Mercurial > public > mercurial-scm > hg
diff mercurial/subrepo.py @ 17027:6c05eebd9fab
merge with stable
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Thu, 21 Jun 2012 15:10:01 +0200 |
parents | 2e3513e7348a 8ad08dcab7d9 |
children | ab4644c3064f |
line wrap: on
line diff
--- a/mercurial/subrepo.py Tue Jun 19 19:45:00 2012 +0200 +++ b/mercurial/subrepo.py Thu Jun 21 15:10:01 2012 +0200 @@ -842,7 +842,6 @@ class gitsubrepo(abstractsubrepo): def __init__(self, ctx, path, state): - # TODO add git version check. self._state = state self._ctx = ctx self._path = path @@ -850,6 +849,29 @@ self._abspath = ctx._repo.wjoin(path) self._subparent = ctx._repo self._ui = ctx._repo.ui + self._ensuregit() + + def _ensuregit(self): + try: + self._gitexecutable = 'git' + out, err = self._gitnodir(['--version']) + except OSError, e: + if e.errno != 2 or os.name != 'nt': + raise + self._gitexecutable = 'git.cmd' + out, err = self._gitnodir(['--version']) + m = re.search(r'^git version (\d+)\.(\d+)\.(\d+)', out) + if not m: + self._ui.warn(_('cannot retrieve git version')) + return + version = (int(m.group(1)), m.group(2), m.group(3)) + # git 1.4.0 can't work at all, but 1.5.X can in at least some cases, + # despite the docstring comment. For now, error on 1.4.0, warn on + # 1.5.0 but attempt to continue. + if version < (1, 5, 0): + raise util.Abort(_('git subrepo requires at least 1.6.0 or later')) + elif version < (1, 6, 0): + self._ui.warn(_('git subrepo requires at least 1.6.0 or later')) def _gitcommand(self, commands, env=None, stream=False): return self._gitdir(commands, env=env, stream=stream)[0] @@ -870,8 +892,8 @@ errpipe = None if self._ui.quiet: errpipe = open(os.devnull, 'w') - p = subprocess.Popen(['git'] + commands, bufsize=-1, cwd=cwd, env=env, - close_fds=util.closefds, + p = subprocess.Popen([self._gitexecutable] + commands, bufsize=-1, + cwd=cwd, env=env, close_fds=util.closefds, stdout=subprocess.PIPE, stderr=errpipe) if stream: return p.stdout, None