comparison mercurial/subrepo.py @ 13110:cad35f06c031

subrepo: show git command with --debug Also removing the clutter of --no-pager, since none of these commands use the pager.
author Eric Eisner <ede@mit.edu>
date Thu, 09 Dec 2010 16:52:14 -0500
parents 53341289eaf8
children 560b8001f765
comparison
equal deleted inserted replaced
13109:53341289eaf8 13110:cad35f06c031
612 612
613 def _gitcommand(self, commands, env=None, stream=False): 613 def _gitcommand(self, commands, env=None, stream=False):
614 return self._gitdir(commands, env=env, stream=stream)[0] 614 return self._gitdir(commands, env=env, stream=stream)[0]
615 615
616 def _gitdir(self, commands, env=None, stream=False): 616 def _gitdir(self, commands, env=None, stream=False):
617 commands = ['--no-pager'] + commands
618 return self._gitnodir(commands, env=env, stream=stream, cwd=self._path) 617 return self._gitnodir(commands, env=env, stream=stream, cwd=self._path)
619 618
620 def _gitnodir(self, commands, env=None, stream=False, cwd=None): 619 def _gitnodir(self, commands, env=None, stream=False, cwd=None):
621 """Calls the git command 620 """Calls the git command
622 621
623 The methods tries to call the git command. versions previor to 1.6.0 622 The methods tries to call the git command. versions previor to 1.6.0
624 are not supported and very probably fail. 623 are not supported and very probably fail.
625 """ 624 """
625 self._ui.debug('%s: git %s\n' % (self._relpath, ' '.join(commands)))
626 # print git's stderr, which is mostly progress and useful info 626 # print git's stderr, which is mostly progress and useful info
627 p = subprocess.Popen(['git'] + commands, bufsize=-1, cwd=cwd, env=env, 627 p = subprocess.Popen(['git'] + commands, bufsize=-1, cwd=cwd, env=env,
628 close_fds=util.closefds, 628 close_fds=util.closefds,
629 stdout=subprocess.PIPE) 629 stdout=subprocess.PIPE)
630 if stream: 630 if stream:
634 # wait for the child to exit to avoid race condition. 634 # wait for the child to exit to avoid race condition.
635 p.wait() 635 p.wait()
636 636
637 if p.returncode != 0 and p.returncode != 1: 637 if p.returncode != 0 and p.returncode != 1:
638 # there are certain error codes that are ok 638 # there are certain error codes that are ok
639 command = None 639 command = commands[0]
640 for arg in commands:
641 if not arg.startswith('-'):
642 command = arg
643 break
644 if command == 'cat-file': 640 if command == 'cat-file':
645 return retdata, p.returncode 641 return retdata, p.returncode
646 # for all others, abort 642 # for all others, abort
647 raise util.Abort('git %s error %d' % (command, p.returncode)) 643 raise util.Abort('git %s error %d in %s' %
644 (command, p.returncode, self._relpath))
648 645
649 return retdata, p.returncode 646 return retdata, p.returncode
650 647
651 def _gitstate(self): 648 def _gitstate(self):
652 return self._gitcommand(['rev-parse', 'HEAD']) 649 return self._gitcommand(['rev-parse', 'HEAD'])