inhibit: config to enable only direct access
authorLaurent Charignon <lcharignon@fb.com>
Thu, 30 Apr 2015 17:37:11 -0700
changeset 1332 1ed337c7f061
parent 1331 5e82d78f5872
child 1333 dffdd0dbe780
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.
hgext/inhibit.py
tests/test-inhibit.t
--- a/hgext/inhibit.py	Mon May 11 14:31:17 2015 -0700
+++ b/hgext/inhibit.py	Thu Apr 30 17:37:11 2015 -0700
@@ -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')))
 
 
 
--- a/tests/test-inhibit.t	Mon May 11 14:31:17 2015 -0700
+++ b/tests/test-inhibit.t	Thu Apr 30 17:37:11 2015 -0700
@@ -533,3 +533,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
+