Problem with hgmerge and spaces in paths

Dales, Michael W michael.w.dales at
Fri Sep 30 10:24:56 CDT 2005

Rather than use the Windows version of mercurial, I installed the source
version as per the UnixInstall isntructions under cygwin. This seems to
work alright, except when you come to do a merge. hgmerge failes due to
spaces commonly found in the filenames (e.g., /cygdrive/c/Documents and
Settings/user/My Documents/foo), and doesn't allow for this
when it invokes hgmerge. This leads to hg update -m reporting:

cp: cannot stat `/cygdrive/c/Documents': No such file or directory

The below patch fixes that bug by simply putting quotes around all the
parameters. Perhaps this needs shoring up otherwhere in the source to
prevent other similar problems, but I've still not made it through the
mercurial tutorial to trip over them yet :) Tested under cygwin on
Windows XP. 

-- Michael

# HG changeset patch
# User michael.w.dales at
# Node ID 0b20b991c1a4dabc0cd72dd2bb8adc360942ec9e
# Parent  0f25830f6bc3f0d36e88ec8c1ae11b62ecd0108b
Fixed problem with invoking hgmerge on paths with spaces.

diff -r 0f25830f6bc3 -r 0b20b991c1a4 mercurial/
--- a/mercurial/	Thu Sep 29 15:18:32 2005 -0700
+++ b/mercurial/	Fri Sep 30 15:09:19 2005 +0000
@@ -1294,7 +1294,7 @@
         cmd = (os.environ.get("HGMERGE") or self.ui.config("ui",
                or "hgmerge")
-        r = os.system("%s %s %s %s" % (cmd, a, b, c))
+        r = os.system('%s "%s" "%s" "%s"' % (cmd, a, b, c))
         if r:
             self.ui.warn("merging %s failed!\n" % fn)

More information about the Mercurial mailing list