Mercurial > evolve
annotate hgext3rd/topic/server.py @ 6893:858b4ca88ea7 stable
tests: check that installed evolve works in test-version-install.t
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sun, 06 Oct 2024 20:29:03 +0400 |
parents | 23cad1a872b6 |
children | e9650b5616ac |
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, |
6572
ef04d887c9a0
topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents:
6564
diff
changeset
|
13 util, |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
14 wireprototypes, |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
15 wireprotov1peer, |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
16 wireprotov1server, |
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 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
19 from . import ( |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
20 common, |
6573
d511eba4cdb0
topic: compatibility for branchmaptns with branchmap from hg 5.0
Anton Shestakov <av6@dwimlabs.net>
parents:
6572
diff
changeset
|
21 compat, |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
22 constants, |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
23 ) |
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 ### Visibility restriction |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
26 # |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
27 # 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
|
28 # 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
|
29 # 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
|
30 # 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
|
31 # |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
32 # 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
|
33 # 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
|
34 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
35 # 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
|
36 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
37 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
|
38 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 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
|
43 consider = mutable - filteredrevs |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
44 cl = repo.changelog |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
45 extrafiltered = set() |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
46 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
|
47 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
|
48 extrafiltered.add(r) |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
49 if extrafiltered: |
5150
e0c091b199bc
topic: extend topic gating to descendant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5148
diff
changeset
|
50 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
|
51 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
|
52 return filteredrevs |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
53 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
54 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
|
55 """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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
62 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
|
63 """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
|
64 h = repo.heads() |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
65 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
|
66 |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
67 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
|
68 """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
|
69 if not common.hastopicext(repo): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
70 return topicheads(repo, proto) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
71 |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
72 namespaces = wireprototypes.decodelist(namespaces) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
73 if b'*' in namespaces: |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
74 # 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
|
75 h = repo.heads() |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
76 else: |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
77 # 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
|
78 h = [] |
6573
d511eba4cdb0
topic: compatibility for branchmaptns with branchmap from hg 5.0
Anton Shestakov <av6@dwimlabs.net>
parents:
6572
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 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
|
83 h.extend(nodes) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
84 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
|
85 |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
86 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
|
87 """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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 else: |
6357551cb66f
topic: announce ext-topics-publish capability in case of SSH and HTTP too
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
96 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
|
97 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
|
98 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
|
99 return caps |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
100 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
101 def setupserver(ui): |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 |
6572
ef04d887c9a0
topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents:
6564
diff
changeset
|
109 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
|
110 # hg <= 5.9 (c424ff4807e6) |
6644
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
111 @wireprotov1peer.batchable |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
112 def wp_tns_heads(self, namespaces): |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
113 f = wireprotov1peer.future() |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
114 yield {b'namespaces': wireprototypes.encodelist(namespaces)}, f |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
115 d = f.value |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
116 try: |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
117 yield wireprototypes.decodelist(d[:-1]) |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
118 except ValueError: |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
119 self._abort(error.ResponseError(_(b"unexpected response:"), d)) |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
120 else: |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
121 @wireprotov1peer.batchable |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
122 def wp_tns_heads(self, namespaces): |
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
123 def decode(d): |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
124 try: |
6644
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
125 return wireprototypes.decodelist(d[:-1]) |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
126 except ValueError: |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
127 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
|
128 |
6644
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
129 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
|
130 |
6644
23cad1a872b6
topic: add tns_heads method to wirepeer directly instead of using a subclass
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6573
diff
changeset
|
131 wireprotov1peer.wirepeer.tns_heads = wp_tns_heads |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
132 |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
133 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
|
134 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
135 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
|
136 if command == b'heads': |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
137 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
|
138 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
|
139 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
|
140 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
|
141 else: |
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6548
diff
changeset
|
142 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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
150 wireprotov1peer.peerexecutor = topicpeerexecutor |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
151 |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
152 class topiccommandexecutor(localrepo.localcommandexecutor): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
153 def callcommand(self, command, args): |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
154 if command == b'heads': |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
155 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
|
156 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
|
157 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
|
158 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
|
159 else: |
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6548
diff
changeset
|
160 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
|
161 s = super(topiccommandexecutor, self) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
162 return s.callcommand(command, args) |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
163 |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
164 localrepo.localcommandexecutor = topiccommandexecutor |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
165 |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
166 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
|
167 repoview.filtertable[FILTERNAME] = computeunservedtopic |
6387
a87abe69a2f8
topic: branchmap already imports subsettable from repoviewutil
Anton Shestakov <av6@dwimlabs.net>
parents:
5931
diff
changeset
|
168 # hg <= 4.9 (caebe5e7f4bd) |
a87abe69a2f8
topic: branchmap already imports subsettable from repoviewutil
Anton Shestakov <av6@dwimlabs.net>
parents:
5931
diff
changeset
|
169 branchmap.subsettable[FILTERNAME] = b'immutable' |
a87abe69a2f8
topic: branchmap already imports subsettable from repoviewutil
Anton Shestakov <av6@dwimlabs.net>
parents:
5931
diff
changeset
|
170 branchmap.subsettable[b'served'] = FILTERNAME |