changeset 17027:6c05eebd9fab

merge with stable
author Martin Geisler <mg@aragost.com>
date Thu, 21 Jun 2012 15:10:01 +0200
parents 3e2d8120528b (current diff) f8af57c00a29 (diff)
children efd2e14f7235
files hgext/rebase.py mercurial/subrepo.py
diffstat 3 files changed, 32 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Jun 19 19:45:00 2012 +0200
+++ b/hgext/rebase.py	Thu Jun 21 15:10:01 2012 +0200
@@ -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:
--- 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
--- a/tests/test-rebase-interruptions.t	Tue Jun 19 19:45:00 2012 +0200
+++ b/tests/test-rebase-interruptions.t	Thu Jun 21 15:10:01 2012 +0200
@@ -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