mq: fix queue.apply to not call os.chdir()
authorVadim Gelfer <vadim.gelfer@gmail.com>
Thu, 27 Jul 2006 18:24:59 -0700
changeset 2713 35caf437a201
parent 2712 8e5cd8d11b51
child 2714 85070b784896
mq: fix queue.apply to not call os.chdir() call to os.chdir broke "hg -R dirname qpush". instead pass -d (change directory) option to patch command.
hgext/mq.py
--- a/hgext/mq.py	Thu Jul 27 16:41:59 2006 -0700
+++ b/hgext/mq.py	Thu Jul 27 18:24:59 2006 -0700
@@ -276,8 +276,6 @@
         # TODO unify with commands.py
         if not patchdir:
             patchdir = self.path
-        pwd = os.getcwd()
-        os.chdir(repo.root)
         err = 0
         if not wlock:
             wlock = repo.wlock()
@@ -304,7 +302,8 @@
 
             try:
                 pp = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch')
-                f = os.popen("%s -p1 --no-backup-if-mismatch < '%s'" % (pp, pf))
+                f = os.popen("%s -d '%s' -p1 --no-backup-if-mismatch < '%s'" %
+                             (pp, repo.root, pf))
             except:
                 self.ui.warn("patch failed, unable to continue (try -v)\n")
                 err = 1
@@ -371,7 +370,6 @@
                 err = 1
                 break
         tr.close()
-        os.chdir(pwd)
         return (err, n)
 
     def delete(self, repo, patch):