[py-svn] r27939 - in py/dist/py/path/svn: . testing

jan at codespeak.net jan at codespeak.net
Tue May 30 20:45:27 CEST 2006


Author: jan
Date: Tue May 30 20:45:26 2006
New Revision: 27939

Modified:
   py/dist/py/path/svn/testing/svntestbase.py
   py/dist/py/path/svn/urlcommand.py
   py/dist/py/path/svn/wccommand.py
Log:
added simple shell escaping for names in svn repositories


Modified: py/dist/py/path/svn/testing/svntestbase.py
==============================================================================
--- py/dist/py/path/svn/testing/svntestbase.py	(original)
+++ py/dist/py/path/svn/testing/svntestbase.py	Tue May 30 20:45:26 2006
@@ -11,14 +11,14 @@
 # cache previously obtained wcs!
 #
 def getrepowc():
-    repo = py.test.ensuretemp('repo') 
+    repo = py.test.ensuretemp('repo$*hehe') 
     wcdir = py.test.ensuretemp('wc') 
     if not repo.listdir():
         #assert not wcdir.check()
         repo.ensure(dir=1)
         try:
-            py.process.cmdexec('svnadmin create "%s"' % repo)
-            py.process.cmdexec('svnadmin load -q "%s" <"%s"' % (repo, repodump))
+            py.process.cmdexec('svnadmin create "%s"' % str(repo).replace('$', '\$'))
+            py.process.cmdexec('svnadmin load -q "%s" <"%s"' % (str(repo).replace('$', '\$'), repodump))
         except py.process.cmdexec.Error:
             raise
             repo.remove()

Modified: py/dist/py/path/svn/urlcommand.py
==============================================================================
--- py/dist/py/path/svn/urlcommand.py	(original)
+++ py/dist/py/path/svn/urlcommand.py	Tue May 30 20:45:26 2006
@@ -25,6 +25,9 @@
         self.rev = rev
         return self
 
+    def _escape(self, cmd):
+        return str(cmd).replace('$', '\$')
+
     def __repr__(self):
         if self.rev == -1:
             return 'svnurl(%r)' % self.strpath
@@ -47,7 +50,7 @@
 
     def _svnwrite(self, cmd, *args):
         l = ['svn %s' % cmd]
-        args = map(lambda x: '"%s"' % str(x), args)
+        args = map(lambda x: '"%s"' % str(x).replace('$', '\$'), args)
         l.extend(args)
         l.append('"%s"' % self._encodedurl())
         # fixing the locale because we can't otherwise parse
@@ -75,10 +78,10 @@
             return os.popen(cmd)
         if self.rev is None:
             return popen(svncommon.fixlocale() +
-                            'svn cat "%s"' % (self.strpath, ))
+                            'svn cat "%s"' % (self._escape(self.strpath), ))
         else:
             return popen(svncommon.fixlocale() +
-                            'svn cat -r %s "%s"' % (self.rev, self.strpath))
+                            'svn cat -r %s "%s"' % (self.rev, self._escape(self.strpath)))
 
     def dirpath(self, *args, **kwargs):
         """ return the directory Path of the current Path joined
@@ -104,21 +107,21 @@
         if getattr(target, 'rev', None) is not None:
             raise py.error.EINVAL(target, "revisions are immutable")
         process.cmdexec('svn copy -m "%s" "%s" "%s"' %(msg, 
-                                                str(self), str(target)))
+                                                self._escape(self), self._escape(target)))
         self._lsnorevcache.delentry(target.dirpath().strpath)
 
     def rename(self, target, msg="renamed by py lib invocation"):
         if getattr(self, 'rev', None) is not None:
             raise py.error.EINVAL(self, "revisions are immutable")
         py.process.cmdexec('svn move -m "%s" --force "%s" "%s"' %(
-                           msg, self, target))
+                           msg, self._escape(self), self._escape(target)))
         self._lsnorevcache.delentry(self.dirpath().strpath)
         self._lsnorevcache.delentry(self.strpath)
 
     def remove(self, rec=1, msg='removed by py lib invocation'):
         if self.rev is not None:
             raise py.error.EINVAL(self, "revisions are immutable")
-        process.cmdexec('svn rm -m "%s" "%s"' %(msg, self))
+        process.cmdexec('svn rm -m "%s" "%s"' %(msg, self._escape(self)))
         self._lsnorevcache.delentry(self.dirpath().strpath)
 
     def ensure(self, *args, **kwargs):
@@ -145,8 +148,8 @@
         try:    
             tempdir.ensure(tocreate, dir=dir) 
             cmd = 'svn import -m "%s" "%s" "%s"' % (
-                    "ensure %s" % tocreate, 
-                    tempdir.join(basename), 
+                    "ensure %s" % self._escape(tocreate), 
+                    self._escape(tempdir.join(basename)), 
                     x.join(basename)._encodedurl())
             process.cmdexec(cmd) 
             self._lsnorevcache.delentry(x.strpath)  # !!! 

Modified: py/dist/py/path/svn/wccommand.py
==============================================================================
--- py/dist/py/path/svn/wccommand.py	(original)
+++ py/dist/py/path/svn/wccommand.py	Tue May 30 20:45:26 2006
@@ -58,9 +58,9 @@
 
     def _svn(self, cmd, *args):
         l = ['svn %s' % cmd]
-        args = map(lambda x: '"%s"' % x, args)
+        args = map(lambda x: '"%s"' % str(x).replace('$', '\$'), args)
         l.extend(args)
-        l.append("%s" % self.strpath)
+        l.append("%s" % self.strpath.replace('$', '\$'))
         # try fixing the locale because we can't otherwise parse
         string = svncommon.fixlocale() + " ".join(l)
         if DEBUG:



More information about the pytest-commit mailing list