# HG changeset patch # User Kostia Balytskyi # Date 2016-06-17 15:59:08 # Node ID 0b5e9a6250422f3458d7e81168f65904b7aaedc1 # Parent 1b699c7eb2b7341724e3efe289f376a954573e19 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 @@ -531,6 +531,9 @@ 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() @@ -538,7 +541,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()]: @@ -777,17 +782,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