# HG changeset patch # User Pierre-Yves David # Date 1555725304 -7200 # Node ID bdcea921d28b8b2ce4cbefd83cb24fb97c50942c # Parent e7b44e9c38d2b7e78d52ed97daf28299d1a08dd4# Parent a51b6684ad8f9fb5f825b252908048ffc4d714df test-compat: merge stable into mercurial-4.9 diff -r a51b6684ad8f -r bdcea921d28b CHANGELOG --- 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 ------------------- diff -r a51b6684ad8f -r bdcea921d28b hgext3rd/evolve/compat.py --- 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 diff -r a51b6684ad8f -r bdcea921d28b hgext3rd/topic/__init__.py --- 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 diff -r a51b6684ad8f -r bdcea921d28b hgext3rd/topic/common.py --- /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 +# +# 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) diff -r a51b6684ad8f -r bdcea921d28b hgext3rd/topic/destination.py --- 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) diff -r a51b6684ad8f -r bdcea921d28b hgext3rd/topic/discovery.py --- 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 diff -r a51b6684ad8f -r bdcea921d28b hgext3rd/topic/topicmap.py --- 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