annotate hgext3rd/topic/server.py @ 6618:b162b76a1ee9

topic: let pytype ignore wireprotov1peer.future attribute if it's not there The safehasattr() check is already done previously, so we're good.
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 26 Dec 2023 16:22:18 -0300
parents c7083ba82d5f
children e9650b5616ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
1 # topic/server.py - server specific behavior with topic
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
2 #
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
3 # This software may be used and distributed according to the terms of the
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
4 # GNU General Public License version 2 or any later version.
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
5 from mercurial.i18n import _
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
6
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
7 from mercurial import (
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
8 error,
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
9 extensions,
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
10 localrepo,
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
11 repoview,
6572
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
12 util,
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
13 wireprototypes,
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
14 wireprotov1peer,
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
15 wireprotov1server,
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
16 )
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
17
6606
c7083ba82d5f topic: drop compatibility {branchmap,repoviewutil}.subsettable for hg 4.9
Anton Shestakov <av6@dwimlabs.net>
parents: 6573
diff changeset
18 from mercurial.utils import repoviewutil
c7083ba82d5f topic: drop compatibility {branchmap,repoviewutil}.subsettable for hg 4.9
Anton Shestakov <av6@dwimlabs.net>
parents: 6573
diff changeset
19
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
20 from . import (
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
21 common,
6573
d511eba4cdb0 topic: compatibility for branchmaptns with branchmap from hg 5.0
Anton Shestakov <av6@dwimlabs.net>
parents: 6572
diff changeset
22 compat,
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
23 constants,
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
24 )
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
25
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
26 ### Visibility restriction
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
27 #
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
28 # Serving draft changesets with topics to clients without topic extension can
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
29 # confuse them, because they won't see the topic label and will consider them
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
30 # normal anonymous heads. Instead we have the option to not serve changesets
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
31 # with topics to clients without topic support.
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
32 #
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
33 # To achieve this, we alter the behavior of the standard `heads` commands and
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
34 # introduce a new `heads` command that only clients with topic will know about.
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
35
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
36 # compat version of the wireprotocommand decorator, taken from evolve compat
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
37
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
38 FILTERNAME = b'served-no-topic'
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
39
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
40 def computeunservedtopic(repo, visibilityexceptions=None):
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
41 assert not repo.changelog.filteredrevs
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
42 filteredrevs = repoview.filtertable[b'served'](repo, visibilityexceptions).copy()
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
43 mutable = repoview.filtertable[b'immutable'](repo, visibilityexceptions)
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
44 consider = mutable - filteredrevs
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
45 cl = repo.changelog
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
46 extrafiltered = set()
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
47 for r in consider:
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
48 if cl.changelogrevision(r).extra.get(constants.extrakey, b''):
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
49 extrafiltered.add(r)
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
50 if extrafiltered:
5150
e0c091b199bc topic: extend topic gating to descendant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 5148
diff changeset
51 extrafiltered = set(repo.revs('%ld::%ld', extrafiltered, consider))
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
52 filteredrevs = frozenset(filteredrevs | extrafiltered)
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
53 return filteredrevs
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
54
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
55 def wrapheads(orig, repo, proto):
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
56 """wrap head to hide topic^W draft changeset to old client"""
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
57 hidetopics = repo.ui.configbool(b'experimental', b'topic.server-gate-topic-changesets')
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
58 if common.hastopicext(repo) and hidetopics:
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
59 h = repo.filtered(FILTERNAME).heads()
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
60 return wireprototypes.bytesresponse(wireprototypes.encodelist(h) + b'\n')
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
61 return orig(repo, proto)
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
62
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
63 def topicheads(repo, proto):
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
64 """Same as the normal wireprotocol command, but accessing with a different end point."""
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
65 h = repo.heads()
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
66 return wireprototypes.bytesresponse(wireprototypes.encodelist(h) + b'\n')
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
67
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
68 def tns_heads(repo, proto, namespaces):
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
69 """wireprotocol command to filter heads based on topic namespaces"""
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
70 if not common.hastopicext(repo):
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
71 return topicheads(repo, proto)
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
72
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
73 namespaces = wireprototypes.decodelist(namespaces)
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
74 if b'*' in namespaces:
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
75 # pulling all topic namespaces, all changesets are visible
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
76 h = repo.heads()
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
77 else:
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
78 # only changesets in the selected topic namespaces are visible
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
79 h = []
6573
d511eba4cdb0 topic: compatibility for branchmaptns with branchmap from hg 5.0
Anton Shestakov <av6@dwimlabs.net>
parents: 6572
diff changeset
80 entries = compat.bcentries(repo.branchmaptns())
d511eba4cdb0 topic: compatibility for branchmaptns with branchmap from hg 5.0
Anton Shestakov <av6@dwimlabs.net>
parents: 6572
diff changeset
81 for branch, nodes in compat.branchmapitems(entries):
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
82 namedbranch, tns, topic = common.parsefqbn(branch)
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
83 if tns == b'none' or tns in namespaces:
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
84 h.extend(nodes)
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
85 return wireprototypes.bytesresponse(wireprototypes.encodelist(h) + b'\n')
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
86
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
87 def wireprotocaps(orig, repo, proto):
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
88 """advertise the new topic specific `head` command for client with topic"""
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
89 caps = orig(repo, proto)
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
90 if common.hastopicext(repo) and repo.peer().capable(b'topics'):
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
91 caps.append(b'_exttopics_heads')
5931
6357551cb66f topic: announce ext-topics-publish capability in case of SSH and HTTP too
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
92 if repo.ui.configbool(b'phases', b'publish'):
6357551cb66f topic: announce ext-topics-publish capability in case of SSH and HTTP too
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
93 mode = b'all'
6357551cb66f topic: announce ext-topics-publish capability in case of SSH and HTTP too
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
94 elif repo.ui.configbool(b'experimental', b'topic.publish-bare-branch'):
6357551cb66f topic: announce ext-topics-publish capability in case of SSH and HTTP too
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
95 mode = b'auto'
6357551cb66f topic: announce ext-topics-publish capability in case of SSH and HTTP too
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
96 else:
6357551cb66f topic: announce ext-topics-publish capability in case of SSH and HTTP too
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
97 mode = b'none'
6357551cb66f topic: announce ext-topics-publish capability in case of SSH and HTTP too
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
98 caps.append(b'ext-topics-publish=%s' % mode)
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
99 caps.append(b'ext-topics-tns-heads')
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
100 return caps
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
101
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
102 def setupserver(ui):
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
103 extensions.wrapfunction(wireprotov1server, 'heads', wrapheads)
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
104 wireprotov1server.commands.pop(b'heads')
5180
515d425c0a05 compat: drop 4.5 related compatibility around wireprotocol module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 5150
diff changeset
105 wireprotov1server.wireprotocommand(b'heads', permission=b'pull')(wireprotov1server.heads)
515d425c0a05 compat: drop 4.5 related compatibility around wireprotocol module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 5150
diff changeset
106 wireprotov1server.wireprotocommand(b'_exttopics_heads', permission=b'pull')(topicheads)
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
107 wireprotov1server.wireprotocommand(b'tns_heads', b'namespaces', permission=b'pull')(tns_heads)
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
108 extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps)
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
109
6572
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
110 if util.safehasattr(wireprotov1peer, 'future'):
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
111 # hg <= 5.9 (c424ff4807e6)
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
112 class tnspeer(wireprotov1peer.wirepeer):
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
113 """ wirepeer that uses `future` class from before c424ff4807e6 """
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
114 @wireprotov1peer.batchable
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
115 def tns_heads(self, namespaces):
6618
b162b76a1ee9 topic: let pytype ignore wireprotov1peer.future attribute if it's not there
Anton Shestakov <av6@dwimlabs.net>
parents: 6606
diff changeset
116 f = wireprotov1peer.future() # pytype: disable=module-attr
6572
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
117 yield {b'namespaces': wireprototypes.encodelist(namespaces)}, f
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
118 d = f.value
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
119 try:
6572
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
120 yield wireprototypes.decodelist(d[:-1])
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
121 except ValueError:
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
122 self._abort(error.ResponseError(_(b"unexpected response:"), d))
6572
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
123 else:
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
124 class tnspeer(wireprotov1peer.wirepeer):
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
125 """ wirepeer that uses newer batchable scheme from c424ff4807e6 """
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
126 @wireprotov1peer.batchable
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
127 def tns_heads(self, namespaces):
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
128 def decode(d):
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
129 try:
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
130 return wireprototypes.decodelist(d[:-1])
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
131 except ValueError:
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
132 self._abort(error.ResponseError(_(b"unexpected response:"), d))
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
133
6572
ef04d887c9a0 topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents: 6564
diff changeset
134 return {b'namespaces': wireprototypes.encodelist(namespaces)}, decode
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
135
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
136 wireprotov1peer.wirepeer = tnspeer
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
137
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
138 class topicpeerexecutor(wireprotov1peer.peerexecutor):
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
140 def callcommand(self, command, args):
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
141 if command == b'heads':
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
142 if self._peer.capable(b'ext-topics-tns-heads'):
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
143 command = b'tns_heads'
6564
2d3771d61068 topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents: 6548
diff changeset
144 if self._peer.ui.configbool(b'_internal', b'tns-explicit-target', False):
2d3771d61068 topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents: 6548
diff changeset
145 args[b'namespaces'] = [b'*']
2d3771d61068 topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents: 6548
diff changeset
146 else:
2d3771d61068 topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents: 6548
diff changeset
147 args[b'namespaces'] = self._peer.ui.configlist(b'experimental', b'tns-default-pull-namespaces', [b'*'])
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
148 elif self._peer.capable(b'_exttopics_heads'):
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
149 command = b'_exttopics_heads'
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
150 if getattr(self._peer, '_exttopics_heads', None) is None:
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
151 self._peer._exttopics_heads = self._peer.heads
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
152 s = super(topicpeerexecutor, self)
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
153 return s.callcommand(command, args)
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
154
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
155 wireprotov1peer.peerexecutor = topicpeerexecutor
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
156
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
157 class topiccommandexecutor(localrepo.localcommandexecutor):
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
158 def callcommand(self, command, args):
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
159 if command == b'heads':
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
160 if self._peer.capable(b'ext-topics-tns-heads'):
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
161 command = b'tns_heads'
6564
2d3771d61068 topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents: 6548
diff changeset
162 if self._peer.ui.configbool(b'_internal', b'tns-explicit-target', False):
2d3771d61068 topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents: 6548
diff changeset
163 args[b'namespaces'] = [b'*']
2d3771d61068 topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents: 6548
diff changeset
164 else:
2d3771d61068 topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents: 6548
diff changeset
165 args[b'namespaces'] = self._peer.ui.configlist(b'experimental', b'tns-default-pull-namespaces', [b'*'])
6548
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
166 s = super(topiccommandexecutor, self)
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
167 return s.callcommand(command, args)
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
168
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
169 localrepo.localcommandexecutor = topiccommandexecutor
445240ccb701 topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents: 6387
diff changeset
170
5139
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
171 if FILTERNAME not in repoview.filtertable:
19b8ffd23795 topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
172 repoview.filtertable[FILTERNAME] = computeunservedtopic
6606
c7083ba82d5f topic: drop compatibility {branchmap,repoviewutil}.subsettable for hg 4.9
Anton Shestakov <av6@dwimlabs.net>
parents: 6573
diff changeset
173 repoviewutil.subsettable[FILTERNAME] = b'immutable'
c7083ba82d5f topic: drop compatibility {branchmap,repoviewutil}.subsettable for hg 4.9
Anton Shestakov <av6@dwimlabs.net>
parents: 6573
diff changeset
174 repoviewutil.subsettable[b'served'] = FILTERNAME