Patchwork [7,of,7,v4] rebase: do not abort of all changesets have equivalents in destination

login
register
mail settings
Submitter Kostia Balytskyi
Date June 5, 2016, 5:46 p.m.
Message ID <5bf6423640bce2f80f4e.1465148781@ikostia-mbp>
Download mbox | patch
Permalink /patch/15417/
State Superseded
Headers show

Comments

Kostia Balytskyi - June 5, 2016, 5:46 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1465144090 -3600
#      Sun Jun 05 17:28:10 2016 +0100
# Node ID 5bf6423640bce2f80f4e7f1d3c4ba9ba2d37078f
# Parent  d35690b8021ac8be0b3e33c9a7865cb36b4b49f8
rebase: do not abort of all changesets have equivalents in destination
Sean Farley - June 7, 2016, 6:35 p.m.
Kostia Balytskyi <ikostia@fb.com> writes:

> # HG changeset patch
> # User Kostia Balytskyi <ikostia@fb.com>
> # Date 1465144090 -3600
> #      Sun Jun 05 17:28:10 2016 +0100
> # Node ID 5bf6423640bce2f80f4e7f1d3c4ba9ba2d37078f
> # Parent  d35690b8021ac8be0b3e33c9a7865cb36b4b49f8
> rebase: do not abort of all changesets have equivalents in destination

I've finally gotten a chance to read your serious (and your previous one
of ~20 patches). I think moving things to a class is a good step (I
don't know why python devs tend to not do this).

Hopefully, this will allow us to start abstracting away the logic for
histedit, rebase, etc. to get the "involved" obsolete revs (so we don't
have to blindly use repo.unfiltered()).

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -535,6 +535,10 @@  def rebase(ui, repo, **opts):
             for k, v in rtstate.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[rtstate.target].node()
@@ -542,7 +546,9 @@  def rebase(ui, repo, **opts):
         # restore original working directory
         # (we do this before stripping)
         newwd = rtstate.state.get(rtstate.originalwd, rtstate.originalwd)
-        if newwd < 0:
+        if newwd == revprecursor:
+            newwd = obsoletenotrebased[rtstate.originalwd]
+        elif newwd < 0:
             # original directory is a parent of rebase set root or ignored
             newwd = rtstate.originalwd
         if newwd not in [c.rev() for c in repo[None].parents()]:
@@ -781,17 +787,6 @@  def _checkobsrebase(repo, ui,
               "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'
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
@@ -709,9 +709,7 @@  should display a friendly error message
   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 @@  rebase source is obsoleted (issue5198)
   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