[PATCH 3 of 7] subrepo: use subprocess's cwd instead of git's --work-tree

Eric Eisner ede at MIT.EDU
Mon Dec 6 20:37:07 CST 2010


# HG changeset patch
# User Eric Eisner <ede at mit.edu>
# Date 1291688247 18000
# Node ID d0cbddfe3f4cd7c00da3d314f3dd36bb808b9bc0
# Parent  83986af605e5b3f756fdd6eecfe185574119f400
subrepo: use subprocess's cwd instead of git's --work-tree

Some older git commands (e.g. git merge) do not properly recognize the
--work-tree argument, so abstract that away from git.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -617,11 +617,10 @@ class gitsubrepo(object):
         return self._gitdir(commands, stream=stream)[0]
 
     def _gitdir(self, commands, stream=False):
-        commands = ['--no-pager', '--git-dir=%s/.git' % self._path,
-                    '--work-tree=%s' % self._path] + commands
-        return self._gitnodir(commands, stream=stream)
+        commands = ['--no-pager'] + commands
+        return self._gitnodir(commands, stream=stream, cwd=self._path)
 
-    def _gitnodir(self, commands, stream=False):
+    def _gitnodir(self, commands, stream=False, cwd=None):
         """Calls the git command
 
         The methods tries to call the git command. versions previor to 1.6.0
@@ -632,7 +631,7 @@ class gitsubrepo(object):
         cmd = util.quotecommand(' '.join(cmd))
 
         # print git's stderr, which is mostly progress and useful info
-        p = subprocess.Popen(cmd, shell=True, bufsize=-1,
+        p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=cwd,
                              close_fds=util.closefds,
                              stdout=subprocess.PIPE)
         if stream:


More information about the Mercurial-devel mailing list