Mercurial > evolve
changeset 6271:caf302fb8f4d
topic: use branch//namespace/topic format everywhere except exchange
We're converting branchmap from using the new "//" format into using the old
":" format as the first step for exchange process. It will make exchange
compatible with older clients that had branchmap in the ":" format without
topic namespaces. This obviously means that right now topic namespaces don't
affect exchange at all.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 08 Jul 2022 17:54:40 +0400 |
parents | 00d1551bfa8c |
children | 47268350b3bc |
files | hgext3rd/evolve/headchecking.py hgext3rd/topic/__init__.py hgext3rd/topic/discovery.py hgext3rd/topic/topicmap.py tests/test-minitopic.t tests/test-namespaces.t tests/test-push-checkheads-multi-topics-F3.t tests/test-single-head-obsolescence-topic-B2.t tests/test-single-head-obsolescence-topic-B5.t tests/test-split.t tests/test-topic-flow-single-head.t tests/test-topic-fold.t tests/test-topic-push.t tests/test-topic-stack-data.t tests/test-topic-stack.t tests/test-topic-tutorial.t tests/test-topic.t |
diffstat | 17 files changed, 48 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/headchecking.py Fri Jul 08 09:50:12 2022 +0200 +++ b/hgext3rd/evolve/headchecking.py Fri Jul 08 17:54:40 2022 +0400 @@ -127,9 +127,7 @@ # make it easy for extension with the branch logic there branch = ctx.branch() if util.safehasattr(ctx, 'topic'): - topic = ctx.topic() - if topic: - branch = "%s:%s" % (branch, topic) + branch = ctx.fqbn() return branch def _filter_obsolete_heads(repo, heads):
--- a/hgext3rd/topic/__init__.py Fri Jul 08 09:50:12 2022 +0200 +++ b/hgext3rd/topic/__init__.py Fri Jul 08 17:54:40 2022 +0400 @@ -570,19 +570,32 @@ # overwritten at the instance level by topicmap.py _autobranchmaptopic = True - def branchmap(self, topic=None): + def branchmap(self, topic=None, convertbm=False): if topic is None: topic = getattr(self, '_autobranchmaptopic', False) topicfilter = topicmap.topicfilter(self.filtername) if not topic or topicfilter == self.filtername: return super(topicrepo, self).branchmap() - return self.filtered(topicfilter).branchmap() + bm = self.filtered(topicfilter).branchmap() + if convertbm: + if util.safehasattr(bm, '_entries'): + entries = bm._entries + else: + # hg <= 4.9 (624d6683c705+b137a6793c51) + entries = bm + for key in list(entries): + branch, tns, topic = common.parsefqbn(key) + if topic: + value = entries.pop(key) + # we lose namespace when converting to ":" format + key = b'%s:%s' % (branch, topic) + entries[key] = value + return bm def branchheads(self, branch=None, start=None, closed=False): if branch is None: branch = self[None].branch() - if self.currenttopic: - branch = b"%s:%s" % (branch, self.currenttopic) + branch = common.formatfqbn(branch, self.currenttns, self.currenttopic) return super(topicrepo, self).branchheads(branch=branch, start=start, closed=closed) @@ -599,7 +612,7 @@ class topicpeer(peer.__class__): def branchmap(self): usetopic = not self._repo.publishing() - return self._repo.branchmap(topic=usetopic) + return self._repo.branchmap(topic=usetopic, convertbm=usetopic) peer.__class__ = topicpeer return peer
--- a/hgext3rd/topic/discovery.py Fri Jul 08 09:50:12 2022 +0200 +++ b/hgext3rd/topic/discovery.py Fri Jul 08 17:54:40 2022 +0400 @@ -37,10 +37,7 @@ branch = oldbranch() if rev in publishedset: return branch - topic = ctx.topic() - if topic: - branch = b"%s:%s" % (branch, topic) - return branch + return ctx.fqbn() def parents(): parents = oldparents() @@ -53,10 +50,7 @@ branch = pbranch() if p.rev() in publishedset: return branch - topic = p.topic() - if topic: - branch = b"%s:%s" % (branch, topic) - return branch + return p.fqbn() p.branch = branch p._topic_ext_branch_hack = True return parents @@ -75,9 +69,7 @@ branch, close = changelog.branchinfo(rev) if rev in publishedset: return branch, close - topic = unfi[rev].topic() - if topic: - branch = b"%s:%s" % (branch, topic) + branch = unfi[rev].fqbn() return branch, close rbc.branchinfo = branchinfo @@ -125,7 +117,9 @@ if b':' not in branch: result[branch].extend(heads) else: - namedbranch = branch.split(b':', 1)[0] + namedbranch, topic = branch.split(b':', 1) + # we lost namespace when converting to ":" format + branch = common.formatfqbn(namedbranch, topic=topic) for h in heads: r = getrev(h) if r is not None and r in publishedset: @@ -145,7 +139,8 @@ pushop.repo = repo summary = orig(pushop) for key, value in summary.items(): - if b':' in key: # This is a topic + branch, tns, topic = common.parsefqbn(key) + if topic: # FIXME: also check namespace? if value[0] is None and value[1]: summary[key] = ([value[1][0]], ) + value[1:] return summary @@ -164,7 +159,7 @@ class repocls(oldrepocls): def branchmap(self): usetopic = not self.publishing() - return super(repocls, self).branchmap(topic=usetopic) + return super(repocls, self).branchmap(topic=usetopic, convertbm=usetopic) unfi.__class__ = repocls if repo.filtername is not None: repo = unfi.filtered(repo.filtername)
--- a/hgext3rd/topic/topicmap.py Fri Jul 08 09:50:12 2022 +0200 +++ b/hgext3rd/topic/topicmap.py Fri Jul 08 17:54:40 2022 +0400 @@ -219,13 +219,10 @@ def branchinfo(r, changelog=None): info = oldgetbranchinfo(r) - topic = b'' ctx = unfi[r] + branch = info[0] if ctx.mutable(): - topic = ctx.topic() - branch = info[0] - if topic: - branch = b'%s:%s' % (branch, topic) + branch = ctx.fqbn() return (branch, info[1]) try: unfi.revbranchcache().branchinfo = branchinfo
--- a/tests/test-minitopic.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-minitopic.t Fri Jul 08 17:54:40 2022 +0400 @@ -220,7 +220,7 @@ $ hg push enabled pushing to http://localhost:$HGPORT/ searching for changes - abort: push creates new remote head 82c5842e0472 on branch 'default:topic_A' + abort: push creates new remote head 82c5842e0472 on branch 'default//topic_A' (merge or see 'hg help push' for details about pushing new heads) [20] $ hg push disabled
--- a/tests/test-namespaces.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-namespaces.t Fri Jul 08 17:54:40 2022 +0400 @@ -45,6 +45,9 @@ $ hg log -r . -T '{rev}: {fqbn}\n' 0: stable//alice/feature + $ hg branches + stable//alice/feature 0:69c7dbf6acd1 + Updating to a revision with a namespace should activate it $ hg up null
--- a/tests/test-push-checkheads-multi-topics-F3.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-push-checkheads-multi-topics-F3.t Fri Jul 08 17:54:40 2022 +0400 @@ -94,7 +94,7 @@ $ hg push -r 'desc("C1")' pushing to $TESTTMP/E1/server searching for changes - abort: push creates new remote head 57530ca5eb24 on branch 'default:Y' + abort: push creates new remote head 57530ca5eb24 on branch 'default//Y' (merge or see 'hg help push' for details about pushing new heads) [20]
--- a/tests/test-single-head-obsolescence-topic-B2.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-single-head-obsolescence-topic-B2.t Fri Jul 08 17:54:40 2022 +0400 @@ -109,6 +109,6 @@ adding file changes transaction abort! rollback completed - abort: rejecting multiple heads on branch "default:topic-X" + abort: rejecting multiple heads on branch "default//topic-X" (2 heads: 5a47a98cd8e5 5a4735b75167) [255]
--- a/tests/test-single-head-obsolescence-topic-B5.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-single-head-obsolescence-topic-B5.t Fri Jul 08 17:54:40 2022 +0400 @@ -110,6 +110,6 @@ no changes found transaction abort! rollback completed - abort: rejecting multiple heads on branch "default:topic-X" + abort: rejecting multiple heads on branch "default//topic-X" (2 heads: 5a47a98cd8e5 d3826ff42cf7) [255]
--- a/tests/test-split.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-split.t Fri Jul 08 17:54:40 2022 +0400 @@ -431,7 +431,7 @@ $ hg summary parent: 18:26f72cfaf036 tip Works on mytopic - branch: new-branch:mytopic + branch: new-branch//mytopic commit: (clean) update: (current) phases: 9 draft
--- a/tests/test-topic-flow-single-head.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-topic-flow-single-head.t Fri Jul 08 17:54:40 2022 +0400 @@ -146,7 +146,7 @@ adding file changes transaction abort! rollback completed - abort: 2 heads on "default:bar" + abort: 2 heads on "default//bar" (5194f5dcd542, 48a01453c1c5) [255]
--- a/tests/test-topic-fold.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-topic-fold.t Fri Jul 08 17:54:40 2022 +0400 @@ -49,7 +49,7 @@ $ hg summary parent: 3:ba602426356f tip folded - branch: default:myfeature + branch: default//myfeature commit: (clean) update: (current) phases: 2 draft
--- a/tests/test-topic-push.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-topic-push.t Fri Jul 08 17:54:40 2022 +0400 @@ -384,7 +384,7 @@ $ hg push draft pushing to $TESTTMP/draft (glob) searching for changes - abort: push creates new remote head f0bc62a661be on branch 'default:babar' + abort: push creates new remote head f0bc62a661be on branch 'default//babar' (merge or see 'hg help push' for details about pushing new heads) [20]
--- a/tests/test-topic-stack-data.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-topic-stack-data.t Fri Jul 08 17:54:40 2022 +0400 @@ -111,7 +111,7 @@ $ hg summary parent: 21:3e54b49a3113 tip add foo_b - branch: lake:foo + branch: lake//foo commit: (clean) update: (current) phases: 22 draft
--- a/tests/test-topic-stack.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-topic-stack.t Fri Jul 08 17:54:40 2022 +0400 @@ -313,7 +313,7 @@ $ hg summary parent: 3:e629654d7050 c_d - branch: default:foo + branch: default//foo commit: (clean) update: 2 new changesets (update) phases: 4 draft
--- a/tests/test-topic-tutorial.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-topic-tutorial.t Fri Jul 08 17:54:40 2022 +0400 @@ -108,7 +108,7 @@ $ hg summary parent: 0:38da43f0a2ea tip Shopping list - branch: default:food + branch: default//food commit: (new branch) update: (current) topic: food
--- a/tests/test-topic.t Fri Jul 08 09:50:12 2022 +0200 +++ b/tests/test-topic.t Fri Jul 08 17:54:40 2022 +0400 @@ -599,11 +599,11 @@ fran (1 changesets) * narf (2 changesets) query (2 changesets) - $ hg debugnamecomplete # branch:topic here is a buggy side effect + $ hg debugnamecomplete default - default:fran - default:narf - default:query + default//fran + default//narf + default//query fran narf query