[PATCH 2 of 8 v2] rebase: better error message when rebased changes are all in destination

Eric Sumner ericsumner at fb.com
Fri Jan 1 12:36:42 CST 2016


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1451431932 28800
#      Tue Dec 29 15:32:12 2015 -0800
# Node ID f9e755736b0eead8d8ab79d5c983feb82579fd92
# Parent  6cd3044985c2809c1eddd80827df2ba9ccfd91fd
rebase: better error message when rebased changes are all in destination

Before this patch, when rebasing a set of obsolete revisions that were plain
pruned or already present in the destination, we were displaying:

abort: no matching revisions

This was not very helpful to understand what was going on, instead we replace
the error message by:

abort: all requested changesets have equivalents or were marked as obsolete
(to force the rebase, set the config experimental.rebaseskipobsolete to False)

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -348,6 +348,13 @@
                 # - split changesets are not rebased if at least one of the
                 # changeset resulting from the split is an ancestor of dest
                 rebaseset = rebasesetrevs - set(obsoletenotrebased)
+                if rebasesetrevs and not rebaseset:
+                    msg = _('all requested changesets have equivalents '
+                            'or were marked as obsolete')
+                    hint = _('to force the rebase, set the config '
+                             'experimental.rebaseskipobsolete to False')
+                    raise error.Abort(msg, hint=hint)
+
             result = buildstate(repo, dest, rebaseset, collapsef,
                                 obsoletenotrebased)
 
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
@@ -685,3 +685,30 @@
   rebasing 4:ff2c4d47b71d "C"
   note: not rebasing 7:360bbaa7d3ce "O", it has no successor
   rebasing 8:8d47583e023f "P" (tip)
+
+If all the changeset to be rebased are obsolete and present in the destination, we
+should display a friendly error message
+
+  $ hg log -G
+  @  10:121d9e3bc4c6 P
+  |
+  o  9:4be60e099a77 C
+  |
+  o  6:9c48361117de D
+  |
+  o  2:261e70097290 B2
+  |
+  o  0:4a2df7238c3b A
+  
+
+  $ hg up 9
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo "non-relevant change" > nonrelevant
+  $ hg add nonrelevant
+  $ hg commit -m nonrelevant
+  created new head
+  $ hg debugobsolete `hg log -r 11 -T '{node}\n'` --config experimental.evolution=all
+  $ hg rebase -r . -d 10
+  abort: all requested changesets have equivalents or were marked as obsolete
+  (to force the rebase, set the config experimental.rebaseskipobsolete to False)
+  [255]


More information about the Mercurial-devel mailing list