[PATCH v2] rebase: add potential divergent commit hashes to error message (issue5086)

Kostia Balytskyi ikostia at fb.com
Wed Feb 17 20:32:22 UTC 2016


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1455741094 0
#      Wed Feb 17 20:31:34 2016 +0000
# Node ID c91240e672a88d78abdcd571cfdcf2cba36504e6
# Parent  95bf01b8754016200a99fd3538e78030b2028c60
rebase: add potential divergent commit hashes to error message (issue5086)

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -305,10 +305,13 @@
                 divergencebasecandidates = rebaseobsrevs - rebaseobsskipped
 
                 if divergencebasecandidates and not divergenceok:
-                    msg = _("this rebase will cause divergence")
+                    divhashes = (repo.unfiltered()[r].hex()
+                                 for r in divergencebasecandidates)
+                    msg = _("this rebase will cause "
+                            "divergences with base(s): %s")
                     h = _("to force the rebase please set "
                           "rebase.allowdivergence=True")
-                    raise error.Abort(msg, hint=h)
+                    raise error.Abort(msg % (",".join(divhashes),), hint=h)
 
                 # - plain prune (no successor) changesets are rebased
                 # - split changesets are not rebased if at least one of the
diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -771,7 +771,7 @@
   phases: 8 draft
   unstable: 1 changesets
   $ hg rebase -s 10 -d 12
-  abort: this rebase will cause divergence
+  abort: this rebase will cause divergences with base(s): 121d9e3bc4c60bd1c9c007e7de31d6796b882a45
   (to force the rebase please set rebase.allowdivergence=True)
   [255]
   $ hg log -G


More information about the Mercurial-devel mailing list