changeset 29372:0b5e9a625042

rebase: do not abort if all changesets have equivalents in the destination
author Kostia Balytskyi <ikostia@fb.com>
date Fri, 17 Jun 2016 16:59:08 +0100
parents 1b699c7eb2b7
children 36fbd72c2f39
files hgext/rebase.py tests/test-rebase-obsolete.t
diffstat 2 files changed, 42 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Thu Jun 16 15:15:33 2016 -0700
+++ b/hgext/rebase.py	Fri Jun 17 16:59:08 2016 +0100
@@ -531,6 +531,9 @@
             for k, v in rbsrt.state.iteritems():
                 if v > nullmerge:
                     nstate[repo[k].node()] = repo[v].node()
+                elif v == revprecursor:
+                    succ = obsoletenotrebased[k]
+                    nstate[repo[k].node()] = repo[succ].node()
             # XXX this is the same as dest.node() for the non-continue path --
             # this should probably be cleaned up
             targetnode = repo[rbsrt.target].node()
@@ -538,7 +541,9 @@
         # restore original working directory
         # (we do this before stripping)
         newwd = rbsrt.state.get(rbsrt.originalwd, rbsrt.originalwd)
-        if newwd < 0:
+        if newwd == revprecursor:
+            newwd = obsoletenotrebased[rbsrt.originalwd]
+        elif newwd < 0:
             # original directory is a parent of rebase set root or ignored
             newwd = rbsrt.originalwd
         if newwd not in [c.rev() for c in repo[None].parents()]:
@@ -777,17 +782,6 @@
               "experimental.allowdivergence=True")
         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
-    # changeset resulting from the split is an ancestor of dest
-    rebaseset = rebasesetrevs - rebaseobsskipped
-    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)
-
 def defineparents(repo, rev, target, state, targetancestors,
                   obsoletenotrebased):
     'Return the new parent relationship of the revision that will be rebased'
--- a/tests/test-rebase-obsolete.t	Thu Jun 16 15:15:33 2016 -0700
+++ b/tests/test-rebase-obsolete.t	Fri Jun 17 16:59:08 2016 +0100
@@ -709,9 +709,7 @@
   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]
+  note: not rebasing 11:f44da1f4954c "nonrelevant" (tip), it has no successor
 
 If a rebase is going to create divergence, it should abort
 
@@ -916,3 +914,38 @@
   o  0:cd010b8cd998 A
   
   $ cd ..
+
+Test that bookmark is moved and working dir is updated when all changesets have
+equivalents in destination
+  $ hg init rbsrepo && cd rbsrepo
+  $ echo "[experimental]" > .hg/hgrc
+  $ echo "evolution=all" >> .hg/hgrc
+  $ echo "rebaseskipobsolete=on" >> .hg/hgrc
+  $ echo root > root && hg ci -Am root
+  adding root
+  $ echo a > a && hg ci -Am a
+  adding a
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo b > b && hg ci -Am b
+  adding b
+  created new head
+  $ hg rebase -r 2 -d 1
+  rebasing 2:1e9a3c00cbe9 "b" (tip)
+  $ hg log -r .  # working dir is at rev 3 (successor of 2)
+  3:be1832deae9a b (no-eol)
+  $ hg book -r 2 mybook --hidden  # rev 2 has a bookmark on it now
+  $ hg up 2 && hg log -r .  # working dir is at rev 2 again
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  2:1e9a3c00cbe9 b (no-eol)
+  $ hg rebase -r 2 -d 3
+  note: not rebasing 2:1e9a3c00cbe9 "b" (mybook), already in destination as 3:be1832deae9a "b"
+Check that working directory was updated to rev 3 although rev 2 was skipped
+during the rebase operation
+  $ hg log -r .
+  3:be1832deae9a b (no-eol)
+
+Check that bookmark was moved to rev 3 although rev 2 was skipped
+during the rebase operation
+  $ hg bookmarks
+     mybook                    3:be1832deae9a