diff --git a/hgext/rebase.py b/hgext/rebase.py index 3e2d8120528b75389cda669f47a78c53be917839_aGdleHQvcmViYXNlLnB5..6c05eebd9fab06e66eab57879e5562088e88f0be_aGdleHQvcmViYXNlLnB5 100644 --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -568,10 +568,11 @@ def abort(repo, originalwd, target, state): 'Restore the repository to its original state' dstates = [s for s in state.values() if s != nullrev] - if [d for d in dstates if not repo[d].mutable()]: - repo.ui.warn(_("warning: immutable rebased changeset detected, " - "can't abort\n")) - return -1 + immutable = [d for d in dstates if not repo[d].mutable()] + if immutable: + raise util.Abort(_("can't abort rebase due to immutable changesets %s") + % ', '.join(str(repo[r]) for r in immutable), + hint=_('see hg help phases for details')) descendants = set() if dstates: diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py index 3e2d8120528b75389cda669f47a78c53be917839_bWVyY3VyaWFsL3N1YnJlcG8ucHk=..6c05eebd9fab06e66eab57879e5562088e88f0be_bWVyY3VyaWFsL3N1YnJlcG8ucHk= 100644 --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -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 diff --git a/tests/test-rebase-interruptions.t b/tests/test-rebase-interruptions.t index 3e2d8120528b75389cda669f47a78c53be917839_dGVzdHMvdGVzdC1yZWJhc2UtaW50ZXJydXB0aW9ucy50..6c05eebd9fab06e66eab57879e5562088e88f0be_dGVzdHMvdGVzdC1yZWJhc2UtaW50ZXJydXB0aW9ucy50 100644 --- a/tests/test-rebase-interruptions.t +++ b/tests/test-rebase-interruptions.t @@ -248,7 +248,8 @@ Abort the rebasing: $ hg rebase --abort - warning: immutable rebased changeset detected, can't abort + abort: can't abort rebase due to immutable changesets 45396c49d53b + (see hg help phases for details) [255] $ hg tglogp