Mercurial > evolve
annotate hgext3rd/topic/server.py @ 6548:445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
This config option controls what topic namespaces get pulled by default.
The current default option is '*', which means all namespaces get pulled.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 27 Jul 2023 16:39:43 -0300 |
parents | a87abe69a2f8 |
children | 2d3771d61068 |
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 ( |
6387
a87abe69a2f8
topic: branchmap already imports subsettable from repoviewutil
Anton Shestakov <av6@dwimlabs.net>
parents:
5931
diff
changeset
|
8 branchmap, |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
9 error, |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
10 extensions, |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
11 localrepo, |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
12 repoview, |
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 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
18 from . import ( |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
19 common, |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
20 constants, |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
21 ) |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
22 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
23 ### Visibility restriction |
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 # 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
|
26 # 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
|
27 # 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
|
28 # 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
|
29 # |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
30 # 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
|
31 # 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
|
32 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
33 # 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
|
34 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
35 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
|
36 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 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
|
41 consider = mutable - filteredrevs |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
42 cl = repo.changelog |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
43 extrafiltered = set() |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
44 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
|
45 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
|
46 extrafiltered.add(r) |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
47 if extrafiltered: |
5150
e0c091b199bc
topic: extend topic gating to descendant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5148
diff
changeset
|
48 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
|
49 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
|
50 return filteredrevs |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
51 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
52 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
|
53 """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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
60 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
|
61 """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
|
62 h = repo.heads() |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
63 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
|
64 |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
65 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
|
66 """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
|
67 if not common.hastopicext(repo): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
68 return topicheads(repo, proto) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
69 |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
70 namespaces = wireprototypes.decodelist(namespaces) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
71 if b'*' in namespaces: |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
72 # 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
|
73 h = repo.heads() |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
74 else: |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
75 # 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
|
76 h = [] |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
77 for branch, nodes in repo.branchmaptns().items(): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
78 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
|
79 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
|
80 h.extend(nodes) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
81 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
|
82 |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
83 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
|
84 """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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 else: |
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'none' |
6357551cb66f
topic: announce ext-topics-publish capability in case of SSH and HTTP too
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
94 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
|
95 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
|
96 return caps |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
97 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
98 def setupserver(ui): |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
106 class tnspeer(wireprotov1peer.wirepeer): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
107 @wireprotov1peer.batchable |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
108 def tns_heads(self, namespaces): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
109 def decode(d): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
110 try: |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
111 return wireprototypes.decodelist(d[:-1]) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
112 except ValueError: |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
113 self._abort(error.ResponseError(_(b"unexpected response:"), d)) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
114 |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
115 return {b'namespaces': wireprototypes.encodelist(namespaces)}, decode |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
116 |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
117 wireprotov1peer.wirepeer = tnspeer |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
118 |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
119 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
|
120 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
121 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
|
122 if command == b'heads': |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
123 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
|
124 command = b'tns_heads' |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
125 args[b'namespaces'] = self._peer.ui.configlist(b'experimental', b'tns-default-pull-namespaces', [b'*']) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
133 wireprotov1peer.peerexecutor = topicpeerexecutor |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
134 |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
135 class topiccommandexecutor(localrepo.localcommandexecutor): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
136 def callcommand(self, command, args): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
137 if command == b'heads': |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
138 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
|
139 command = b'tns_heads' |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
140 args[b'namespaces'] = self._peer.ui.configlist(b'experimental', b'tns-default-pull-namespaces', [b'*']) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
141 s = super(topiccommandexecutor, self) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
142 return s.callcommand(command, args) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
143 |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
144 localrepo.localcommandexecutor = topiccommandexecutor |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
145 |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
146 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
|
147 repoview.filtertable[FILTERNAME] = computeunservedtopic |
6387
a87abe69a2f8
topic: branchmap already imports subsettable from repoviewutil
Anton Shestakov <av6@dwimlabs.net>
parents:
5931
diff
changeset
|
148 # hg <= 4.9 (caebe5e7f4bd) |
a87abe69a2f8
topic: branchmap already imports subsettable from repoviewutil
Anton Shestakov <av6@dwimlabs.net>
parents:
5931
diff
changeset
|
149 branchmap.subsettable[FILTERNAME] = b'immutable' |
a87abe69a2f8
topic: branchmap already imports subsettable from repoviewutil
Anton Shestakov <av6@dwimlabs.net>
parents:
5931
diff
changeset
|
150 branchmap.subsettable[b'served'] = FILTERNAME |