# HG changeset patch # User Anton Shestakov # Date 1657288480 -14400 # Node ID caf302fb8f4dfa8664dafa1139bfcb7c911c4dc0 # Parent 00d1551bfa8cf5efae90bfb41d8b69a32c74636a 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. diff -r 00d1551bfa8c -r caf302fb8f4d hgext3rd/evolve/headchecking.py --- 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): diff -r 00d1551bfa8c -r caf302fb8f4d hgext3rd/topic/__init__.py --- 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 diff -r 00d1551bfa8c -r caf302fb8f4d hgext3rd/topic/discovery.py --- 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) diff -r 00d1551bfa8c -r caf302fb8f4d hgext3rd/topic/topicmap.py --- 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 diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-minitopic.t --- 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 diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-namespaces.t --- 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 diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-push-checkheads-multi-topics-F3.t --- 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] diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-single-head-obsolescence-topic-B2.t --- 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] diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-single-head-obsolescence-topic-B5.t --- 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] diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-split.t --- 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 diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-topic-flow-single-head.t --- 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] diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-topic-fold.t --- 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 diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-topic-push.t --- 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] diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-topic-stack-data.t --- 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 diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-topic-stack.t --- 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 diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-topic-tutorial.t --- 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 diff -r 00d1551bfa8c -r caf302fb8f4d tests/test-topic.t --- 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