mercurial/subrepo.py
branchstable
changeset 17025 8ad08dcab7d9
parent 17024 33b057778cd2
child 17027 6c05eebd9fab
child 17035 ba0286e149aa
equal deleted inserted replaced
17024:33b057778cd2 17025:8ad08dcab7d9
   848         self._subparent = ctx._repo
   848         self._subparent = ctx._repo
   849         self._ui = ctx._repo.ui
   849         self._ui = ctx._repo.ui
   850         self._ensuregit()
   850         self._ensuregit()
   851 
   851 
   852     def _ensuregit(self):
   852     def _ensuregit(self):
   853         out, err = self._gitnodir(['--version'])
   853         try:
       
   854             self._gitexecutable = 'git'
       
   855             out, err = self._gitnodir(['--version'])
       
   856         except OSError, e:
       
   857             if e.errno != 2 or os.name != 'nt':
       
   858                 raise
       
   859             self._gitexecutable = 'git.cmd'
       
   860             out, err = self._gitnodir(['--version'])
   854         m = re.search(r'^git version (\d+)\.(\d+)\.(\d+)', out)
   861         m = re.search(r'^git version (\d+)\.(\d+)\.(\d+)', out)
   855         if not m:
   862         if not m:
   856             self._ui.warn(_('cannot retrieve git version'))
   863             self._ui.warn(_('cannot retrieve git version'))
   857             return
   864             return
   858         version = (int(m.group(1)), m.group(2), m.group(3))
   865         version = (int(m.group(1)), m.group(2), m.group(3))
   881         # unless ui.quiet is set, print git's stderr,
   888         # unless ui.quiet is set, print git's stderr,
   882         # which is mostly progress and useful info
   889         # which is mostly progress and useful info
   883         errpipe = None
   890         errpipe = None
   884         if self._ui.quiet:
   891         if self._ui.quiet:
   885             errpipe = open(os.devnull, 'w')
   892             errpipe = open(os.devnull, 'w')
   886         p = subprocess.Popen(['git'] + commands, bufsize=-1, cwd=cwd, env=env,
   893         p = subprocess.Popen([self._gitexecutable] + commands, bufsize=-1,
   887                              close_fds=util.closefds,
   894                              cwd=cwd, env=env, close_fds=util.closefds,
   888                              stdout=subprocess.PIPE, stderr=errpipe)
   895                              stdout=subprocess.PIPE, stderr=errpipe)
   889         if stream:
   896         if stream:
   890             return p.stdout, None
   897             return p.stdout, None
   891 
   898 
   892         retdata = p.stdout.read().strip()
   899         retdata = p.stdout.read().strip()