changeset 4547:bdcea921d28b mercurial-4.9

test-compat: merge stable into mercurial-4.9
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 20 Apr 2019 03:55:04 +0200
parents e7b44e9c38d2 (diff) a51b6684ad8f (current diff)
children d3cc1b55ad0a e914abb05c6a
files
diffstat 7 files changed, 66 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG	Wed Apr 17 20:56:24 2019 +0200
+++ b/CHANGELOG	Sat Apr 20 03:55:04 2019 +0200
@@ -1,6 +1,13 @@
 Changelog
 =========
 
+8.5.1 - in progress
+-------------------
+
+  * evolve: make sure we use upstream merge code with 5.0,
+  * topic: compatibility with mercurial-5.0,
+  * topic: improve extensions isolation (issue6121).
+
 8.5.0 -- 2019-04-23
 -------------------
 
--- a/hgext3rd/evolve/compat.py	Wed Apr 17 20:56:24 2019 +0200
+++ b/hgext3rd/evolve/compat.py	Sat Apr 20 03:55:04 2019 +0200
@@ -418,7 +418,7 @@
     return copy, movewithdir, diverge, renamedelete, dirmove
 
 # hg <= 4.9 compat (7694b685bb10)
-fixupstreamed = util.safehasattr(scmutil, '_movedirstate')
+fixupstreamed = util.safehasattr(scmutil, 'movedirstate')
 if not fixupstreamed:
     copies._fullcopytracing = fixedcopytracing
 
--- a/hgext3rd/topic/__init__.py	Wed Apr 17 20:56:24 2019 +0200
+++ b/hgext3rd/topic/__init__.py	Sat Apr 20 03:55:04 2019 +0200
@@ -139,6 +139,7 @@
 )
 
 from . import (
+    common,
     compat,
     constants,
     destination,
@@ -257,6 +258,8 @@
 topicrev = re.compile(r'^t\d+$')
 branchrev = re.compile(r'^b\d+$')
 
+hastopicext = common.hastopicext
+
 def _namemap(repo, name):
     revs = None
     if stackrev.match(name):
@@ -368,6 +371,9 @@
 
     class topicrepo(repo.__class__):
 
+        # attribute for other code to distinct between repo with topic and repo without
+        hastopicext = True
+
         def _restrictcapabilities(self, caps):
             caps = super(topicrepo, self)._restrictcapabilities(caps)
             caps.add('topics')
@@ -559,6 +565,8 @@
 
 def wrapinit(orig, self, repo, *args, **kwargs):
     orig(self, repo, *args, **kwargs)
+    if not hastopicext(repo):
+        return
     if constants.extrakey not in self._extra:
         if getattr(repo, 'currenttopic', ''):
             self._extra[constants.extrakey] = repo.currenttopic
@@ -1114,6 +1122,8 @@
     return topicmode
 
 def commitwrap(orig, ui, repo, *args, **opts):
+    if not hastopicext(repo):
+        return orig(ui, repo, *args, **opts)
     with repo.wlock():
         topicmode = _configtopicmode(ui)
         ismergecommit = len(repo[None].parents()) == 2
@@ -1155,10 +1165,11 @@
 
 def committextwrap(orig, repo, ctx, subs, extramsg):
     ret = orig(repo, ctx, subs, extramsg)
-    t = repo.currenttopic
-    if t:
-        ret = ret.replace("\nHG: branch",
-                          "\nHG: topic '%s'\nHG: branch" % t)
+    if hastopicext(repo):
+        t = repo.currenttopic
+        if t:
+            ret = ret.replace("\nHG: branch",
+                              "\nHG: topic '%s'\nHG: branch" % t)
     return ret
 
 def pushoutgoingwrap(orig, ui, repo, *args, **opts):
@@ -1175,6 +1186,8 @@
     ist0 = False
     try:
         ret = orig(repo, node, branchmerge, force, *args, **kwargs)
+        if not hastopicext(repo):
+            return ret
         # The mergeupdatewrap function makes the destination's topic as the
         # current topic. This is right for merge but wrong for rebase. We check
         # if rebase is running and update the currenttopic to topic of new
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgext3rd/topic/common.py	Sat Apr 20 03:55:04 2019 +0200
@@ -0,0 +1,8 @@
+# Copyright 2019 Pierre-Yves David <pierre-yves.david@octobus.net>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+def hastopicext(repo):
+    """True if the repo use the topic extension"""
+    return getattr(repo, 'hastopicext', False)
--- a/hgext3rd/topic/destination.py	Wed Apr 17 20:56:24 2019 +0200
+++ b/hgext3rd/topic/destination.py	Sat Apr 20 03:55:04 2019 +0200
@@ -7,7 +7,10 @@
     error,
     extensions,
 )
-from . import topicmap
+from . import (
+    common,
+    topicmap,
+)
 from .evolvebits import builddependencies
 
 def _destmergebranch(orig, repo, action='merge', sourceset=None,
@@ -19,7 +22,9 @@
         # XXX: using only the max here is flacky. That code should eventually
         # be updated to take care of the whole sourceset.
         p1 = repo[max(sourceset)]
-    top = p1.topic()
+    top = None
+    if common.hastopicext(repo):
+        top = p1.topic()
     if top:
         revs = repo.revs('topic(%s) - obsolete()', top)
         deps, rdeps = builddependencies(repo, revs)
@@ -57,6 +62,8 @@
 
 def _destupdatetopic(repo, clean, check=None):
     """decide on an update destination from current topic"""
+    if not common.hastopicext(repo):
+        return None, None, None
     movemark = node = None
     topic = repo.currenttopic
     if topic:
@@ -71,6 +78,8 @@
     return node, movemark, None
 
 def desthistedit(orig, ui, repo):
+    if not common.hastopicext(repo):
+        return None
     if not (ui.config('histedit', 'defaultrev', None) is None
             and repo.currenttopic):
         return orig(ui, repo)
--- a/hgext3rd/topic/discovery.py	Wed Apr 17 20:56:24 2019 +0200
+++ b/hgext3rd/topic/discovery.py	Sat Apr 20 03:55:04 2019 +0200
@@ -12,6 +12,9 @@
     extensions,
     util,
 )
+from . import (
+    common,
+)
 
 try:
     from mercurial import wireproto
@@ -26,7 +29,10 @@
 
     publishing = ('phases' not in remote.listkeys('namespaces')
                   or bool(remote.listkeys('phases').get('publishing', False)))
-    if ((publishing or not remote.capable('topics'))
+
+    if not common.hastopicext(pushop.repo):
+        return orig(pushop, *args, **kwargs)
+    elif ((publishing or not remote.capable('topics'))
             and not getattr(pushop, 'publish', False)):
         return orig(pushop, *args, **kwargs)
 
@@ -117,6 +123,8 @@
             remote.branchmap = origremotebranchmap
 
 def wireprotobranchmap(orig, repo, proto):
+    if not common.hastopicext(repo):
+        return orig(repo, proto)
     oldrepo = repo.__class__
     try:
         class repocls(repo.__class__):
@@ -146,7 +154,7 @@
 def handlecheckheads(orig, op, inpart):
     """This is used to check for new heads when publishing changeset"""
     orig(op, inpart)
-    if op.repo.publishing():
+    if not common.hastopicext(op.repo) or op.repo.publishing():
         return
     tr = op.gettransaction()
     if tr.hookargs['source'] not in ('push', 'serve'): # not a push
@@ -181,15 +189,16 @@
 handlecheckheads.params = frozenset()
 
 def _pushb2phases(orig, pushop, bundler):
-    checktypes = ('check:heads', 'check:updated-heads')
-    hascheck = any(p.type in checktypes for p in bundler._parts)
-    if not hascheck and pushop.outdatedphases:
-        exchange._pushb2ctxcheckheads(pushop, bundler)
+    if common.hastopicext(pushop.repo):
+        checktypes = ('check:heads', 'check:updated-heads')
+        hascheck = any(p.type in checktypes for p in bundler._parts)
+        if not hascheck and pushop.outdatedphases:
+            exchange._pushb2ctxcheckheads(pushop, bundler)
     return orig(pushop, bundler)
 
 def wireprotocaps(orig, repo, proto):
     caps = orig(repo, proto)
-    if repo.peer().capable('topics'):
+    if common.hastopicext(repo) and repo.peer().capable('topics'):
         caps.append('topics')
     return caps
 
--- a/hgext3rd/topic/topicmap.py	Wed Apr 17 20:56:24 2019 +0200
+++ b/hgext3rd/topic/topicmap.py	Sat Apr 20 03:55:04 2019 +0200
@@ -12,6 +12,10 @@
     util,
 )
 
+from . import (
+    common,
+)
+
 basefilter = set(['base', 'immutable'])
 def topicfilter(name):
     """return a "topic" version of a filter level"""
@@ -30,6 +34,8 @@
     return filtername.endswith('-topic')
 
 def gettopicrepo(repo):
+    if not common.hastopicext(repo):
+        return repo
     filtername = topicfilter(repo.filtername)
     if filtername == repo.filtername:
         return repo