Mercurial > evolve
annotate hgext3rd/topic/discovery.py @ 6936:a239ea1dfacb default tip
branching: merge with stable
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 22 Nov 2024 16:53:42 +0400 |
parents | 361dcfcb3f08 |
children |
rev | line source |
---|---|
1934
9d6d30e36cdd
discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1921
diff
changeset
|
1 from __future__ import absolute_import |
9d6d30e36cdd
discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1921
diff
changeset
|
2 |
3182
bc09dd507c41
topic: fix new head detection when using --publish on a topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2696
diff
changeset
|
3 import collections |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
4 import contextlib |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
5 import weakref |
1934
9d6d30e36cdd
discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1921
diff
changeset
|
6 |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
7 from mercurial.i18n import _ |
1934
9d6d30e36cdd
discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1921
diff
changeset
|
8 from mercurial import ( |
1944
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
9 bundle2, |
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
10 discovery, |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
11 encoding, |
1934
9d6d30e36cdd
discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1921
diff
changeset
|
12 exchange, |
1944
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
13 extensions, |
6564
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6563
diff
changeset
|
14 hg, |
5581
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
15 scmutil, |
2676
10dedac0d82e
topic: also insert the extra head check with using the new head checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2675
diff
changeset
|
16 util, |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
17 wireprototypes, |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
18 wireprotov1server, |
1934
9d6d30e36cdd
discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1921
diff
changeset
|
19 ) |
6383
c6e3d2dbbeb0
topic: simply reuse wirepeer.branchmap() as wirepeer.branchmaptns()
Anton Shestakov <av6@dwimlabs.net>
parents:
6382
diff
changeset
|
20 from mercurial.wireprotov1peer import wirepeer |
4540
22cde12d9467
topic: only wrap _headssummary for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
21 from . import ( |
22cde12d9467
topic: only wrap _headssummary for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
22 common, |
4743
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
4742
diff
changeset
|
23 compat, |
4540
22cde12d9467
topic: only wrap _headssummary for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
24 ) |
1934
9d6d30e36cdd
discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1921
diff
changeset
|
25 |
6890
7ec9f4b04519
topic: compatibility for revbranchcache being in a separate module now
Anton Shestakov <av6@dwimlabs.net>
parents:
6786
diff
changeset
|
26 try: |
7ec9f4b04519
topic: compatibility for revbranchcache being in a separate module now
Anton Shestakov <av6@dwimlabs.net>
parents:
6786
diff
changeset
|
27 from mercurial.branching.rev_cache import revbranchcache |
7ec9f4b04519
topic: compatibility for revbranchcache being in a separate module now
Anton Shestakov <av6@dwimlabs.net>
parents:
6786
diff
changeset
|
28 except ImportError: |
7ec9f4b04519
topic: compatibility for revbranchcache being in a separate module now
Anton Shestakov <av6@dwimlabs.net>
parents:
6786
diff
changeset
|
29 # hg <= 6.8 (f0e07efc199f) |
7ec9f4b04519
topic: compatibility for revbranchcache being in a separate module now
Anton Shestakov <av6@dwimlabs.net>
parents:
6786
diff
changeset
|
30 from mercurial.branchmap import revbranchcache |
7ec9f4b04519
topic: compatibility for revbranchcache being in a separate module now
Anton Shestakov <av6@dwimlabs.net>
parents:
6786
diff
changeset
|
31 |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
32 urlreq = util.urlreq |
3678
d725fe3e3989
topic: handle wireproto module change from b4d85bc122bd
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3186
diff
changeset
|
33 |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
34 @contextlib.contextmanager |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
35 def override_context_branch(repo, publishedset=()): |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
36 unfi = repo.unfiltered() |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
37 |
6364
e8d85d51c7b2
topic: monkey-patch ctx.branch() correctly in override_context_branch
Anton Shestakov <av6@dwimlabs.net>
parents:
6125
diff
changeset
|
38 def overridebranch(p, origbranch): |
e8d85d51c7b2
topic: monkey-patch ctx.branch() correctly in override_context_branch
Anton Shestakov <av6@dwimlabs.net>
parents:
6125
diff
changeset
|
39 def branch(): |
6369 | 40 branch = origbranch() |
6364
e8d85d51c7b2
topic: monkey-patch ctx.branch() correctly in override_context_branch
Anton Shestakov <av6@dwimlabs.net>
parents:
6125
diff
changeset
|
41 if p.rev() in publishedset: |
6369 | 42 return common.formatfqbn(branch=branch) |
43 return p.fqbn() | |
6364
e8d85d51c7b2
topic: monkey-patch ctx.branch() correctly in override_context_branch
Anton Shestakov <av6@dwimlabs.net>
parents:
6125
diff
changeset
|
44 return branch |
e8d85d51c7b2
topic: monkey-patch ctx.branch() correctly in override_context_branch
Anton Shestakov <av6@dwimlabs.net>
parents:
6125
diff
changeset
|
45 |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
46 class repocls(unfi.__class__): |
6295
e81b3516242f
topic: update a comment about branch:topic, use the modern version
Anton Shestakov <av6@dwimlabs.net>
parents:
6271
diff
changeset
|
47 # awful hack to see branch as "branch//namespace/topic" |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
48 def __getitem__(self, key): |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
49 ctx = super(repocls, self).__getitem__(key) |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
50 oldbranch = ctx.branch |
5684
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
51 oldparents = ctx.parents |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
52 rev = ctx.rev() |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
53 |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
54 def branch(): |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
55 branch = oldbranch() |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
56 if rev in publishedset: |
6336
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
57 return common.formatfqbn(branch=branch) |
6271
caf302fb8f4d
topic: use branch//namespace/topic format everywhere except exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6270
diff
changeset
|
58 return ctx.fqbn() |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
59 |
5684
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
60 def parents(): |
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
61 parents = oldparents() |
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
62 for p in parents: |
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
63 if getattr(p, '_topic_ext_branch_hack', False): |
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
64 continue |
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
65 |
6364
e8d85d51c7b2
topic: monkey-patch ctx.branch() correctly in override_context_branch
Anton Shestakov <av6@dwimlabs.net>
parents:
6125
diff
changeset
|
66 p.branch = overridebranch(p, p.branch) |
5684
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
67 p._topic_ext_branch_hack = True |
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
68 return parents |
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
69 |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
70 ctx.branch = branch |
5684
4de216446c53
topic: also wrap the `ctx.branch` of parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5683
diff
changeset
|
71 ctx.parents = parents |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
72 return ctx |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
73 |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
74 oldrepocls = unfi.__class__ |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
75 try: |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
76 unfi.__class__ = repocls |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
77 if repo.filtername is not None: |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
78 repo = unfi.filtered(repo.filtername) |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
79 else: |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
80 repo = unfi |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
81 yield repo |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
82 finally: |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
83 unfi.__class__ = oldrepocls |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
84 |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
85 |
3689
415c872d3308
topic: remove compatibility for older version in discovery wrapping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3678
diff
changeset
|
86 def _headssummary(orig, pushop, *args, **kwargs): |
415c872d3308
topic: remove compatibility for older version in discovery wrapping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3678
diff
changeset
|
87 repo = pushop.repo.unfiltered() |
415c872d3308
topic: remove compatibility for older version in discovery wrapping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3678
diff
changeset
|
88 remote = pushop.remote |
2558
65cf338258d2
fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents:
1965
diff
changeset
|
89 |
3182
bc09dd507c41
topic: fix new head detection when using --publish on a topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2696
diff
changeset
|
90 publishedset = () |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
91 if remote.capable(b'topics-namespaces'): |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
92 origremotebranchmap = remote.branchmaptns |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
93 else: |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
94 origremotebranchmap = remote.branchmap |
4263
35130e428ebd
compat: drop code dealing with incompatibility for --publish with 4.3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4194
diff
changeset
|
95 publishednode = [c.node() for c in pushop.outdatedphases] |
6786
ae01e2b10419
topic: compatibility for RemotePhasesSummary.public_heads
Anton Shestakov <av6@dwimlabs.net>
parents:
6785
diff
changeset
|
96 if util.safehasattr(pushop.remotephases, 'publicheads'): |
ae01e2b10419
topic: compatibility for RemotePhasesSummary.public_heads
Anton Shestakov <av6@dwimlabs.net>
parents:
6785
diff
changeset
|
97 # hg <= 6.7 (22cc679a7312) |
ae01e2b10419
topic: compatibility for RemotePhasesSummary.public_heads
Anton Shestakov <av6@dwimlabs.net>
parents:
6785
diff
changeset
|
98 publishedset = repo.revs(b'ancestors(%ln + %ln)', publishednode, pushop.remotephases.publicheads) |
ae01e2b10419
topic: compatibility for RemotePhasesSummary.public_heads
Anton Shestakov <av6@dwimlabs.net>
parents:
6785
diff
changeset
|
99 else: |
ae01e2b10419
topic: compatibility for RemotePhasesSummary.public_heads
Anton Shestakov <av6@dwimlabs.net>
parents:
6785
diff
changeset
|
100 publishedset = repo.revs(b'ancestors(%ln + %ld)', publishednode, pushop.remotephases.public_heads) |
3182
bc09dd507c41
topic: fix new head detection when using --publish on a topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2696
diff
changeset
|
101 |
6336
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
102 publishing = (b'phases' not in remote.listkeys(b'namespaces') |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
103 or bool(remote.listkeys(b'phases').get(b'publishing', False))) |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
104 # remote repo may be non-publishing, but if user does hg push --publish, we |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
105 # still need to consider push operation publishing |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
106 publishing = publishing or pushop.publish |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
107 |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
108 ctxoverride = util.nullcontextmanager() |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
109 if common.hastopicext(pushop.repo) and remote.capable(b'topics'): |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
110 ctxoverride = override_context_branch(repo, publishedset=publishedset) |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
111 overrides = {(b'_internal', b'tns-publish'): publishing} |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
112 else: |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
113 overrides = {(b'_internal', b'tns-disable-fqbn'): True} |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
114 configoverride = repo.ui.configoverride(overrides, b'topic-namespaces') |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
115 |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
116 if not common.hastopicext(pushop.repo): |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
117 with ctxoverride, configoverride: |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
118 return orig(pushop, *args, **kwargs) |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
119 elif ((publishing or not remote.capable(b'topics')) |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
120 and not getattr(pushop, 'publish', False)): |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
121 with ctxoverride, configoverride: |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
122 return orig(pushop, *args, **kwargs) |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
123 |
4929
bb2b4f6c99dc
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4814
diff
changeset
|
124 getrev = compat.getgetrev(repo.unfiltered().changelog) |
3182
bc09dd507c41
topic: fix new head detection when using --publish on a topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2696
diff
changeset
|
125 |
4263
35130e428ebd
compat: drop code dealing with incompatibility for --publish with 4.3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4194
diff
changeset
|
126 def remotebranchmap(): |
35130e428ebd
compat: drop code dealing with incompatibility for --publish with 4.3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4194
diff
changeset
|
127 # drop topic information from changeset about to be published |
35130e428ebd
compat: drop code dealing with incompatibility for --publish with 4.3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4194
diff
changeset
|
128 result = collections.defaultdict(list) |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
129 items = list(compat.branchmapitems(origremotebranchmap())) |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
130 if not remote.capable(b'topics-namespaces'): |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
131 items = [(common.upgradeformat(branch), heads) for branch, heads in items] |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
132 for branch, heads in items: |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
133 namedbranch, tns, topic = common.parsefqbn(branch) |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
134 for h in heads: |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
135 r = getrev(h) |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
136 if r is not None and r in publishedset: |
6336
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
137 result[common.formatfqbn(branch=namedbranch)].append(h) |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
138 else: |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
139 result[branch].append(h) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4804
diff
changeset
|
140 for heads in result.values(): |
4263
35130e428ebd
compat: drop code dealing with incompatibility for --publish with 4.3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4194
diff
changeset
|
141 heads.sort() |
35130e428ebd
compat: drop code dealing with incompatibility for --publish with 4.3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4194
diff
changeset
|
142 return result |
3182
bc09dd507c41
topic: fix new head detection when using --publish on a topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2696
diff
changeset
|
143 |
6336
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
144 with ctxoverride, configoverride: |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
145 try: |
6667
31e157a5cfe2
cleanup: remove unnecessary remotebranchmap checks
Manuel Jacob <me@manueljacob.de>
parents:
6607
diff
changeset
|
146 remote.branchmap = remotebranchmap |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
147 unxx = repo.filtered(b'unfiltered-topic') |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
148 repo.unfiltered = lambda: unxx |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
149 pushop.repo = repo |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
150 summary = orig(pushop) |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
151 for key, value in summary.items(): |
6271
caf302fb8f4d
topic: use branch//namespace/topic format everywhere except exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6270
diff
changeset
|
152 branch, tns, topic = common.parsefqbn(key) |
caf302fb8f4d
topic: use branch//namespace/topic format everywhere except exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6270
diff
changeset
|
153 if topic: # FIXME: also check namespace? |
5683
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
154 if value[0] is None and value[1]: |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
155 summary[key] = ([value[1][0]], ) + value[1:] |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
156 return summary |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
157 finally: |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
158 if r'unfiltered' in vars(repo): |
1dece375d2ab
topic: extract awful `ctx.branch` hijacking used in discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5581
diff
changeset
|
159 del repo.unfiltered |
6667
31e157a5cfe2
cleanup: remove unnecessary remotebranchmap checks
Manuel Jacob <me@manueljacob.de>
parents:
6607
diff
changeset
|
160 remote.branchmap = origremotebranchmap |
1886
0504e76bfbd9
push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
161 |
0504e76bfbd9
push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
162 def wireprotobranchmap(orig, repo, proto): |
4541
7e98faf278d6
topic: only wrap wireprotobranchmap for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4540
diff
changeset
|
163 if not common.hastopicext(repo): |
7e98faf278d6
topic: only wrap wireprotobranchmap for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4540
diff
changeset
|
164 return orig(repo, proto) |
6270
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
165 unfi = repo.unfiltered() |
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
166 oldrepocls = unfi.__class__ |
1886
0504e76bfbd9
push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
167 try: |
6270
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
168 class repocls(oldrepocls): |
1886
0504e76bfbd9
push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
169 def branchmap(self): |
0504e76bfbd9
push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
170 usetopic = not self.publishing() |
6271
caf302fb8f4d
topic: use branch//namespace/topic format everywhere except exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6270
diff
changeset
|
171 return super(repocls, self).branchmap(topic=usetopic, convertbm=usetopic) |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
172 |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
173 # Where is branchmaptns method, you might ask? The answer is that |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
174 # this repocls is only relevant when we're trying to use the old |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
175 # branchmap server command. If we use branchmaptns command that was |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
176 # introduced as a part of topic namespaces support, then this |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
177 # repocls shouldn't be used at all. |
6270
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
178 unfi.__class__ = repocls |
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
179 if repo.filtername is not None: |
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
180 repo = unfi.filtered(repo.filtername) |
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
181 else: |
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
182 repo = unfi |
1886
0504e76bfbd9
push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
183 return orig(repo, proto) |
0504e76bfbd9
push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
184 finally: |
6270
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
185 unfi.__class__ = oldrepocls |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
186 |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
187 def wireprotobranchmaptns(repo, proto): |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
188 """copied from wireprotov1server.branchmap()""" |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
189 if not common.hastopicext(repo): |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
190 return wireprotov1server.branchmap(repo, proto) |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
191 heads = [] |
6745
71c4b6c2bcdc
topic: drop branchmap._entries compatibility for hg 4.9
Anton Shestakov <av6@dwimlabs.net>
parents:
6700
diff
changeset
|
192 entries = repo.branchmaptns()._entries |
6573
d511eba4cdb0
topic: compatibility for branchmaptns with branchmap from hg 5.0
Anton Shestakov <av6@dwimlabs.net>
parents:
6566
diff
changeset
|
193 for branch, nodes in compat.branchmapitems(entries): |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
194 branchname = urlreq.quote(encoding.fromlocal(branch)) |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
195 branchnodes = wireprototypes.encodelist(nodes) |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
196 heads.append(b'%s %s' % (branchname, branchnodes)) |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
197 |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
198 return wireprototypes.bytesresponse(b'\n'.join(heads)) |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
199 |
5222
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
200 def _get_branch_name(ctx): |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
201 # make it easy for extension with the branch logic there |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
202 return ctx.branch() |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
203 |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
204 |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
205 def _filter_obsolete_heads(repo, heads): |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
206 """filter heads to return non-obsolete ones |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
207 |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
208 Given a list of heads (on the same named branch) return a new list of heads |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
209 where the obsolete part have been skimmed out. |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
210 """ |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
211 new_heads = [] |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
212 old_heads = heads[:] |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
213 while old_heads: |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
214 rh = old_heads.pop() |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
215 ctx = repo[rh] |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
216 current_name = _get_branch_name(ctx) |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
217 # run this check early to skip the evaluation of the whole branch |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
218 if not ctx.obsolete(): |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
219 new_heads.append(rh) |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
220 continue |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
221 |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
222 # Get all revs/nodes on the branch exclusive to this head |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
223 # (already filtered heads are "ignored")) |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
224 sections_revs = repo.revs( |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
225 b'only(%d, (%ld+%ld))', rh, old_heads, new_heads, |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
226 ) |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
227 keep_revs = [] |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
228 for r in sections_revs: |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
229 ctx = repo[r] |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
230 if ctx.obsolete(): |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
231 continue |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
232 if _get_branch_name(ctx) != current_name: |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
233 continue |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
234 keep_revs.append(r) |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
235 for h in repo.revs(b'heads(%ld and (::%ld))', sections_revs, keep_revs): |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
236 new_heads.append(h) |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
237 new_heads.sort() |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
238 return new_heads |
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
239 |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
240 # Discovery have deficiency around phases, branch can get new heads with pure |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
241 # phases change. This happened with a changeset was allowed to be pushed |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
242 # because it had a topic, but it later become public and create a new branch |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
243 # head. |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
244 # |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
245 # Handle this by doing an extra check for new head creation server side |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
246 def _nbheads(repo): |
6785
cf1e854f50e9
topic: compatibility for scmutil.combined_filtered_and_obsolete_hash()
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
247 filterfn = lambda repo, heads: heads |
cf1e854f50e9
topic: compatibility for scmutil.combined_filtered_and_obsolete_hash()
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
248 if util.safehasattr(scmutil, 'filteredhash'): |
cf1e854f50e9
topic: compatibility for scmutil.combined_filtered_and_obsolete_hash()
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
249 # hg <= 6.7 (a03fa40afd01) |
6823
47c7b5ccabd0
pytype: ignore an error about missing scmutil.filteredhash() on hg 6.8
Anton Shestakov <av6@dwimlabs.net>
parents:
6792
diff
changeset
|
250 code = scmutil.filteredhash.__code__ # pytype: disable=module-attr |
6785
cf1e854f50e9
topic: compatibility for scmutil.combined_filtered_and_obsolete_hash()
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
251 if 'needobsolete' not in code.co_varnames[:code.co_argcount]: |
cf1e854f50e9
topic: compatibility for scmutil.combined_filtered_and_obsolete_hash()
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
252 # hg <= 6.0 (053a5bf508da) |
cf1e854f50e9
topic: compatibility for scmutil.combined_filtered_and_obsolete_hash()
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
253 filterfn = _filter_obsolete_heads |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
254 data = {} |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
255 for b in repo.branchmap().iterbranches(): |
6382
3d0b5b4b262a
topic: make _nbheads() skip branchmap entries that aren't just a branch
Anton Shestakov <av6@dwimlabs.net>
parents:
6369
diff
changeset
|
256 namedbranch, tns, topic = common.parsefqbn(b[0]) |
6487
963471ebe26a
topic: make topic namespace use string "none" as the default/empty value
Anton Shestakov <av6@dwimlabs.net>
parents:
6386
diff
changeset
|
257 if tns != b'none' or topic: |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
258 continue |
5222
ba53591d4aab
head-checking: filter out obsolete heads when checking for new heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
259 oldheads = [repo[n].rev() for n in b[1]] |
6125
885a972d5069
topic: no need to filter obsolete heads in Mercurial 6.1
Anton Shestakov <av6@dwimlabs.net>
parents:
5684
diff
changeset
|
260 newheads = filterfn(repo, oldheads) |
5581
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
261 data[b[0]] = newheads |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
262 return data |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
263 |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
264 def handlecheckheads(orig, op, inpart): |
2675
304232cc14b6
topic: some document for an obscure function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2674
diff
changeset
|
265 """This is used to check for new heads when publishing changeset""" |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
266 orig(op, inpart) |
4542
f5127bfc1588
topic: only wrap handlecheckheads for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4541
diff
changeset
|
267 if not common.hastopicext(op.repo) or op.repo.publishing(): |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
268 return |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
269 tr = op.gettransaction() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4804
diff
changeset
|
270 if tr.hookargs[b'source'] not in (b'push', b'serve'): # not a push |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
271 return |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
272 tr._prepushheads = _nbheads(op.repo) |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
273 reporef = weakref.ref(op.repo) |
1921 | 274 |
5203
034d6d0efa7d
topic: fix compatibility issues caused because of change in transaction API
Pulkit Goyal <7895pulkit@gmail.com>
parents:
5193
diff
changeset
|
275 def _validate(tr): |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
276 repo = reporef() |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
277 if repo is not None: |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
278 repo.invalidatecaches() |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
279 finalheads = _nbheads(repo) |
4742
db3e7f6b5ceb
py3: switch from iteritems() to items() in the topics extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
4544
diff
changeset
|
280 for branch, oldnb in tr._prepushheads.items(): |
5581
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
281 newheads = finalheads.pop(branch, []) |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
282 if len(oldnb) < len(newheads): |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
283 cl = repo.changelog |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
284 newheads = sorted(set(newheads).difference(oldnb)) |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
285 heads = scmutil.nodesummaries(repo, [cl.node(r) for r in newheads]) |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
286 msg = _( |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
287 b"push creates new heads on branch '%s': %s" |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
288 % (branch, heads) |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
289 ) |
6321
58b856416d2e
topic: use compat.StateError for aborting pushes that create new heads
Anton Shestakov <av6@dwimlabs.net>
parents:
6304
diff
changeset
|
290 raise compat.StateError(msg) |
4742
db3e7f6b5ceb
py3: switch from iteritems() to items() in the topics extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
4544
diff
changeset
|
291 for branch, newnb in finalheads.items(): |
5581
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
292 if 1 < len(newnb): |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
293 cl = repo.changelog |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
294 heads = scmutil.nodesummaries(repo, [cl.node(r) for r in newnb]) |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
295 msg = _( |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
296 b"push creates new branch '%s' with multiple heads: %s" |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
297 % (branch, heads) |
36ccafa69095
discovery: list the new heads like core does when failing a multi-head push
Matt Harbison <matt_harbison@yahoo.com>
parents:
5377
diff
changeset
|
298 ) |
5377
a267a7d3e1c5
topic: copy an abort message (new branch) from upstream exactly
Anton Shestakov <av6@dwimlabs.net>
parents:
5376
diff
changeset
|
299 hint = _(b"merge or see 'hg help push' for details about " |
a267a7d3e1c5
topic: copy an abort message (new branch) from upstream exactly
Anton Shestakov <av6@dwimlabs.net>
parents:
5376
diff
changeset
|
300 b"pushing new heads") |
6321
58b856416d2e
topic: use compat.StateError for aborting pushes that create new heads
Anton Shestakov <av6@dwimlabs.net>
parents:
6304
diff
changeset
|
301 raise compat.StateError(msg, hint=hint) |
5203
034d6d0efa7d
topic: fix compatibility issues caused because of change in transaction API
Pulkit Goyal <7895pulkit@gmail.com>
parents:
5193
diff
changeset
|
302 |
6700
a7d94f235488
topic: remove transaction validator compatibility for hg 5.3
Anton Shestakov <av6@dwimlabs.net>
parents:
6667
diff
changeset
|
303 tr.addvalidator(b'000-new-head-check', _validate) |
5203
034d6d0efa7d
topic: fix compatibility issues caused because of change in transaction API
Pulkit Goyal <7895pulkit@gmail.com>
parents:
5193
diff
changeset
|
304 |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
305 handlecheckheads.params = frozenset() |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
306 |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
307 def _pushb2phases(orig, pushop, bundler): |
4543
7f1e1ba3d16b
topic: only wrap _pushb2phases for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4542
diff
changeset
|
308 if common.hastopicext(pushop.repo): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4804
diff
changeset
|
309 checktypes = (b'check:heads', b'check:updated-heads') |
4543
7f1e1ba3d16b
topic: only wrap _pushb2phases for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4542
diff
changeset
|
310 hascheck = any(p.type in checktypes for p in bundler._parts) |
7f1e1ba3d16b
topic: only wrap _pushb2phases for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4542
diff
changeset
|
311 if not hascheck and pushop.outdatedphases: |
7f1e1ba3d16b
topic: only wrap _pushb2phases for repo with topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4542
diff
changeset
|
312 exchange._pushb2ctxcheckheads(pushop, bundler) |
1887
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
313 return orig(pushop, bundler) |
68125d026b07
push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1886
diff
changeset
|
314 |
1903
58cdf061d49a
topic: don't take topic into account when pushing to non-topic repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
315 def wireprotocaps(orig, repo, proto): |
58cdf061d49a
topic: don't take topic into account when pushing to non-topic repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
316 caps = orig(repo, proto) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4804
diff
changeset
|
317 if common.hastopicext(repo) and repo.peer().capable(b'topics'): |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4804
diff
changeset
|
318 caps.append(b'topics') |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
319 caps.append(b'topics-namespaces') |
1903
58cdf061d49a
topic: don't take topic into account when pushing to non-topic repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
320 return caps |
1944
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
321 |
6607
ff2ba083f8b4
topic: drop compatibility for branchinfo(..., changelog=None) for hg 4.8
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
322 def wrapbranchinfo(orig, self, rev): |
6384
afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
Anton Shestakov <av6@dwimlabs.net>
parents:
6383
diff
changeset
|
323 # NOTE: orig can be either branchinfo() or _branchinfo()! |
6607
ff2ba083f8b4
topic: drop compatibility for branchinfo(..., changelog=None) for hg 4.8
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
324 b, close = orig(self, rev) |
6336
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
325 if common.hastopicext(self._repo): |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
326 if self._repo.ui.configbool(b'_internal', b'tns-disable-fqbn'): |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
327 # the config option prevents this function from doing anything, |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
328 # this happens when e.g. the remote repo doesn't have topic |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
329 # extension enabled |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
330 pass |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
331 elif self._repo.ui.configbool(b'_internal', b'tns-publish'): |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
332 # when this rev gets published, only branch will stay |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
333 b = common.formatfqbn(branch=b) |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
334 else: |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
335 ctx = self._repo[rev] |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
336 b = ctx.fqbn() |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
337 return b, close |
453861da6922
topic: use fully qualified branch name during exchange
Anton Shestakov <av6@dwimlabs.net>
parents:
6321
diff
changeset
|
338 |
6607
ff2ba083f8b4
topic: drop compatibility for branchinfo(..., changelog=None) for hg 4.8
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
339 def wrapslowbranchinfo(orig, self, rev): |
6384
afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
Anton Shestakov <av6@dwimlabs.net>
parents:
6383
diff
changeset
|
340 if self.branchinfo == self._branchinfo: |
afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
Anton Shestakov <av6@dwimlabs.net>
parents:
6383
diff
changeset
|
341 # _branchinfo() gets called directly and needs to do the conversion |
6607
ff2ba083f8b4
topic: drop compatibility for branchinfo(..., changelog=None) for hg 4.8
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
342 return wrapbranchinfo(orig, self, rev) |
6384
afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
Anton Shestakov <av6@dwimlabs.net>
parents:
6383
diff
changeset
|
343 else: |
afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
Anton Shestakov <av6@dwimlabs.net>
parents:
6383
diff
changeset
|
344 # _branchinfo() gets called through branchinfo(), the latter will need |
afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
Anton Shestakov <av6@dwimlabs.net>
parents:
6383
diff
changeset
|
345 # to do the conversion |
6607
ff2ba083f8b4
topic: drop compatibility for branchinfo(..., changelog=None) for hg 4.8
Anton Shestakov <av6@dwimlabs.net>
parents:
6573
diff
changeset
|
346 return orig(self, rev) |
6384
afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
Anton Shestakov <av6@dwimlabs.net>
parents:
6383
diff
changeset
|
347 |
6546
30d0d3d92c8d
topic: properly process revbranchcache before sending it to peers (issue6841)
Anton Shestakov <av6@dwimlabs.net>
parents:
6386
diff
changeset
|
348 def wrapaddpartrevbranchcache(orig, repo, bundler, outgoing): |
30d0d3d92c8d
topic: properly process revbranchcache before sending it to peers (issue6841)
Anton Shestakov <av6@dwimlabs.net>
parents:
6386
diff
changeset
|
349 """making sure we send rev-branch-cache that only has bare branches""" |
30d0d3d92c8d
topic: properly process revbranchcache before sending it to peers (issue6841)
Anton Shestakov <av6@dwimlabs.net>
parents:
6386
diff
changeset
|
350 overrides = {(b'_internal', b'tns-disable-fqbn'): True} |
30d0d3d92c8d
topic: properly process revbranchcache before sending it to peers (issue6841)
Anton Shestakov <av6@dwimlabs.net>
parents:
6386
diff
changeset
|
351 with repo.ui.configoverride(overrides, b'topic-namespaces'): |
30d0d3d92c8d
topic: properly process revbranchcache before sending it to peers (issue6841)
Anton Shestakov <av6@dwimlabs.net>
parents:
6386
diff
changeset
|
352 orig(repo, bundler, outgoing) |
30d0d3d92c8d
topic: properly process revbranchcache before sending it to peers (issue6841)
Anton Shestakov <av6@dwimlabs.net>
parents:
6386
diff
changeset
|
353 |
6564
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6563
diff
changeset
|
354 def wraphgpeer(orig, uiorrepo, opts, *args, **kwargs): |
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6563
diff
changeset
|
355 """hg.peer() that checks if there are explicit arguments for e.g. pull""" |
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6563
diff
changeset
|
356 peer = orig(uiorrepo, opts, *args, **kwargs) |
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6563
diff
changeset
|
357 if any(opts.get(k) for k in (b'rev', b'bookmark', b'branch')): |
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6563
diff
changeset
|
358 peer.ui.setconfig(b'_internal', b'tns-explicit-target', True, b'topic-namespaces') |
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6563
diff
changeset
|
359 return peer |
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6563
diff
changeset
|
360 |
6563
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
361 def wraphgremoteui(orig, src, opts): |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
362 """hg.remoteui() that copies tns-related config options to peer ui""" |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
363 dst = orig(src, opts) |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
364 if util.safehasattr(src, 'baseui'): # looks like a repository |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
365 src = src.ui |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
366 # we need to copy topic namespaces from local config to peer ui, since it |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
367 # needs to be accessible for peer command executors |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
368 namespaces = src.configlist(b'experimental', b'tns-default-pull-namespaces', [b'*']) |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
369 dst.setconfig(b'experimental', b'tns-default-pull-namespaces', namespaces, b'copied') |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
370 return dst |
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
371 |
1944
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
372 def modsetup(ui): |
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
373 """run at uisetup time to install all destinations wrapping""" |
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
374 extensions.wrapfunction(discovery, '_headssummary', _headssummary) |
5180
515d425c0a05
compat: drop 4.5 related compatibility around wireprotocol module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
375 extensions.wrapfunction(wireprotov1server, 'branchmap', wireprotobranchmap) |
6270
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
376 wireprotov1server.commands.pop(b'branchmap') |
00d1551bfa8c
topic: actually wrap branchmap wire-protocol command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
6125
diff
changeset
|
377 wireprotov1server.wireprotocommand(b'branchmap', permission=b'pull')(wireprotov1server.branchmap) |
5180
515d425c0a05
compat: drop 4.5 related compatibility around wireprotocol module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5041
diff
changeset
|
378 extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps) |
6383
c6e3d2dbbeb0
topic: simply reuse wirepeer.branchmap() as wirepeer.branchmaptns()
Anton Shestakov <av6@dwimlabs.net>
parents:
6382
diff
changeset
|
379 wirepeer.branchmaptns = wirepeer.branchmap |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6295
diff
changeset
|
380 wireprotov1server.wireprotocommand(b'branchmaptns', permission=b'pull')(wireprotobranchmaptns) |
6890
7ec9f4b04519
topic: compatibility for revbranchcache being in a separate module now
Anton Shestakov <av6@dwimlabs.net>
parents:
6786
diff
changeset
|
381 extensions.wrapfunction(revbranchcache, 'branchinfo', wrapbranchinfo) |
6384
afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
Anton Shestakov <av6@dwimlabs.net>
parents:
6383
diff
changeset
|
382 # branchinfo method can get replaced by _branchinfo method directly when |
afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
Anton Shestakov <av6@dwimlabs.net>
parents:
6383
diff
changeset
|
383 # on-disk revbranchcache is not available, see revbranchcache.__init__() |
6890
7ec9f4b04519
topic: compatibility for revbranchcache being in a separate module now
Anton Shestakov <av6@dwimlabs.net>
parents:
6786
diff
changeset
|
384 extensions.wrapfunction(revbranchcache, '_branchinfo', wrapslowbranchinfo) |
2676
10dedac0d82e
topic: also insert the extra head check with using the new head checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2675
diff
changeset
|
385 # we need a proper wrap b2 part stuff |
1944
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
386 extensions.wrapfunction(bundle2, 'handlecheckheads', handlecheckheads) |
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
387 bundle2.handlecheckheads.params = frozenset() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4804
diff
changeset
|
388 bundle2.parthandlermapping[b'check:heads'] = bundle2.handlecheckheads |
2676
10dedac0d82e
topic: also insert the extra head check with using the new head checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2675
diff
changeset
|
389 if util.safehasattr(bundle2, 'handlecheckupdatedheads'): |
10dedac0d82e
topic: also insert the extra head check with using the new head checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2675
diff
changeset
|
390 # we still need a proper wrap b2 part stuff |
10dedac0d82e
topic: also insert the extra head check with using the new head checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2675
diff
changeset
|
391 extensions.wrapfunction(bundle2, 'handlecheckupdatedheads', handlecheckheads) |
10dedac0d82e
topic: also insert the extra head check with using the new head checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2675
diff
changeset
|
392 bundle2.handlecheckupdatedheads.params = frozenset() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4804
diff
changeset
|
393 bundle2.parthandlermapping[b'check:updated-heads'] = bundle2.handlecheckupdatedheads |
6546
30d0d3d92c8d
topic: properly process revbranchcache before sending it to peers (issue6841)
Anton Shestakov <av6@dwimlabs.net>
parents:
6386
diff
changeset
|
394 extensions.wrapfunction(bundle2, 'addpartrevbranchcache', wrapaddpartrevbranchcache) |
1944
daad8249d5cf
discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1934
diff
changeset
|
395 extensions.wrapfunction(exchange, '_pushb2phases', _pushb2phases) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4804
diff
changeset
|
396 exchange.b2partsgenmapping[b'phase'] = exchange._pushb2phases |
6564
2d3771d61068
topic: use a config option to signal explicit target arguments (for tns)
Anton Shestakov <av6@dwimlabs.net>
parents:
6563
diff
changeset
|
397 extensions.wrapfunction(hg, 'peer', wraphgpeer) |
6563
bdc8978232de
topic: copy experimental.tns-default-pull-namespaces to remote peer ui
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
398 extensions.wrapfunction(hg, 'remoteui', wraphgremoteui) |