[PATCH 7 of 7 v6] rebase: do not abort if all changesets have equivalents in the destination
Kostia Balytskyi
ikostia at fb.com
Mon Jun 13 18:03:52 EDT 2016
# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1465854863 -3600
# Mon Jun 13 22:54:23 2016 +0100
# Node ID 1852013ed3ae1ed5b7cc61a1959a61f651422d44
# Parent 0387ce5764968036c615b38f575e45fc9c0ae71d
rebase: do not abort if all changesets have equivalents in the destination
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -534,6 +534,10 @@ def rebase(ui, repo, **opts):
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()
@@ -541,7 +545,9 @@ def rebase(ui, repo, **opts):
# 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()]:
@@ -780,17 +786,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
More information about the Mercurial-devel
mailing list