changeset 2551:ecd47c63b6de stable

obshashrange: add an option to protect from accidental activation The new 'obshashrange.max-revs' option is meant to help large installation like bitbucket to avoid impact on repositories that cannot handle it.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 07 Jun 2017 00:48:12 +0100
parents d8a48234efad
children 85cabd631a1b 08bd8ab55cc9
files README hgext3rd/evolve/__init__.py hgext3rd/evolve/obsdiscovery.py hgext3rd/evolve/stablerange.py tests/test-discovery-obshashrange.t
diffstat 5 files changed, 23 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/README	Wed Jun 07 00:12:08 2017 +0100
+++ b/README	Wed Jun 07 00:48:12 2017 +0100
@@ -125,6 +125,7 @@
 -------------------
 
  - effect flag: fix a small bug related to hidden changeset,
+ - obshashrange: install a '.max-revs' option see extension help for details
 
 6.3.1 -- 2017-06-01
 -------------------
--- a/hgext3rd/evolve/__init__.py	Wed Jun 07 00:12:08 2017 +0100
+++ b/hgext3rd/evolve/__init__.py	Wed Jun 07 00:48:12 2017 +0100
@@ -90,6 +90,12 @@
     # restrict cache size to reduce memory consumption
     obshashrange.lru-size = 2000 # default is 2000
 
+    # automatically disable obshashrange related computation and capabilities
+    # if the repository has more than N revisions.  This is meant to help large
+    # server deployement to enable the feature on smaller repositories while
+    # ensuring no large repository will get affected.
+    obshashrange.max-revs = 100000 # default is None
+
 Effect Flag Experiment
 ======================
 
--- a/hgext3rd/evolve/obsdiscovery.py	Wed Jun 07 00:12:08 2017 +0100
+++ b/hgext3rd/evolve/obsdiscovery.py	Wed Jun 07 00:48:12 2017 +0100
@@ -586,8 +586,7 @@
                 repo = reporef()
                 if repo is None:
                     return
-                hasobshashrange = repo.ui.configbool('experimental',
-                                                     'obshashrange', False)
+                hasobshashrange = _useobshashrange(repo)
                 hascachewarm = repo.ui.configbool('experimental',
                                                   'obshashrange.warm-cache',
                                                   True)
@@ -665,15 +664,22 @@
     hashes = _obshashrange_v0(repo, ranges)
     return wireproto.encodelist(hashes)
 
+def _useobshashrange(repo):
+    base = repo.ui.configbool('experimental', 'obshashrange', False)
+    if base:
+        maxrevs = repo.ui.configint('experimental', 'obshashrange.max-revs', None)
+        if maxrevs is not None and maxrevs < len(repo.unfiltered()):
+            base = False
+    return base
 
 def _canobshashrange(local, remote):
-    return (local.ui.configbool('experimental', 'obshashrange', False)
+    return (_useobshashrange(local)
             and remote.capable('_evoext_obshashrange_v0'))
 
 def _obshashrange_capabilities(orig, repo, proto):
     """wrapper to advertise new capability"""
     caps = orig(repo, proto)
-    enabled = repo.ui.configbool('experimental', 'obshashrange', False)
+    enabled = _useobshashrange(repo)
     if obsolete.isenabled(repo, obsolete.exchangeopt) and enabled:
         caps = caps.split()
         caps.append('_evoext_obshashrange_v0')
--- a/hgext3rd/evolve/stablerange.py	Wed Jun 07 00:12:08 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Wed Jun 07 00:48:12 2017 +0100
@@ -948,6 +948,9 @@
             if not repo.ui.configbool('experimental', 'obshashrange.warm-cache',
                                       True):
                 return tr
+            maxrevs = self.ui.configint('experimental', 'obshashrange.max-revs', None)
+            if maxrevs is not None and maxrevs < len(self.unfiltered()):
+                return tr
             reporef = weakref.ref(self)
 
             def _warmcache(tr):
--- a/tests/test-discovery-obshashrange.t	Wed Jun 07 00:12:08 2017 +0100
+++ b/tests/test-discovery-obshashrange.t	Wed Jun 07 00:48:12 2017 +0100
@@ -74,7 +74,7 @@
   
 
   $ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa `getid 'desc(r1)'`
-  $ hg debugobsolete bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb `getid 'desc(r2)'`
+  $ hg debugobsolete bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb `getid 'desc(r2)'` --config experimental.obshashrange.max-revs=1
   $ hg debugobsolete cccccccccccccccccccccccccccccccccccccccc `getid 'desc(r4)'`
   $ hg debugobsolete dddddddddddddddddddddddddddddddddddddddd `getid 'desc(r5)'` --config experimental.obshashrange.warm-cache=0
   $ hg debugobsolete eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee `getid 'desc(r7)'`
@@ -97,14 +97,12 @@
   * @0000000000000000000000000000000000000000 (*)> debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 66f7d451a68b85ed82ff5fcc254daf50c74144bd exited 0 after *.?? seconds (glob)
   * @0000000000000000000000000000000000000000 (*)> debugobsolete bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 01241442b3c2bf3211e593b549c655ea65b295e3 (glob)
   * @0000000000000000000000000000000000000000 (*)> alias 'debugobsolete' expands to 'debugobsolete -d '0 0'' (glob)
-  * @0000000000000000000000000000000000000000 (*)> obshashcache reset - new markers affect cached ranges (glob)
-  * @0000000000000000000000000000000000000000 (*)> updated evo-ext-obshashrange in *.???? seconds (0r, 1o) (glob)
   * @0000000000000000000000000000000000000000 (*)> updated evo-ext-obscache in *.???? seconds (0r, 1o) (glob)
-  * @0000000000000000000000000000000000000000 (*)> debugobsolete bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 01241442b3c2bf3211e593b549c655ea65b295e3 exited 0 after *.?? seconds (glob)
+  * @0000000000000000000000000000000000000000 (*)> debugobsolete bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 01241442b3c2bf3211e593b549c655ea65b295e3 --config 'experimental.obshashrange.max-revs=1' exited 0 after *.?? seconds (glob)
   * @0000000000000000000000000000000000000000 (*)> debugobsolete cccccccccccccccccccccccccccccccccccccccc bebd167eb94d257ace0e814aeb98e6972ed2970d (glob)
   * @0000000000000000000000000000000000000000 (*)> alias 'debugobsolete' expands to 'debugobsolete -d '0 0'' (glob)
   * @0000000000000000000000000000000000000000 (*)> obshashcache reset - new markers affect cached ranges (glob)
-  * @0000000000000000000000000000000000000000 (*)> updated evo-ext-obshashrange in *.???? seconds (0r, 1o) (glob)
+  * @0000000000000000000000000000000000000000 (*)> updated evo-ext-obshashrange in *.???? seconds (0r, 2o) (glob)
   * @0000000000000000000000000000000000000000 (*)> updated evo-ext-obscache in *.???? seconds (0r, 1o) (glob)
   * @0000000000000000000000000000000000000000 (*)> debugobsolete cccccccccccccccccccccccccccccccccccccccc bebd167eb94d257ace0e814aeb98e6972ed2970d exited 0 after *.?? seconds (glob)
   * @0000000000000000000000000000000000000000 (*)> debugobsolete dddddddddddddddddddddddddddddddddddddddd c8d03c1b5e94af74b772900c58259d2e08917735 (glob)