[svn r46692] Added 'export()' method to py.path.svnurl.
--HG-- branch : trunk
This commit is contained in:
parent
28c5aae67d
commit
303a6e659a
|
@ -59,6 +59,44 @@ class TestSvnURLCommandPath(CommonCommandAndBindingTests):
|
|||
py.test.skip('XXX fixme win32')
|
||||
py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo:bar")')
|
||||
|
||||
def test_export(self):
|
||||
repo, wc = getrepowc('test_export_repo', 'test_export_wc')
|
||||
foo = wc.join('foo').ensure(dir=True)
|
||||
bar = foo.join('bar').ensure(file=True)
|
||||
bar.write('bar\n')
|
||||
foo.commit('testing something')
|
||||
exportpath = py.test.ensuretemp('test_export_exportdir')
|
||||
url = py.path.svnurl(repo + '/foo')
|
||||
foo = url.export(exportpath.join('foo'))
|
||||
assert foo == exportpath.join('foo')
|
||||
assert isinstance(foo, py.path.local)
|
||||
assert foo.join('bar').check()
|
||||
assert not foo.join('.svn').check()
|
||||
|
||||
def test_export_rev(self):
|
||||
repo, wc = getrepowc('test_export_rev_repo', 'test_export_rev_wc')
|
||||
foo = wc.join('foo').ensure(dir=True)
|
||||
bar = foo.join('bar').ensure(file=True)
|
||||
bar.write('bar\n')
|
||||
rev1 = foo.commit('testing something')
|
||||
print 'rev1:', rev1
|
||||
baz = foo.join('baz').ensure(file=True)
|
||||
baz.write('baz\n')
|
||||
rev2 = foo.commit('testing more')
|
||||
|
||||
exportpath = py.test.ensuretemp('test_export_rev_exportdir')
|
||||
url = py.path.svnurl(repo + '/foo', rev=rev1)
|
||||
foo1 = url.export(exportpath.join('foo1'))
|
||||
assert foo1.check()
|
||||
assert foo1.join('bar').check()
|
||||
assert not foo1.join('baz').check()
|
||||
|
||||
url = py.path.svnurl(repo + '/foo', rev=rev2)
|
||||
foo2 = url.export(exportpath.join('foo2'))
|
||||
assert foo2.check()
|
||||
assert foo2.join('bar').check()
|
||||
assert foo2.join('baz').check()
|
||||
|
||||
class TestSvnInfoCommand:
|
||||
|
||||
def test_svn_1_2(self):
|
||||
|
|
|
@ -270,6 +270,19 @@ class TestWCSvnCommandPath(CommonSvnTests):
|
|||
assert len(status.prop_modified) == 0
|
||||
assert len(status.modified) == 0
|
||||
|
||||
def test_commit_return_value(self):
|
||||
root = self.root
|
||||
testfile = root.join('test.txt').ensure(file=True)
|
||||
testfile.write('test')
|
||||
rev = root.commit('testing')
|
||||
assert type(rev) == int
|
||||
|
||||
anotherfile = root.join('another.txt').ensure(file=True)
|
||||
anotherfile.write('test')
|
||||
rev2 = root.commit('testing more')
|
||||
assert type(rev2) == int
|
||||
assert rev2 == rev + 1
|
||||
|
||||
#def test_log(self):
|
||||
# l = self.root.log()
|
||||
# assert len(l) == 3 # might need to be upped if more tests are added
|
||||
|
|
|
@ -132,6 +132,20 @@ checkin message msg."""
|
|||
process.cmdexec('svn rm -m "%s" "%s"' %(msg, self._escape(self)))
|
||||
self._lsnorevcache.delentry(self.dirpath().strpath)
|
||||
|
||||
def export(self, topath):
|
||||
""" export to a local path
|
||||
|
||||
topath should not exist prior to calling this, returns a
|
||||
py.path.local instance
|
||||
"""
|
||||
topath = py.path.local(topath)
|
||||
args = ['"%s"' % (self._escape(self),),
|
||||
'"%s"' % (self._escape(topath),)]
|
||||
if self.rev is not None:
|
||||
args = ['-r', str(self.rev)] + args
|
||||
process.cmdexec('svn export %s' % (' '.join(args),))
|
||||
return topath
|
||||
|
||||
def ensure(self, *args, **kwargs):
|
||||
""" ensure that an args-joined path exists (by default as
|
||||
a file). If you specify a keyword argument 'dir=True'
|
||||
|
|
Loading…
Reference in New Issue