[py-svn] r46692 - in py/trunk/py/path/svn: . testing

guido at codespeak.net guido at codespeak.net
Mon Sep 17 14:22:44 CEST 2007


Author: guido
Date: Mon Sep 17 14:22:39 2007
New Revision: 46692

Modified:
   py/trunk/py/path/svn/testing/test_urlcommand.py
   py/trunk/py/path/svn/testing/test_wccommand.py
   py/trunk/py/path/svn/urlcommand.py
Log:
Added 'export()' method to py.path.svnurl.


Modified: py/trunk/py/path/svn/testing/test_urlcommand.py
==============================================================================
--- py/trunk/py/path/svn/testing/test_urlcommand.py	(original)
+++ py/trunk/py/path/svn/testing/test_urlcommand.py	Mon Sep 17 14:22:39 2007
@@ -59,6 +59,44 @@
             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):

Modified: py/trunk/py/path/svn/testing/test_wccommand.py
==============================================================================
--- py/trunk/py/path/svn/testing/test_wccommand.py	(original)
+++ py/trunk/py/path/svn/testing/test_wccommand.py	Mon Sep 17 14:22:39 2007
@@ -270,6 +270,19 @@
         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

Modified: py/trunk/py/path/svn/urlcommand.py
==============================================================================
--- py/trunk/py/path/svn/urlcommand.py	(original)
+++ py/trunk/py/path/svn/urlcommand.py	Mon Sep 17 14:22:39 2007
@@ -132,6 +132,20 @@
         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'



More information about the pytest-commit mailing list