[PATCH evolve-ext-V2] inhibit: make rebase see obsolescence even for visible nodes

Laurent Charignon lcharignon at fb.com
Mon Nov 30 18:52:33 CST 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1448930920 28800
#      Mon Nov 30 16:48:40 2015 -0800
# Node ID 780261cacea50d5afbc8ad400dc5f67258b85d1f
# Parent  48547b4c77defdd17c670b1eb0eb94272edf0207
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.

diff --git a/hgext/inhibit.py b/hgext/inhibit.py
--- a/hgext/inhibit.py
+++ b/hgext/inhibit.py
@@ -176,6 +176,16 @@ def _createmarkers(orig, repo, relations
     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):
@@ -202,8 +212,10 @@ def extsetup(ui):
         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')
@@ -232,6 +244,14 @@ def extsetup(ui):
     # wrap both to add inhibition markers.
     extensions.wrapfunction(bookmarks.bmstore, 'recordchange', _bookmarkchanged)
     extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged)
+    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,
diff --git a/tests/test-inhibit.t b/tests/test-inhibit.t
--- a/tests/test-inhibit.t
+++ b/tests/test-inhibit.t
@@ -700,6 +700,17 @@ Empty commit
   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:
 
@@ -714,7 +725,7 @@ With no extension specified:
   > EOF
   $ hg id
   ['rebase', 'strip', 'evolve', 'directaccess', 'inhibit', 'testextension']
-  721c3c279519 tip
+  721c3c279519
 
 With test_extension specified:
   $ cat >> $HGRCPATH << EOF
@@ -723,7 +734,7 @@ With test_extension specified:
   > EOF
   $ hg id
   ['rebase', 'strip', 'evolve', 'inhibit', 'testextension', 'directaccess']
-  721c3c279519 tip
+  721c3c279519
 
 Inhibit should not work without directaccess
   $ cat >> $HGRCPATH <<EOF
@@ -746,6 +757,7 @@ We copy the inhibhit repo to inhibit2 an
   $ pwd=$(pwd)
   $ cd inhibit
   $ mkcommit pk
+  created new head
   $ hg id
   003a4735afde tip
   $ echo "OO" > pk
@@ -767,7 +779,7 @@ Visible commits can still be pushed
   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


More information about the Mercurial-devel mailing list