# HG changeset patch # User Brendan Cully # Date 1154816606 25200 # Node ID f4d9163513663eff9e8d3957487547938ec67208 # Parent 58a679745b38df67dc1bb6559828e6927bdd6946 Add portable shell-quoting function; teach mq to use it. diff -r 58a679745b38 -r f4d916351366 hgext/mq.py --- a/hgext/mq.py Sun Aug 06 16:03:02 2006 +0200 +++ b/hgext/mq.py Sat Aug 05 15:23:26 2006 -0700 @@ -272,8 +272,8 @@ patchfile: file name of patch''' try: pp = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch') - f = os.popen("%s -d '%s' -p1 --no-backup-if-mismatch < '%s'" % - (pp, repo.root, patchfile)) + f = os.popen("%s -d %s -p1 --no-backup-if-mismatch < %s" % + (pp, util.shellquote(repo.root), util.shellquote(patchfile))) except: self.ui.warn("patch failed, unable to continue (try -v)\n") return (None, [], False) diff -r 58a679745b38 -r f4d916351366 mercurial/util.py --- a/mercurial/util.py Sun Aug 06 16:03:02 2006 +0200 +++ b/mercurial/util.py Sat Aug 05 15:23:26 2006 -0700 @@ -611,6 +611,9 @@ def samestat(s1, s2): return False + def shellquote(s): + return '"%s"' % s.replace('"', '\\"') + def explain_exit(code): return _("exited with status %d") % code, code @@ -700,6 +703,9 @@ else: raise + def shellquote(s): + return "'%s'" % s.replace("'", "'\\''") + def testpid(pid): '''return False if pid dead, True if running or not sure''' try: