Mercurial > evolve
changeset 1542:333e056b3034
inhibit: make rebase see obsolescence even for visible nodes
Rebase changed recently to take advantage of obsolescence markers to reduce
the number of conflicts to resolve. Inhibit users were unable to leverage this
new feature because none of their visible nodes could be obsolete. This patch
makes the nodes that would be obsolete without inhibit, actually obsolete for
the duration of the rebase to take advantage of the feature mentioned before.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Mon, 30 Nov 2015 16:48:40 -0800 |
parents | 23a34dce5131 |
children | 54394d2aaf5e |
files | hgext/inhibit.py tests/test-inhibit.t |
diffstat | 2 files changed, 36 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/inhibit.py Tue Nov 24 17:16:27 2015 -0800 +++ b/hgext/inhibit.py Mon Nov 30 16:48:40 2015 -0800 @@ -181,6 +181,16 @@ finally: lockmod.release(tr, lock) +def _computeobsoletenotrebasedwrap(orig, repo, rebasesetrevs, dest): + repo._notinhibited = rebasesetrevs + try: + repo.invalidatevolatilesets() + r = orig(repo, rebasesetrevs, dest) + finally: + del repo._notinhibited + repo.invalidatevolatilesets() + return r + def transactioncallback(orig, repo, desc, *args, **kwargs): """ Wrap localrepo.transaction to inhibit new obsolete changes """ def inhibitposttransaction(transaction): @@ -207,8 +217,10 @@ obs = obsfunc(repo) if _inhibitenabled(repo): getrev = repo.changelog.nodemap.get + blacklist = getattr(repo, '_notinhibited', set()) for n in repo._obsinhibit: - obs.discard(getrev(n)) + if getrev(n) not in blacklist: + obs.discard(getrev(n)) return obs try: extensions.find('directaccess') @@ -233,6 +245,14 @@ # wrap update to make sure that no obsolete commit is visible after an # update extensions.wrapcommand(commands.table, 'update', _update) + try: + rebase = extensions.find('rebase') + if rebase: + extensions.wrapfunction(rebase, + '_computeobsoletenotrebased', + _computeobsoletenotrebasedwrap) + except KeyError: + pass # Add bookmark -D option entry = extensions.wrapcommand(commands.table, 'bookmark', _bookmark) entry[1].append(('D','prune',None,
--- a/tests/test-inhibit.t Tue Nov 24 17:16:27 2015 -0800 +++ b/tests/test-inhibit.t Mon Nov 30 16:48:40 2015 -0800 @@ -751,6 +751,17 @@ nothing changed [1] +Check that the behavior of rebase with obsolescence markers is maintained +despite inhibit + + $ hg up a438c045eb37 + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg rebase -r 15:: -d 21 --config experimental.rebaseskipobsolete=True + note: not rebasing 15:2d66e189f5b5 "add cM", already in destination as 21:721c3c279519 "add cM" + rebasing 16:a438c045eb37 "add cN" + $ hg up 21 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + Directaccess should load after some extensions precised in the conf With no extension specified: @@ -765,7 +776,7 @@ > EOF $ hg id ['rebase', 'strip', 'evolve', 'directaccess', 'inhibit', 'testextension'] - 721c3c279519 tip + 721c3c279519 With test_extension specified: $ cat >> $HGRCPATH << EOF @@ -774,7 +785,7 @@ > EOF $ hg id ['rebase', 'strip', 'evolve', 'inhibit', 'testextension', 'directaccess'] - 721c3c279519 tip + 721c3c279519 Inhibit should not work without directaccess $ cat >> $HGRCPATH <<EOF @@ -797,6 +808,7 @@ $ pwd=$(pwd) $ cd inhibit $ mkcommit pk + created new head $ hg id 003a4735afde tip $ echo "OO" > pk @@ -818,7 +830,7 @@ adding changesets adding manifests adding file changes - added 1 changesets with 1 changes to 1 files + added 1 changesets with 1 changes to 1 files (+1 heads) 2 new obsolescence markers Pulling from a inhibit repo to a non-inhibit repo should work