changeset 3187:68aeeb4d4b8f mercurial-4.3

test-compat: merge stable into mercurial-4.3
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 14 Nov 2017 23:15:18 +0100
parents 9d9ff55d1bb1 (diff) 1b58e0121689 (current diff)
children 4cc1057970a2 c0ee9ddfd5ff
files tests/test-topic-flow-publish-flag.t tests/test-wireproto.t
diffstat 4 files changed, 84 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py	Tue Nov 07 13:05:37 2017 +0100
+++ b/hgext3rd/evolve/__init__.py	Tue Nov 14 23:15:18 2017 +0100
@@ -416,10 +416,10 @@
 def _configureoptions(ui, repo):
     # If no capabilities are specified, enable everything.
     # This is so existing evolve users don't need to change their config.
-    evolveopts = ui.configlist('experimental', 'evolution')
+    evolveopts = repo.ui.configlist('experimental', 'evolution')
     if not evolveopts:
         evolveopts = ['all']
-        ui.setconfig('experimental', 'evolution', evolveopts, 'evolve')
+        repo.ui.setconfig('experimental', 'evolution', evolveopts, 'evolve')
     if obsolete.isenabled(repo, 'exchange'):
         repo.ui.setconfig('server', 'bundle1', False)
 
--- a/hgext3rd/evolve/serveronly.py	Tue Nov 07 13:05:37 2017 +0100
+++ b/hgext3rd/evolve/serveronly.py	Tue Nov 14 23:15:18 2017 +0100
@@ -53,9 +53,9 @@
 
 @eh.reposetup
 def default2evolution(ui, repo):
-    evolveopts = ui.configlist('experimental', 'evolution')
+    evolveopts = repo.ui.configlist('experimental', 'evolution')
     if not evolveopts:
         evolveopts = 'all'
-        ui.setconfig('experimental', 'evolution', evolveopts)
+        repo.ui.setconfig('experimental', 'evolution', evolveopts)
     if obsolete.isenabled(repo, 'exchange'):
         repo.ui.setconfig('server', 'bundle1', False)
--- a/hgext3rd/topic/discovery.py	Tue Nov 07 13:05:37 2017 +0100
+++ b/hgext3rd/topic/discovery.py	Tue Nov 14 23:15:18 2017 +0100
@@ -1,5 +1,6 @@
 from __future__ import absolute_import
 
+import collections
 import weakref
 
 from mercurial.i18n import _
@@ -15,6 +16,7 @@
 
 def _headssummary(orig, *args):
     # In mercurial < 4.2, we receive repo, remote and outgoing as arguments
+    pushop = None
     if len(args) == 3:
         pushoparg = False
         repo, remote, outgoing = args
@@ -31,17 +33,51 @@
 
     publishing = ('phases' not in remote.listkeys('namespaces')
                   or bool(remote.listkeys('phases').get('publishing', False)))
-    if publishing or not remote.capable('topics'):
+    if ((publishing or not remote.capable('topics'))
+            and not getattr(pushop, 'publish', False)):
         return orig(*args)
 
+    publishedset = ()
+    remotebranchmap = None
+    origremotebranchmap = remote.branchmap
+    # < hg-4.4 do not have a --publish flag anyway
+    if pushoparg and util.safehasattr(pushop, 'remotephases'):
+        publishednode = [c.node() for c in pushop.outdatedphases]
+        publishedset = repo.revs('ancestors(%ln + %ln)',
+                                 publishednode,
+                                 pushop.remotephases.publicheads)
+
+        rev = repo.unfiltered().changelog.nodemap.get
+
+        def remotebranchmap():
+            # drop topic information from changeset about to be published
+            result = collections.defaultdict(list)
+            for branch, heads in origremotebranchmap().iteritems():
+                if ':' not in branch:
+                    result[branch].extend(heads)
+                else:
+                    namedbranch = branch.split(':', 1)[0]
+                    for h in heads:
+                        r = rev(h)
+                        if r is not None and r in publishedset:
+                            result[namedbranch].append(h)
+                        else:
+                            result[branch].append(h)
+            for heads in result.itervalues():
+                heads.sort()
+            return result
+
     class repocls(repo.__class__):
         # awful hack to see branch as "branch:topic"
         def __getitem__(self, key):
             ctx = super(repocls, self).__getitem__(key)
             oldbranch = ctx.branch
+            rev = ctx.rev()
 
             def branch():
                 branch = oldbranch()
+                if rev in publishedset:
+                    return branch
                 topic = ctx.topic()
                 if topic:
                     branch = "%s:%s" % (branch, topic)
@@ -56,6 +92,8 @@
 
             def branchinfo(rev):
                 branch, close = changelog.branchinfo(rev)
+                if rev in publishedset:
+                    return branch, close
                 topic = repo[rev].topic()
                 if topic:
                     branch = "%s:%s" % (branch, topic)
@@ -67,6 +105,8 @@
     oldrepocls = repo.__class__
     try:
         repo.__class__ = repocls
+        if remotebranchmap is not None:
+            remote.branchmap = remotebranchmap
         unxx = repo.filtered('unfiltered-topic')
         repo.unfiltered = lambda: unxx
         if pushoparg:
@@ -83,6 +123,8 @@
         if 'unfiltered' in vars(repo):
             del repo.unfiltered
         repo.__class__ = oldrepocls
+        if remotebranchmap is not None:
+            remote.branchmap = origremotebranchmap
 
 def wireprotobranchmap(orig, repo, proto):
     oldrepo = repo.__class__
--- a/tests/test-wireproto.t	Tue Nov 07 13:05:37 2017 +0100
+++ b/tests/test-wireproto.t	Tue Nov 14 23:15:18 2017 +0100
@@ -204,8 +204,45 @@
   abort: unexpected response: empty string
   [255]
 
+(do some extra pulling to be sure)
+
+  $ hg -R client pull http://localhost:$HGPORT/
+  pulling from http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  obsmarker-exchange: 376 bytes received
+
+  $ hg -R client pull http://localhost:$HGPORT/ --config experimental.evolution=createmarkers
+  pulling from http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+
+  $ hg -R client pull http://localhost:$HGPORT/ --config experimental.evolution=createmarkers --config extensions.evolve='!'
+  pulling from http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+
 But we do let it goes fine on repository with exchange disabled:
 
   $ $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
   $ hg serve -R server -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log  --config experimental.evolution='!'
   $ hg debugpushkey http://localhost:$HGPORT/ obsolete
+
+(do some extra pulling to be sure)
+
+  $ hg -R client pull http://localhost:$HGPORT/
+  pulling from http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+
+  $ hg -R client pull http://localhost:$HGPORT/ --config experimental.evolution=createmarkers
+  pulling from http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+
+  $ hg -R client pull http://localhost:$HGPORT/ --config experimental.evolution=createmarkers --config extensions.evolve='!'
+  pulling from http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+
+  $ $RUNTESTDIR/killdaemons.py $DAEMON_PIDS