obsdiscovery: add an option to disable all obsdiscovery
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 30 May 2017 17:32:39 +0200
changeset 2521 29fc90b0e59c
parent 2520 5fb5d096348c
child 2522 a1cc2a0b9f6f
obsdiscovery: add an option to disable all obsdiscovery On large repository, computing the obshashtree can we as slow as resending everything. We give the option for people to opt out.
README
hgext3rd/evolve/__init__.py
hgext3rd/evolve/obsdiscovery.py
tests/test-wireproto.t
--- a/README	Tue May 30 11:39:45 2017 +0200
+++ b/README	Tue May 30 17:32:39 2017 +0200
@@ -119,6 +119,8 @@
  - olog: add an '--all' option to show the whole obsolescence history tree.
  - evolution: add an experiment to track the effect of rewrites.
    (See hg help - evolve for details)
+ - obsdiscovery: add a config flag to disable all obsmarkers discovery
+   (See hg help - evolve for details)
  - template: add a 'precursors' template that display the closests precursors of changesets
  - template: add a 'successors' template that display the closests successors of changesets
  - template: add a 'obsfate' template that display how a changeset has evolved
--- a/hgext3rd/evolve/__init__.py	Tue May 30 11:39:45 2017 +0200
+++ b/hgext3rd/evolve/__init__.py	Tue May 30 17:32:39 2017 +0200
@@ -44,6 +44,12 @@
     # * abort: abort the push
     auto-publish = ignore
 
+    # For some large repository with few markers, the current  for obsolescence
+    # markers discovery can get in the way. You can disable it with the
+    # configuration option below. This means all pushes and pulls will
+    # re-exchange all markers every time.
+    evolution.obsdiscovery = yes
+
 Obsolescence Markers Discovery Experiment
 =========================================
 
--- a/hgext3rd/evolve/obsdiscovery.py	Tue May 30 11:39:45 2017 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Tue May 30 17:32:39 2017 +0200
@@ -872,6 +872,14 @@
     (_canobshashtree, _pushobshashtree),
 ]
 
+obsdiscovery_skip_message = """\
+(skipping discovery of obsolescence markers, will exchange everything)
+(controled by 'experimental.evolution.obsdiscovery' configuration)
+"""
+
+def usediscovery(repo):
+    return repo.ui.configbool('experimental', 'evolution.obsdiscovery', True)
+
 @eh.wrapfunction(exchange, '_pushdiscoveryobsmarkers')
 def _pushdiscoveryobsmarkers(orig, pushop):
     if _dopushmarkers(pushop):
@@ -881,6 +889,11 @@
         revs = list(repo.revs('::%ln', pushop.futureheads))
         unfi = repo.unfiltered()
 
+        if not usediscovery(repo):
+            # discovery disabled by user
+            repo.ui.status(obsdiscovery_skip_message)
+            return orig(pushop)
+
         # look for an obs-discovery protocol we can use
         discovery = None
         for candidate in obsdiscoveries:
@@ -929,6 +942,12 @@
         boundaries['common'] = [node.nullid]
         return boundaries
 
+    if not usediscovery(repo):
+        # discovery disabled by users.
+        repo.ui.status(obsdiscovery_skip_message)
+        boundaries['common'] = [node.nullid]
+        return boundaries
+
     if bundle2 and _canobshashrange(repo, remote):
         obsexcmsg(repo.ui, "looking for common markers in %i nodes\n"
                   % len(revs))
--- a/tests/test-wireproto.t	Tue May 30 11:39:45 2017 +0200
+++ b/tests/test-wireproto.t	Tue May 30 17:32:39 2017 +0200
@@ -149,4 +149,34 @@
   1 new obsolescence markers
   (run 'hg heads' to see heads)
 
+test discovery avoid exchanging known markers
+
+  $ hg push
+  pushing to ssh://user@dummy/server
+  searching for changes
+  no changes found
+  [1]
+  $ hg -R ../other pull
+  pulling from ssh://user@dummy/server
+  searching for changes
+  no changes found
+
+test discovery can be disabled
+
+  $ hg push --config experimental.evolution.obsdiscovery=no
+  pushing to ssh://user@dummy/server
+  searching for changes
+  (skipping discovery of obsolescence markers, will exchange everything)
+  (controled by 'experimental.evolution.obsdiscovery' configuration)
+  no changes found
+  remote: obsmarker-exchange: 346 bytes received
+  [1]
+  $ hg -R ../other pull --config experimental.evolution.obsdiscovery=no
+  pulling from ssh://user@dummy/server
+  searching for changes
+  no changes found
+  (skipping discovery of obsolescence markers, will exchange everything)
+  (controled by 'experimental.evolution.obsdiscovery' configuration)
+  obsmarker-exchange: 346 bytes received
+
   $ cd ..