[svn r37264] create the new development trunk
--HG-- branch : trunk
This commit is contained in:
@@ -0,0 +1 @@
|
||||
#
|
||||
@@ -0,0 +1,228 @@
|
||||
SVN-fs-dump-format-version: 2
|
||||
|
||||
UUID: 876a30f4-1eed-0310-aeb7-ae314d1e5934
|
||||
|
||||
Revision-number: 0
|
||||
Prop-content-length: 56
|
||||
Content-length: 56
|
||||
|
||||
K 8
|
||||
svn:date
|
||||
V 27
|
||||
2005-01-07T23:55:31.755989Z
|
||||
PROPS-END
|
||||
|
||||
Revision-number: 1
|
||||
Prop-content-length: 118
|
||||
Content-length: 118
|
||||
|
||||
K 7
|
||||
svn:log
|
||||
V 20
|
||||
testrepo setup rev 1
|
||||
K 10
|
||||
svn:author
|
||||
V 3
|
||||
hpk
|
||||
K 8
|
||||
svn:date
|
||||
V 27
|
||||
2005-01-07T23:55:37.815386Z
|
||||
PROPS-END
|
||||
|
||||
Node-path: execfile
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Text-content-length: 4
|
||||
Text-content-md5: d4b5bc61e16310f08c5d11866eba0a22
|
||||
Content-length: 14
|
||||
|
||||
PROPS-END
|
||||
x=42
|
||||
|
||||
Node-path: otherdir
|
||||
Node-kind: dir
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Content-length: 10
|
||||
|
||||
PROPS-END
|
||||
|
||||
|
||||
Node-path: otherdir/__init__.py
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Text-content-length: 0
|
||||
Text-content-md5: d41d8cd98f00b204e9800998ecf8427e
|
||||
Content-length: 10
|
||||
|
||||
PROPS-END
|
||||
|
||||
|
||||
Node-path: otherdir/a.py
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Text-content-length: 30
|
||||
Text-content-md5: 247c7daeb2ee5dcab0aba7bd12bad665
|
||||
Content-length: 40
|
||||
|
||||
PROPS-END
|
||||
from b import stuff as result
|
||||
|
||||
|
||||
Node-path: otherdir/b.py
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Text-content-length: 15
|
||||
Text-content-md5: c1b13503469a7711306d03a4b0721bc6
|
||||
Content-length: 25
|
||||
|
||||
PROPS-END
|
||||
stuff="got it"
|
||||
|
||||
|
||||
Node-path: otherdir/c.py
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Text-content-length: 75
|
||||
Text-content-md5: 250cdb6b5df68536152c681f48297569
|
||||
Content-length: 85
|
||||
|
||||
PROPS-END
|
||||
import py; py.magic.autopath()
|
||||
import otherdir.a
|
||||
value = otherdir.a.result
|
||||
|
||||
|
||||
Node-path: otherdir/d.py
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Text-content-length: 72
|
||||
Text-content-md5: 940c9c621e7b198e081459642c37f5a7
|
||||
Content-length: 82
|
||||
|
||||
PROPS-END
|
||||
import py; py.magic.autopath()
|
||||
from otherdir import a
|
||||
value2 = a.result
|
||||
|
||||
|
||||
Node-path: sampledir
|
||||
Node-kind: dir
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Content-length: 10
|
||||
|
||||
PROPS-END
|
||||
|
||||
|
||||
Node-path: sampledir/otherfile
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Text-content-length: 0
|
||||
Text-content-md5: d41d8cd98f00b204e9800998ecf8427e
|
||||
Content-length: 10
|
||||
|
||||
PROPS-END
|
||||
|
||||
|
||||
Node-path: samplefile
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 40
|
||||
Text-content-length: 11
|
||||
Text-content-md5: 9225ac28b32156979ab6482b8bb5fb8c
|
||||
Content-length: 51
|
||||
|
||||
K 13
|
||||
svn:eol-style
|
||||
V 6
|
||||
native
|
||||
PROPS-END
|
||||
samplefile
|
||||
|
||||
|
||||
Node-path: samplepickle
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Text-content-length: 56
|
||||
Text-content-md5: 719d85c1329a33134bb98f56b756c545
|
||||
Content-length: 66
|
||||
|
||||
PROPS-END
|
||||
(dp1
|
||||
S'answer'
|
||||
p2
|
||||
I42
|
||||
sI1
|
||||
I2
|
||||
sS'hello'
|
||||
p3
|
||||
S'world'
|
||||
p4
|
||||
s.
|
||||
|
||||
Revision-number: 2
|
||||
Prop-content-length: 108
|
||||
Content-length: 108
|
||||
|
||||
K 7
|
||||
svn:log
|
||||
V 10
|
||||
second rev
|
||||
K 10
|
||||
svn:author
|
||||
V 3
|
||||
hpk
|
||||
K 8
|
||||
svn:date
|
||||
V 27
|
||||
2005-01-07T23:55:39.223202Z
|
||||
PROPS-END
|
||||
|
||||
Node-path: anotherfile
|
||||
Node-kind: file
|
||||
Node-action: add
|
||||
Prop-content-length: 10
|
||||
Text-content-length: 5
|
||||
Text-content-md5: 5d41402abc4b2a76b9719d911017c592
|
||||
Content-length: 15
|
||||
|
||||
PROPS-END
|
||||
hello
|
||||
|
||||
Revision-number: 3
|
||||
Prop-content-length: 106
|
||||
Content-length: 106
|
||||
|
||||
K 7
|
||||
svn:log
|
||||
V 9
|
||||
third rev
|
||||
K 10
|
||||
svn:author
|
||||
V 3
|
||||
hpk
|
||||
K 8
|
||||
svn:date
|
||||
V 27
|
||||
2005-01-07T23:55:41.556642Z
|
||||
PROPS-END
|
||||
|
||||
Node-path: anotherfile
|
||||
Node-kind: file
|
||||
Node-action: change
|
||||
Text-content-length: 5
|
||||
Text-content-md5: 7d793037a0760186574b0282f2f435e7
|
||||
Content-length: 5
|
||||
|
||||
world
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
import sys
|
||||
import py
|
||||
from py import path, test, process
|
||||
from py.__.path.testing.fscommon import CommonFSTests, setuptestfs
|
||||
from py.__.path.svn import cache, svncommon
|
||||
|
||||
mypath = py.magic.autopath()
|
||||
repodump = mypath.dirpath('repotest.dump')
|
||||
|
||||
# make a wc directory out of a given root url
|
||||
# cache previously obtained wcs!
|
||||
#
|
||||
def getrepowc(reponame='a~bc$aaa~', wcname='wc'):
|
||||
repo = py.test.ensuretemp(reponame)
|
||||
wcdir = py.test.ensuretemp(wcname)
|
||||
if not repo.listdir():
|
||||
#assert not wcdir.check()
|
||||
repo.ensure(dir=1)
|
||||
try:
|
||||
py.process.cmdexec('svnadmin create "%s"' %
|
||||
svncommon._escape_helper(repo))
|
||||
py.process.cmdexec('svnadmin load -q "%s" <"%s"' %
|
||||
(svncommon._escape_helper(repo), repodump))
|
||||
except py.process.cmdexec.Error:
|
||||
raise
|
||||
repo.remove()
|
||||
raise py.test.skip('could not create temporary svn test repository')
|
||||
print "created svn repository", repo
|
||||
wcdir.ensure(dir=1)
|
||||
wc = py.path.svnwc(wcdir)
|
||||
if py.std.sys.platform == 'win32':
|
||||
repo = '/' + str(repo).replace('\\', '/')
|
||||
wc.checkout(url='file://%s' % repo)
|
||||
print "checked out new repo into", wc
|
||||
else:
|
||||
print "using repository at", repo
|
||||
wc = py.path.svnwc(wcdir)
|
||||
return ("file://%s" % repo, wc)
|
||||
|
||||
|
||||
def save_repowc():
|
||||
repo, wc = getrepowc()
|
||||
repo = py.path.local(repo[len("file://"):])
|
||||
assert repo.check()
|
||||
savedrepo = repo.dirpath('repo_save')
|
||||
savedwc = wc.dirpath('wc_save')
|
||||
repo.copy(savedrepo)
|
||||
wc.localpath.copy(savedwc.localpath)
|
||||
return savedrepo, savedwc
|
||||
|
||||
def restore_repowc((savedrepo, savedwc)):
|
||||
repo, wc = getrepowc()
|
||||
print repo
|
||||
print repo[len("file://"):]
|
||||
repo = py.path.local(repo[len("file://"):])
|
||||
print repo
|
||||
assert repo.check()
|
||||
# repositories have read only files on windows
|
||||
#repo.chmod(0777, rec=True)
|
||||
repo.remove()
|
||||
wc.localpath.remove()
|
||||
savedrepo.move(repo)
|
||||
savedwc.localpath.move(wc.localpath)
|
||||
|
||||
# create an empty repository for testing purposes and return the url to it
|
||||
def make_test_repo(name="test-repository"):
|
||||
repo = py.test.ensuretemp(name)
|
||||
try:
|
||||
py.process.cmdexec('svnadmin create %s' % repo)
|
||||
except:
|
||||
repo.remove()
|
||||
raise
|
||||
if sys.platform == 'win32':
|
||||
repo = '/' + str(repo).replace('\\', '/')
|
||||
return py.path.svnurl("file://%s" % repo)
|
||||
|
||||
class CommonSvnTests(CommonFSTests):
|
||||
|
||||
def setup_method(self, meth):
|
||||
bn = meth.func_name
|
||||
for x in 'test_remove', 'test_move':
|
||||
if bn.startswith(x):
|
||||
self._savedrepowc = save_repowc()
|
||||
|
||||
def teardown_method(self, meth):
|
||||
x = getattr(self, '_savedrepowc', None)
|
||||
if x is not None:
|
||||
restore_repowc(x)
|
||||
del self._savedrepowc
|
||||
|
||||
def test_propget(self):
|
||||
url = self.root.join("samplefile")
|
||||
value = url.propget('svn:eol-style')
|
||||
assert value == 'native'
|
||||
|
||||
def test_proplist(self):
|
||||
url = self.root.join("samplefile")
|
||||
res = url.proplist()
|
||||
assert res['svn:eol-style'] == 'native'
|
||||
|
||||
def test_info(self):
|
||||
url = self.root.join("samplefile")
|
||||
res = url.info()
|
||||
assert res.size > len("samplefile") and res.created_rev >= 0
|
||||
|
||||
def xxxtest_info_log(self):
|
||||
url = self.root.join("samplefile")
|
||||
res = url.log(rev_start=1155, rev_end=1155, verbose=True)
|
||||
assert res[0].revision == 1155 and res[0].author == "jum"
|
||||
from time import gmtime
|
||||
t = gmtime(res[0].date)
|
||||
assert t.tm_year == 2003 and t.tm_mon == 7 and t.tm_mday == 17
|
||||
|
||||
class CommonCommandAndBindingTests(CommonSvnTests):
|
||||
def test_trailing_slash_is_stripped(self):
|
||||
# XXX we need to test more normalizing properties
|
||||
url = self.root.join("/")
|
||||
assert self.root == url
|
||||
|
||||
#def test_different_revs_compare_unequal(self):
|
||||
# newpath = self.root.new(rev=1199)
|
||||
# assert newpath != self.root
|
||||
|
||||
def test_exists_svn_root(self):
|
||||
assert self.root.check()
|
||||
|
||||
#def test_not_exists_rev(self):
|
||||
# url = self.root.__class__(self.rooturl, rev=500)
|
||||
# assert url.check(exists=0)
|
||||
|
||||
#def test_nonexisting_listdir_rev(self):
|
||||
# url = self.root.__class__(self.rooturl, rev=500)
|
||||
# raises(py.error.ENOENT, url.listdir)
|
||||
|
||||
#def test_newrev(self):
|
||||
# url = self.root.new(rev=None)
|
||||
# assert url.rev == None
|
||||
# assert url.strpath == self.root.strpath
|
||||
# url = self.root.new(rev=10)
|
||||
# assert url.rev == 10
|
||||
|
||||
#def test_info_rev(self):
|
||||
# url = self.root.__class__(self.rooturl, rev=1155)
|
||||
# url = url.join("samplefile")
|
||||
# res = url.info()
|
||||
# assert res.size > len("samplefile") and res.created_rev == 1155
|
||||
|
||||
# the following tests are easier if we have a path class
|
||||
def test_repocache_simple(self):
|
||||
repocache = cache.RepoCache()
|
||||
repocache.put(self.root.strpath, 42)
|
||||
url, rev = repocache.get(self.root.join('test').strpath)
|
||||
assert rev == 42
|
||||
assert url == self.root.strpath
|
||||
|
||||
def test_repocache_notimeout(self):
|
||||
repocache = cache.RepoCache()
|
||||
repocache.timeout = 0
|
||||
repocache.put(self.root.strpath, self.root.rev)
|
||||
url, rev = repocache.get(self.root.strpath)
|
||||
assert rev == -1
|
||||
assert url == self.root.strpath
|
||||
|
||||
def test_repocache_outdated(self):
|
||||
repocache = cache.RepoCache()
|
||||
repocache.put(self.root.strpath, 42, timestamp=0)
|
||||
url, rev = repocache.get(self.root.join('test').strpath)
|
||||
assert rev == -1
|
||||
assert url == self.root.strpath
|
||||
|
||||
def _test_getreporev(self):
|
||||
""" this test runs so slow it's usually disabled """
|
||||
old = cache.repositories.repos
|
||||
try:
|
||||
_repocache.clear()
|
||||
root = self.root.new(rev=-1)
|
||||
url, rev = cache.repocache.get(root.strpath)
|
||||
assert rev>=0
|
||||
assert url == svnrepourl
|
||||
finally:
|
||||
repositories.repos = old
|
||||
|
||||
#cache.repositories.put(svnrepourl, 1200, 0)
|
||||
@@ -0,0 +1,26 @@
|
||||
import py
|
||||
from py.__.path.svn.testing.svntestbase import make_test_repo
|
||||
|
||||
|
||||
if py.path.local.sysfind('svn') is None:
|
||||
py.test.skip("cannot test py.path.svn, 'svn' binary not found")
|
||||
|
||||
class TestMakeRepo(object):
|
||||
def setup_class(cls):
|
||||
cls.repo = make_test_repo()
|
||||
cls.wc = py.path.svnwc(py.test.ensuretemp("test-wc").join("wc"))
|
||||
|
||||
def test_empty_checkout(self):
|
||||
self.wc.checkout(self.repo)
|
||||
assert len(self.wc.listdir()) == 0
|
||||
|
||||
def test_commit(self):
|
||||
p = self.wc.join("a_file")
|
||||
p.write("test file")
|
||||
p.add()
|
||||
rev = self.wc.commit("some test")
|
||||
assert p.info().rev == 1
|
||||
assert rev == 1
|
||||
rev = self.wc.commit()
|
||||
assert rev is None
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import py
|
||||
from py.__.path.svn.urlcommand import InfoSvnCommand
|
||||
from py.__.path.svn.testing.svntestbase import CommonCommandAndBindingTests, \
|
||||
getrepowc
|
||||
import datetime
|
||||
import time
|
||||
|
||||
|
||||
if py.path.local.sysfind('svn') is None:
|
||||
py.test.skip("cannot test py.path.svn, 'svn' binary not found")
|
||||
|
||||
class TestSvnCommandPath(CommonCommandAndBindingTests):
|
||||
def setup_class(cls):
|
||||
repo, wc = getrepowc()
|
||||
cls.root = py.path.svnurl(repo)
|
||||
|
||||
def test_svnurl_needs_arg(self):
|
||||
py.test.raises(TypeError, "py.path.svnurl()")
|
||||
|
||||
def test_svnurl_does_not_accept_None_either(self):
|
||||
py.test.raises(Exception, "py.path.svnurl(None)")
|
||||
|
||||
def test_svnurl_characters_simple(self):
|
||||
py.path.svnurl("svn+ssh://hello/world")
|
||||
|
||||
def test_svnurl_characters_at_user(self):
|
||||
py.path.svnurl("http://user@host.com/some/dir")
|
||||
|
||||
def test_svnurl_characters_at_path(self):
|
||||
py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo@bar")')
|
||||
|
||||
def test_svnurl_characters_colon_port(self):
|
||||
py.path.svnurl("http://host.com:8080/some/dir")
|
||||
|
||||
def test_svnurl_characters_colon_path(self):
|
||||
if py.std.sys.platform == 'win32':
|
||||
# colons are allowed on win32, because they're part of the drive
|
||||
# part of an absolute path... however, they shouldn't be allowed in
|
||||
# other parts, I think
|
||||
py.test.skip('XXX fixme win32')
|
||||
py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo:bar")')
|
||||
|
||||
def test_svnurl_characters_tilde_end(self):
|
||||
py.path.svnurl("http://host.com/some/file~")
|
||||
|
||||
# XXX
|
||||
def xtest_copy_file(self):
|
||||
raise py.test.Skipped(msg="XXX fix svnurl first")
|
||||
|
||||
def xtest_copy_dir(self):
|
||||
py.test.skipp("XXX fix svnurl first")
|
||||
|
||||
def XXXtest_info_log(self):
|
||||
url = self.root.join("samplefile")
|
||||
res = url.log(rev_start=1155, rev_end=1155, verbose=True)
|
||||
assert res[0].revision == 1155 and res[0].author == "jum"
|
||||
from time import gmtime
|
||||
t = gmtime(res[0].date)
|
||||
assert t.tm_year == 2003 and t.tm_mon == 7 and t.tm_mday == 17
|
||||
|
||||
class TestSvnInfoCommand:
|
||||
|
||||
def test_svn_1_2(self):
|
||||
line = " 2256 hpk 165 Nov 24 17:55 __init__.py"
|
||||
info = InfoSvnCommand(line)
|
||||
now = datetime.datetime.now()
|
||||
assert info.last_author == 'hpk'
|
||||
assert info.created_rev == 2256
|
||||
assert info.kind == 'file'
|
||||
assert time.gmtime(info.mtime)[:6] == (2006, 11, 24, 17, 55, 0)
|
||||
assert info.size == 165
|
||||
assert info.time == info.mtime * 1000000
|
||||
|
||||
def test_svn_1_3(self):
|
||||
line =" 4784 hpk 2 Jun 01 2004 __init__.py"
|
||||
info = InfoSvnCommand(line)
|
||||
assert info.last_author == 'hpk'
|
||||
assert info.kind == 'file'
|
||||
|
||||
def test_svn_1_3_b(self):
|
||||
line =" 74 autoadmi Oct 06 23:59 plonesolutions.com/"
|
||||
info = InfoSvnCommand(line)
|
||||
assert info.last_author == 'autoadmi'
|
||||
assert info.kind == 'dir'
|
||||
|
||||
def test_badchars():
|
||||
py.test.raises(ValueError, "py.path.svnurl('file:///tmp/@@@:')")
|
||||
@@ -0,0 +1,311 @@
|
||||
import py
|
||||
from py.__.path.svn.testing.svntestbase import CommonSvnTests, getrepowc
|
||||
from py.__.path.svn.wccommand import InfoSvnWCCommand
|
||||
from py.__.path.svn.wccommand import parse_wcinfotime
|
||||
from py.__.path.svn import svncommon
|
||||
|
||||
|
||||
if py.path.local.sysfind('svn') is None:
|
||||
py.test.skip("cannot test py.path.svn, 'svn' binary not found")
|
||||
|
||||
|
||||
class TestWCSvnCommandPath(CommonSvnTests):
|
||||
|
||||
def setup_class(cls):
|
||||
repo, cls.root = getrepowc()
|
||||
|
||||
def test_status_attributes_simple(self):
|
||||
def assert_nochange(p):
|
||||
s = p.status()
|
||||
assert not s.modified
|
||||
assert not s.prop_modified
|
||||
assert not s.added
|
||||
assert not s.deleted
|
||||
|
||||
dpath = self.root.join('sampledir')
|
||||
assert_nochange(self.root.join('sampledir'))
|
||||
assert_nochange(self.root.join('samplefile'))
|
||||
|
||||
def test_status_added(self):
|
||||
nf = self.root.join('newfile')
|
||||
nf.write('hello')
|
||||
nf.add()
|
||||
try:
|
||||
s = nf.status()
|
||||
assert s.added
|
||||
assert not s.modified
|
||||
assert not s.prop_modified
|
||||
finally:
|
||||
nf.revert()
|
||||
|
||||
def test_status_change(self):
|
||||
nf = self.root.join('samplefile')
|
||||
try:
|
||||
nf.write(nf.read() + 'change')
|
||||
s = nf.status()
|
||||
assert not s.added
|
||||
assert s.modified
|
||||
assert not s.prop_modified
|
||||
finally:
|
||||
nf.revert()
|
||||
|
||||
def test_status_added_ondirectory(self):
|
||||
sampledir = self.root.join('sampledir')
|
||||
try:
|
||||
t2 = sampledir.mkdir('t2')
|
||||
t1 = t2.join('t1')
|
||||
t1.write('test')
|
||||
t1.add()
|
||||
s = sampledir.status(rec=1)
|
||||
# Comparing just the file names, because paths are unpredictable
|
||||
# on Windows. (long vs. 8.3 paths)
|
||||
assert t1.basename in [item.basename for item in s.added]
|
||||
assert t2.basename in [item.basename for item in s.added]
|
||||
finally:
|
||||
t2.revert(rec=1)
|
||||
t2.localpath.remove(rec=1)
|
||||
|
||||
def test_status_unknown(self):
|
||||
t1 = self.root.join('un1')
|
||||
try:
|
||||
t1.write('test')
|
||||
s = self.root.status()
|
||||
# Comparing just the file names, because paths are unpredictable
|
||||
# on Windows. (long vs. 8.3 paths)
|
||||
assert t1.basename in [item.basename for item in s.unknown]
|
||||
finally:
|
||||
t1.localpath.remove()
|
||||
|
||||
def test_status_unchanged(self):
|
||||
r = self.root
|
||||
s = self.root.status(rec=1)
|
||||
# Comparing just the file names, because paths are unpredictable
|
||||
# on Windows. (long vs. 8.3 paths)
|
||||
assert r.join('samplefile').basename in [item.basename
|
||||
for item in s.unchanged]
|
||||
assert r.join('sampledir').basename in [item.basename
|
||||
for item in s.unchanged]
|
||||
assert r.join('sampledir/otherfile').basename in [item.basename
|
||||
for item in s.unchanged]
|
||||
|
||||
def test_status_update(self):
|
||||
r = self.root
|
||||
try:
|
||||
r.update(rev=1)
|
||||
s = r.status(updates=1, rec=1)
|
||||
# Comparing just the file names, because paths are unpredictable
|
||||
# on Windows. (long vs. 8.3 paths)
|
||||
assert r.join('anotherfile').basename in [item.basename for
|
||||
item in s.update_available]
|
||||
#assert len(s.update_available) == 1
|
||||
finally:
|
||||
r.update()
|
||||
|
||||
def test_diff(self):
|
||||
p = self.root / 'anotherfile'
|
||||
out = p.diff(rev=2)
|
||||
assert out.find('hello') != -1
|
||||
|
||||
def test_blame(self):
|
||||
p = self.root.join('samplepickle')
|
||||
lines = p.blame()
|
||||
assert sum([l[0] for l in lines]) == len(lines)
|
||||
for l1, l2 in zip(p.readlines(), [l[2] for l in lines]):
|
||||
assert l1 == l2
|
||||
assert [l[1] for l in lines] == ['hpk'] * len(lines)
|
||||
p = self.root.join('samplefile')
|
||||
lines = p.blame()
|
||||
assert sum([l[0] for l in lines]) == len(lines)
|
||||
for l1, l2 in zip(p.readlines(), [l[2] for l in lines]):
|
||||
assert l1 == l2
|
||||
assert [l[1] for l in lines] == ['hpk'] * len(lines)
|
||||
|
||||
def test_join_abs(self):
|
||||
s = str(self.root.localpath)
|
||||
n = self.root.join(s, abs=1)
|
||||
assert self.root == n
|
||||
|
||||
def test_join_abs2(self):
|
||||
assert self.root.join('samplefile', abs=1) == self.root.join('samplefile')
|
||||
|
||||
def test_str_gives_localpath(self):
|
||||
assert str(self.root) == str(self.root.localpath)
|
||||
|
||||
def test_versioned(self):
|
||||
assert self.root.check(versioned=1)
|
||||
# TODO: Why does my copy of svn think .svn is versioned?
|
||||
#assert self.root.join('.svn').check(versioned=0)
|
||||
assert self.root.join('samplefile').check(versioned=1)
|
||||
assert not self.root.join('notexisting').check(versioned=1)
|
||||
notexisting = self.root.join('hello').localpath
|
||||
try:
|
||||
notexisting.write("")
|
||||
assert self.root.join('hello').check(versioned=0)
|
||||
finally:
|
||||
notexisting.remove()
|
||||
|
||||
def test_properties(self):
|
||||
try:
|
||||
self.root.propset('gaga', 'this')
|
||||
assert self.root.propget('gaga') == 'this'
|
||||
# Comparing just the file names, because paths are unpredictable
|
||||
# on Windows. (long vs. 8.3 paths)
|
||||
assert self.root.basename in [item.basename for item in
|
||||
self.root.status().prop_modified]
|
||||
assert 'gaga' in self.root.proplist()
|
||||
assert self.root.proplist()['gaga'] == 'this'
|
||||
|
||||
finally:
|
||||
self.root.propdel('gaga')
|
||||
|
||||
def test_proplist_recursive(self):
|
||||
s = self.root.join('samplefile')
|
||||
s.propset('gugu', 'that')
|
||||
try:
|
||||
p = self.root.proplist(rec=1)
|
||||
# Comparing just the file names, because paths are unpredictable
|
||||
# on Windows. (long vs. 8.3 paths)
|
||||
assert (self.root / 'samplefile').basename in [item.basename
|
||||
for item in p]
|
||||
finally:
|
||||
s.propdel('gugu')
|
||||
|
||||
def test_long_properties(self):
|
||||
value = """
|
||||
vadm:posix : root root 0100755
|
||||
Properties on 'chroot/dns/var/bind/db.net.xots':
|
||||
"""
|
||||
try:
|
||||
self.root.propset('gaga', value)
|
||||
backvalue = self.root.propget('gaga')
|
||||
assert backvalue == value
|
||||
#assert len(backvalue.split('\n')) == 1
|
||||
finally:
|
||||
self.root.propdel('gaga')
|
||||
|
||||
|
||||
def test_ensure(self):
|
||||
newpath = self.root.ensure('a', 'b', 'c')
|
||||
try:
|
||||
assert newpath.check(exists=1, versioned=1)
|
||||
newpath.write("hello")
|
||||
newpath.ensure()
|
||||
assert newpath.read() == "hello"
|
||||
finally:
|
||||
self.root.join('a').remove(force=1)
|
||||
|
||||
def test_not_versioned(self):
|
||||
p = self.root.localpath.mkdir('whatever')
|
||||
f = self.root.localpath.ensure('testcreatedfile')
|
||||
try:
|
||||
assert self.root.join('whatever').check(versioned=0)
|
||||
assert self.root.join('testcreatedfile').check(versioned=0)
|
||||
assert not self.root.join('testcreatedfile').check(versioned=1)
|
||||
finally:
|
||||
p.remove(rec=1)
|
||||
f.remove()
|
||||
|
||||
#def test_log(self):
|
||||
# l = self.root.log()
|
||||
# assert len(l) == 3 # might need to be upped if more tests are added
|
||||
|
||||
class XTestWCSvnCommandPathSpecial:
|
||||
|
||||
rooturl = 'http://codespeak.net/svn/py.path/trunk/dist/py.path/test/data'
|
||||
#def test_update_none_rev(self):
|
||||
# path = tmpdir.join('checkouttest')
|
||||
# wcpath = newpath(xsvnwc=str(path), url=self.rooturl)
|
||||
# try:
|
||||
# wcpath.checkout(rev=2100)
|
||||
# wcpath.update()
|
||||
# assert wcpath.info().rev > 2100
|
||||
# finally:
|
||||
# wcpath.localpath.remove(rec=1)
|
||||
|
||||
def test_parse_wcinfotime():
|
||||
assert (parse_wcinfotime('2006-05-30 20:45:26 +0200 (Tue, 30 May 2006)') ==
|
||||
1149021926)
|
||||
assert (parse_wcinfotime('2003-10-27 20:43:14 +0100 (Mon, 27 Oct 2003)') ==
|
||||
1067287394)
|
||||
|
||||
class TestInfoSvnWCCommand:
|
||||
|
||||
def test_svn_1_2(self):
|
||||
output = """
|
||||
Path: test_wccommand.py
|
||||
Name: test_wccommand.py
|
||||
URL: http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py
|
||||
Repository UUID: fd0d7bf2-dfb6-0310-8d31-b7ecfe96aada
|
||||
Revision: 28137
|
||||
Node Kind: file
|
||||
Schedule: normal
|
||||
Last Changed Author: jan
|
||||
Last Changed Rev: 27939
|
||||
Last Changed Date: 2006-05-30 20:45:26 +0200 (Tue, 30 May 2006)
|
||||
Text Last Updated: 2006-06-01 00:42:53 +0200 (Thu, 01 Jun 2006)
|
||||
Properties Last Updated: 2006-05-23 11:54:59 +0200 (Tue, 23 May 2006)
|
||||
Checksum: 357e44880e5d80157cc5fbc3ce9822e3
|
||||
"""
|
||||
path = py.magic.autopath().dirpath().chdir()
|
||||
info = InfoSvnWCCommand(output)
|
||||
path.chdir()
|
||||
assert info.last_author == 'jan'
|
||||
assert info.kind == 'file'
|
||||
assert info.mtime == 1149021926.0
|
||||
assert info.url == 'http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py'
|
||||
assert info.time == 1149021926000000.0
|
||||
assert info.rev == 28137
|
||||
|
||||
|
||||
def test_svn_1_3(self):
|
||||
output = """
|
||||
Path: test_wccommand.py
|
||||
Name: test_wccommand.py
|
||||
URL: http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py
|
||||
Repository Root: http://codespeak.net/svn
|
||||
Repository UUID: fd0d7bf2-dfb6-0310-8d31-b7ecfe96aada
|
||||
Revision: 28124
|
||||
Node Kind: file
|
||||
Schedule: normal
|
||||
Last Changed Author: jan
|
||||
Last Changed Rev: 27939
|
||||
Last Changed Date: 2006-05-30 20:45:26 +0200 (Tue, 30 May 2006)
|
||||
Text Last Updated: 2006-06-02 23:46:11 +0200 (Fri, 02 Jun 2006)
|
||||
Properties Last Updated: 2006-06-02 23:45:28 +0200 (Fri, 02 Jun 2006)
|
||||
Checksum: 357e44880e5d80157cc5fbc3ce9822e3
|
||||
"""
|
||||
path = py.magic.autopath().dirpath().chdir()
|
||||
info = InfoSvnWCCommand(output)
|
||||
path.chdir()
|
||||
assert info.last_author == 'jan'
|
||||
assert info.kind == 'file'
|
||||
assert info.mtime == 1149021926.0
|
||||
assert info.url == 'http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py'
|
||||
assert info.rev == 28124
|
||||
assert info.time == 1149021926000000.0
|
||||
|
||||
class TestWCSvnCommandPathEmptyRepo(object):
|
||||
|
||||
def setup_class(cls):
|
||||
repo = py.test.ensuretemp("emptyrepo")
|
||||
wcdir = py.test.ensuretemp("emptywc")
|
||||
py.process.cmdexec('svnadmin create "%s"' %
|
||||
svncommon._escape_helper(repo))
|
||||
wc = py.path.svnwc(wcdir)
|
||||
repopath = repo.strpath
|
||||
if py.std.sys.platform.startswith('win32'):
|
||||
# strange win problem, paths become something like file:///c:\\foo
|
||||
repourl = 'file:///%s' % (repopath.replace('\\', '/'),)
|
||||
else:
|
||||
repourl = 'file://%s' % (repopath,)
|
||||
wc.checkout(url=repourl)
|
||||
cls.wc = wc
|
||||
|
||||
def test_info(self):
|
||||
self.wc.info().rev = 0
|
||||
|
||||
def test_characters_at():
|
||||
py.test.raises(ValueError, "py.path.svnwc('/tmp/@@@:')")
|
||||
|
||||
def test_characters_tilde():
|
||||
py.path.svnwc('/tmp/test~')
|
||||
Reference in New Issue
Block a user