comparison mercurial/subrepo.py @ 13093:d0cbddfe3f4c

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.
author Eric Eisner <ede@mit.edu>
date Mon, 06 Dec 2010 21:17:27 -0500
parents cca0779b4832
children a1dd7bd26a2b
comparison
equal deleted inserted replaced
13092:83986af605e5 13093:d0cbddfe3f4c
615 615
616 def _gitcommand(self, commands, stream=False): 616 def _gitcommand(self, commands, stream=False):
617 return self._gitdir(commands, stream=stream)[0] 617 return self._gitdir(commands, stream=stream)[0]
618 618
619 def _gitdir(self, commands, stream=False): 619 def _gitdir(self, commands, stream=False):
620 commands = ['--no-pager', '--git-dir=%s/.git' % self._path, 620 commands = ['--no-pager'] + commands
621 '--work-tree=%s' % self._path] + commands 621 return self._gitnodir(commands, stream=stream, cwd=self._path)
622 return self._gitnodir(commands, stream=stream) 622
623 623 def _gitnodir(self, commands, stream=False, cwd=None):
624 def _gitnodir(self, commands, stream=False):
625 """Calls the git command 624 """Calls the git command
626 625
627 The methods tries to call the git command. versions previor to 1.6.0 626 The methods tries to call the git command. versions previor to 1.6.0
628 are not supported and very probably fail. 627 are not supported and very probably fail.
629 """ 628 """
630 cmd = ['git'] + commands 629 cmd = ['git'] + commands
631 cmd = [util.shellquote(arg) for arg in cmd] 630 cmd = [util.shellquote(arg) for arg in cmd]
632 cmd = util.quotecommand(' '.join(cmd)) 631 cmd = util.quotecommand(' '.join(cmd))
633 632
634 # print git's stderr, which is mostly progress and useful info 633 # print git's stderr, which is mostly progress and useful info
635 p = subprocess.Popen(cmd, shell=True, bufsize=-1, 634 p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=cwd,
636 close_fds=util.closefds, 635 close_fds=util.closefds,
637 stdout=subprocess.PIPE) 636 stdout=subprocess.PIPE)
638 if stream: 637 if stream:
639 return p.stdout, None 638 return p.stdout, None
640 639