[PATCH evolve-ext] inhibit: config to enable only direct access

Laurent Charignon lcharignon at fb.com
Mon May 11 23:17:30 UTC 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1430440631 25200
#      Thu Apr 30 17:37:11 2015 -0700
# Node ID f4d5d25a8f4c31349c6b17fabdf0b4bcae05cbc1
# Parent  5e82d78f5872c9503d7b6691c594a13794a9b4a4
inhibit: config to enable only direct access

Inhibit provides several features to hide instability and direct access.
We want to use direct access in evolve without hiding the instability.
This patch adds a config flag to enable only direct access in inhibit, when
this config flag is not set or set to false we enable all the features of
inhibit that don't concern direct access.

diff --git a/hgext/inhibit.py b/hgext/inhibit.py
--- a/hgext/inhibit.py
+++ b/hgext/inhibit.py
@@ -55,12 +55,12 @@
             _inhibitmarkers(repo, [newnode])
             return newnode
 
-    # Wrapping this to inhibit obsolete revs resulting from a transaction
-    extensions.wrapfunction(localrepo.localrepository,
-                            'transaction', transactioncallback)
-
     repo.__class__ = obsinhibitedrepo
     repo._explicitaccess = set()
+    if not ui.configbool('inhibit', 'onlydirectaccess', False):
+        # Wrapping this to inhibit obsolete revs resulting from a transaction
+        extensions.wrapfunction(localrepo.localrepository,
+                                'transaction', transactioncallback)
 
 
 def _update(orig, ui, repo, *args, **kwargs):
@@ -206,25 +206,26 @@
             obs.discard(getrev(n))
         return obs
     obsolete.cachefuncs['obsolete'] = _computeobsoleteset
-    # drop divergence computation since it is incompatible with "light revive"
-    obsolete.cachefuncs['divergent'] = lambda repo: set()
-    # drop bumped computation since it is incompatible with "light revive"
-    obsolete.cachefuncs['bumped'] = lambda repo: set()
     # wrap create marker to make it able to lift the inhibition
     extensions.wrapfunction(obsolete, 'createmarkers', _createmarkers)
     extensions.wrapfunction(repoview, '_getdynamicblockers', _accessvisible)
     extensions.wrapfunction(revset, 'posttreebuilthook', _posttreebuilthook)
-    # wrap update to make sure that no obsolete commit is visible after an
-    # update
-    extensions.wrapcommand(commands.table, 'update', _update)
-    # There are two ways to save bookmark changes during a transation, we
-    # wrap both to add inhibition markers.
-    extensions.wrapfunction(bookmarks.bmstore, 'recordchange', _bookmarkchanged)
-    extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged)
-    # Add bookmark -D option
-    entry = extensions.wrapcommand(commands.table, 'bookmark', _bookmark)
-    entry[1].append(('D','prune',None,
-                    _('delete the bookmark and prune the commits underneath')))
+    if not ui.configbool('inhibit', 'onlydirectaccess', False):
+        # drop divergence computation since it is incompatible with "light revive"
+        obsolete.cachefuncs['divergent'] = lambda repo: set()
+        # drop bumped computation since it is incompatible with "light revive"
+        obsolete.cachefuncs['bumped'] = lambda repo: set()
+        # wrap update to make sure that no obsolete commit is visible after an
+        # update
+        extensions.wrapcommand(commands.table, 'update', _update)
+        # There are two ways to save bookmark changes during a transation, we
+        # wrap both to add inhibition markers.
+        extensions.wrapfunction(bookmarks.bmstore, 'recordchange', _bookmarkchanged)
+        extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged)
+        # Add bookmark -D option
+        entry = extensions.wrapcommand(commands.table, 'bookmark', _bookmark)
+        entry[1].append(('D','prune',None,
+                        _('delete the bookmark and prune the commits underneath')))
 
 
 
diff --git a/tests/test-inhibit.t b/tests/test-inhibit.t
--- a/tests/test-inhibit.t
+++ b/tests/test-inhibit.t
@@ -489,7 +489,6 @@
   o  0:54ccbc537fc2 add cA
   
 Check that rebasing a commit twice makes the commit visible again
-
   $ hg rebase -d 18 -r 16 --keep
   rebasing 16:a438c045eb37 "add cN"
   $ hg log -r 14:: -G
@@ -533,3 +532,36 @@
   |
   @  14:d66ccb8c5871 add cL foo
   |
+
+Only allow direct access and check that evolve works like before
+  $ cat >> $HGRCPATH <<EOF
+  > [inhibit]
+  > onlydirectaccess = True
+  > EOF
+
+  $ hg up 15
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo "CM" > cM
+  $ hg amend
+  1 new unstable changesets
+  $ hg log -G
+  @  21:721c3c279519 add cM
+  |
+  | o  16:a438c045eb37 add cN
+  | |
+  | x  15:2d66e189f5b5 add cM
+  |/
+  o  14:d66ccb8c5871 add cL
+  |
+  | o  9:55c73a90e4b4 add cJ
+  | |
+  o |  7:18214586bf78 add cJ
+  |/
+  o  6:cf5c4f4554ce add cH
+  |
+  o  5:5419eb264a33 add cG
+  |
+  o  4:98065434e5c6 add cE
+  |
+  o  0:54ccbc537fc2 add cA
+  


More information about the Mercurial-devel mailing list