Mercurial > evolve
annotate hgext3rd/topic/server.py @ 6702:691a9301b51e
topic: drop compatibility for tr.changes[b'phases'] being a dict in hg 5.3
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 10 Jan 2024 15:39:03 -0300 |
parents | 92fd4581f569 |
children | 71c4b6c2bcdc |
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 |
6652
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
102 class topiccommandexecutor(localrepo.localcommandexecutor): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
103 def callcommand(self, command, args): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
104 if command == b'heads': |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
105 if self._peer.capable(b'ext-topics-tns-heads'): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
106 command = b'tns_heads' |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
107 if self._peer.ui.configbool(b'_internal', b'tns-explicit-target', False): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
108 args[b'namespaces'] = [b'*'] |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
109 else: |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
110 args[b'namespaces'] = self._peer.ui.configlist(b'experimental', b'tns-default-pull-namespaces', [b'*']) |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
111 s = super(topiccommandexecutor, self) |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
112 return s.callcommand(command, args) |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
113 |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
114 class topicpeerexecutor(wireprotov1peer.peerexecutor): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
115 def callcommand(self, command, args): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
116 if command == b'heads': |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
117 if self._peer.capable(b'ext-topics-tns-heads'): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
118 command = b'tns_heads' |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
119 if self._peer.ui.configbool(b'_internal', b'tns-explicit-target', False): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
120 args[b'namespaces'] = [b'*'] |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
121 else: |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
122 args[b'namespaces'] = self._peer.ui.configlist(b'experimental', b'tns-default-pull-namespaces', [b'*']) |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
123 elif self._peer.capable(b'_exttopics_heads'): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
124 command = b'_exttopics_heads' |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
125 if getattr(self._peer, '_exttopics_heads', None) is None: |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
126 self._peer._exttopics_heads = self._peer.heads |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
127 s = super(topicpeerexecutor, self) |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
128 return s.callcommand(command, args) |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
129 |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
130 def setupserver(ui): |
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 |
6572
ef04d887c9a0
topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
Anton Shestakov <av6@dwimlabs.net>
parents:
6564
diff
changeset
|
138 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
|
139 # 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
|
140 @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
|
141 def wp_tns_heads(self, namespaces): |
6651 | 142 f = wireprotov1peer.future() # pytype: disable=module-attr |
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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 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
|
150 @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
|
151 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
|
152 def decode(d): |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
153 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
|
154 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
|
155 except ValueError: |
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
156 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
|
157 |
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
|
158 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
|
159 |
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
|
160 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
|
161 |
6652
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
162 def wp_commandexecutor(self): |
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
163 return topicpeerexecutor(self) |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
164 |
6652
92fd4581f569
topic: return our special executor classes for each instance
Anton Shestakov <av6@dwimlabs.net>
parents:
6651
diff
changeset
|
165 wireprotov1peer.wirepeer.commandexecutor = wp_commandexecutor |
6548
445240ccb701
topic: add experimental.tns-default-pull-namespaces config option
Anton Shestakov <av6@dwimlabs.net>
parents:
6387
diff
changeset
|
166 |
5139
19b8ffd23795
topic: option to hide topic changesets to plain client
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 repoviewutil.subsettable[b'served'] = FILTERNAME |