subrepo: use subprocess's cwd instead of git's --work-tree
authorEric Eisner <ede@mit.edu>
Mon, 06 Dec 2010 21:17:27 -0500
changeset 13093 d0cbddfe3f4c
parent 13092 83986af605e5
child 13094 a1dd7bd26a2b
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.
mercurial/subrepo.py
--- a/mercurial/subrepo.py	Mon Dec 06 21:17:27 2010 -0500
+++ b/mercurial/subrepo.py	Mon Dec 06 21:17:27 2010 -0500
@@ -617,11 +617,10 @@
         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 @@
         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: