Merge with crew-stable
authorPatrick Mezard <pmezard@gmail.com>
Mon, 10 Sep 2007 23:53:23 +0200
changeset 5293 32ec518ee3cb
parent 5290 05889b6b1468 (current diff)
parent 5292 5a65d870871d (diff)
child 5295 51b132b4fd36
Merge with crew-stable
hgext/extdiff.py
mercurial/sshrepo.py
mercurial/util.py
--- a/hgext/extdiff.py	Fri Sep 07 17:54:38 2007 +0200
+++ b/hgext/extdiff.py	Mon Sep 10 23:53:23 2007 +0200
@@ -201,17 +201,17 @@
             '''use closure to save diff command to use'''
             def mydiff(ui, repo, *pats, **opts):
                 return dodiff(ui, repo, path, diffopts, pats, opts)
-            mydiff.__doc__ = '''use %(path)r to diff repository (or selected files)
+            mydiff.__doc__ = '''use %(path)s to diff repository (or selected files)
 
             Show differences between revisions for the specified
-            files, using the %(path)r program.
+            files, using the %(path)s program.
 
             When two revision arguments are given, then changes are
             shown between those revisions. If only one revision is
             specified then that revision is compared to the working
             directory, and, when no revisions are specified, the
             working directory files are compared to its parent.''' % {
-                'path': path,
+                'path': util.uirepr(path),
                 }
             return mydiff
         cmdtable[cmd] = (save(cmd, path, diffopts),
--- a/mercurial/sshrepo.py	Fri Sep 07 17:54:38 2007 +0200
+++ b/mercurial/sshrepo.py	Mon Sep 10 23:53:23 2007 +0200
@@ -35,7 +35,7 @@
             cmd = cmd % (sshcmd, args, remotecmd, self.path)
 
             ui.note('running %s\n' % cmd)
-            res = os.system(cmd)
+            res = util.system(cmd)
             if res != 0:
                 self.raise_(repo.RepoError(_("could not create remote repo")))
 
@@ -51,6 +51,7 @@
         cmd = '%s %s "%s -R %s serve --stdio"'
         cmd = cmd % (sshcmd, args, remotecmd, self.path)
 
+        cmd = util.quotecommand(cmd)
         ui.note('running %s\n' % cmd)
         self.pipeo, self.pipei, self.pipee = os.popen3(cmd, 'b')
 
--- a/mercurial/util.py	Fri Sep 07 17:54:38 2007 +0200
+++ b/mercurial/util.py	Mon Sep 10 23:53:23 2007 +0200
@@ -1001,6 +1001,12 @@
             _quotere = re.compile(r'(\\*)("|\\$)')
         return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
 
+    def quotecommand(cmd):
+        """Build a command string suitable for os.popen* calls."""
+        # The extra quotes are needed because popen* runs the command
+        # through the current COMSPEC. cmd.exe suppress enclosing quotes.
+        return '"' + cmd + '"'
+
     def explain_exit(code):
         return _("exited with status %d") % code, code
 
@@ -1154,6 +1160,9 @@
         else:
             return "'%s'" % s.replace("'", "'\\''")
 
+    def quotecommand(cmd):
+        return cmd
+
     def testpid(pid):
         '''return False if pid dead, True if running or not sure'''
         if os.sys.platform == 'OpenVMS':
@@ -1681,3 +1690,7 @@
         if path.startswith('//'):
             path = path[2:]
     return path
+
+def uirepr(s):
+    # Avoid double backslash in Windows path repr()
+    return repr(s).replace('\\\\', '\\')