annotate mercurial/discovery.py @ 51663:11f41248595b stable 6.8

relnotes: add 6.8
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 08 Jul 2024 17:51:04 +0200
parents 3a6fae3bef35
children f4733654f144
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11313
0bb14798cd07 discovery: fix description line
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11301
diff changeset
1 # discovery.py - protocol changeset discovery functions
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
2 #
46819
d4ba4d51f85f contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents: 46780
diff changeset
3 # Copyright 2010 Olivia Mackall <olivia@selenic.com>
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
4 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8210
diff changeset
5 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9954
diff changeset
6 # GNU General Public License version 2 or any later version.
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
7
25944
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
8
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
9 import functools
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
10
25944
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
11 from .i18n import _
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
12 from .node import (
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
13 hex,
25944
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
14 short,
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
15 )
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
16
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
17 from . import (
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
18 bookmarks,
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
19 branchmap,
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26585
diff changeset
20 error,
51594
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
21 node as nodemod,
48688
053a5bf508da discovery: port _postprocessobsolete() changes from evolve, add tests
Anton Shestakov <av6@dwimlabs.net>
parents: 48530
diff changeset
22 obsolete,
25944
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
23 phases,
43106
d783f945a701 py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43077
diff changeset
24 pycompat,
35184
bc775b8cc020 scmutil: extra utility to display a reasonable amount of nodes
Boris Feld <boris.feld@octobus.net>
parents: 32792
diff changeset
25 scmutil,
25944
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
26 setdiscovery,
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
27 treediscovery,
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
28 util,
337d010f31e6 discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24702
diff changeset
29 )
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 8108
diff changeset
30
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
31
35305
483b5dd0f1aa push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents: 35184
diff changeset
32 def findcommonincoming(repo, remote, heads=None, force=False, ancestorsof=None):
14073
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
33 """Return a tuple (common, anyincoming, heads) used to identify the common
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
34 subset of nodes between repo and remote.
2601
00fc88b0b256 move most of tag code to localrepository class.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2581
diff changeset
35
14073
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
36 "common" is a list of (at least) the heads of the common subset.
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
37 "anyincoming" is testable as a boolean indicating if any nodes are missing
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
38 locally. If remote does not support getbundle, this actually is a list of
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
39 roots of the nodes that would be incoming, to be supplied to
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
40 changegroupsubset. No code except for pull should be relying on this fact
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
41 any longer.
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
42 "heads" is either the supplied heads, or else the remote's heads.
35305
483b5dd0f1aa push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents: 35184
diff changeset
43 "ancestorsof" if not None, restrict the discovery to a subset defined by
45142
75f6491b66a7 discovery: weaken claim about returned common heads if ancestorsof are given
Manuel Jacob <me@manueljacob.de>
parents: 44729
diff changeset
44 these nodes. Changeset outside of this set won't be considered (but may
75f6491b66a7 discovery: weaken claim about returned common heads if ancestorsof are given
Manuel Jacob <me@manueljacob.de>
parents: 44729
diff changeset
45 still appear in "common").
14164
cb98fed52495 discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14073
diff changeset
46
17424
e7cfe3587ea4 fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents: 17254
diff changeset
47 If you pass heads and they are all known locally, the response lists just
14164
cb98fed52495 discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14073
diff changeset
48 these heads in "common" and in "heads".
14213
30273f0c776b discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14184
diff changeset
49
30273f0c776b discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14184
diff changeset
50 Please use findcommonoutgoing to compute the set of outgoing nodes to give
30273f0c776b discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14184
diff changeset
51 extensions a good hook into outgoing.
11301
3d0591a66118 move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11230
diff changeset
52 """
14073
72c84f24b420 discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13742
diff changeset
53
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
54 if not remote.capable(b'getbundle'):
14164
cb98fed52495 discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14073
diff changeset
55 return treediscovery.findcommonincoming(repo, remote, heads, force)
1806
a2c69737e65e Automatic nesting into running transactions in the same repository.
mason@suse.com
parents: 1802
diff changeset
56
14164
cb98fed52495 discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14073
diff changeset
57 if heads:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
58 knownnode = repo.changelog.hasnode # no nodemap until it is filtered
35879
6c1d3779c052 discovery: don't reimplement all()
Martin von Zweigbergk <martinvonz@google.com>
parents: 35849
diff changeset
59 if all(knownnode(h) for h in heads):
14164
cb98fed52495 discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14073
diff changeset
60 return (heads, False, heads)
8404
a2bc39ade36b commit: move 'nothing changed' test into commit()
Matt Mackall <mpm@selenic.com>
parents: 8403
diff changeset
61
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
62 res = setdiscovery.findcommonheads(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
63 repo.ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
64 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
65 remote,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
66 abortwhenunrelated=not force,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
67 ancestorsof=ancestorsof,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
68 )
14164
cb98fed52495 discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14073
diff changeset
69 common, anyinc, srvheads = res
44667
b561f3a68e41 discovery: avoid wrongly saying there are nothing to pull
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44450
diff changeset
70 if heads and not anyinc:
b561f3a68e41 discovery: avoid wrongly saying there are nothing to pull
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44450
diff changeset
71 # server could be lying on the advertised heads
b561f3a68e41 discovery: avoid wrongly saying there are nothing to pull
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44450
diff changeset
72 has_node = repo.changelog.hasnode
b561f3a68e41 discovery: avoid wrongly saying there are nothing to pull
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44450
diff changeset
73 anyinc = any(not has_node(n) for n in heads)
14164
cb98fed52495 discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14073
diff changeset
74 return (list(common), anyinc, heads or list(srvheads))
11301
3d0591a66118 move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11230
diff changeset
75
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
76
48946
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48913
diff changeset
77 class outgoing:
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
78 """Represents the result of a findcommonoutgoing() call.
15837
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
79
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
80 Members:
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
81
45143
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
82 ancestorsof is a list of the nodes whose ancestors are included in the
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
83 outgoing operation.
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
84
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
85 missing is a list of those ancestors of ancestorsof that are present in
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
86 local but not in remote.
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
87
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
88 common is a set containing revs common between the local and the remote
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
89 repository (at least all of those that are ancestors of ancestorsof).
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
90
15837
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
91 commonheads is the list of heads of common.
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
92
45143
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
93 excluded is the list of missing changeset that shouldn't be sent
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
94 remotely.
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
95
5631b0116374 discovery: fix docstring of `outgoing` class
Manuel Jacob <me@manueljacob.de>
parents: 45142
diff changeset
96 Some members are computed on demand from the heads, unless provided upfront
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
97 by discovery."""
15837
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
98
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
99 def __init__(
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
100 self, repo, commonheads=None, ancestorsof=None, missingroots=None
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
101 ):
51594
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
102 # at most one of them must not be set
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
103 if commonheads is not None and missingroots is not None:
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
104 m = 'commonheads and missingroots arguments are mutually exclusive'
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
105 raise error.ProgrammingError(m)
29805
f09d0004481c outgoing: adds some default value for argument
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29804
diff changeset
106 cl = repo.changelog
51595
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
107 unfi = repo.unfiltered()
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
108 ucl = unfi.changelog
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
109 to_node = ucl.node
51594
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
110 missing = None
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
111 common = None
51595
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
112 arg_anc = ancestorsof
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
113 if ancestorsof is None:
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
114 ancestorsof = cl.heads()
51595
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
115
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
116 # XXX-perf: do we need all this to be node-list? They would be simpler
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
117 # as rev-num sets (and smartset)
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
118 if missingroots == [nodemod.nullrev] or missingroots == []:
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
119 commonheads = [repo.nullid]
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
120 common = set()
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
121 if arg_anc is None:
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
122 missing = [to_node(r) for r in cl]
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
123 else:
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
124 missing_rev = repo.revs('::%ln', missingroots, ancestorsof)
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
125 missing = [to_node(r) for r in missing_rev]
3a6fae3bef35 outgoing: add a simple fastpath when there is no common
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51594
diff changeset
126 elif missingroots is not None:
29806
82e8c86cdd6d outgoing: add a 'missingroots' argument
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29805
diff changeset
127 # TODO remove call to nodesbetween.
51594
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
128 missing_rev = repo.revs('%ln::%ln', missingroots, ancestorsof)
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
129 ancestorsof = [to_node(r) for r in ucl.headrevs(missing_rev)]
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
130 parent_revs = ucl.parentrevs
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
131 common_legs = set()
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
132 for r in missing_rev:
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
133 p1, p2 = parent_revs(r)
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
134 if p1 not in missing_rev:
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
135 common_legs.add(p1)
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
136 if p2 not in missing_rev:
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
137 common_legs.add(p2)
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
138 common_legs.discard(nodemod.nullrev)
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
139 if not common_legs:
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
140 commonheads = [repo.nullid]
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
141 common = set()
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
142 else:
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
143 commonheads_revs = unfi.revs(
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
144 'heads(%ld::%ld)',
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
145 common_legs,
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
146 common_legs,
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
147 )
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
148 commonheads = [to_node(r) for r in commonheads_revs]
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
149 common = ucl.ancestors(commonheads_revs, inclusive=True)
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
150 missing = [to_node(r) for r in missing_rev]
29806
82e8c86cdd6d outgoing: add a 'missingroots' argument
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29805
diff changeset
151 elif not commonheads:
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46819
diff changeset
152 commonheads = [repo.nullid]
15837
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
153 self.commonheads = commonheads
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
154 self.ancestorsof = ancestorsof
29805
f09d0004481c outgoing: adds some default value for argument
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29804
diff changeset
155 self._revlog = cl
51594
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
156 self._common = common
e3a5ec2d236a outgoing: rework the handling of the `missingroots` case to be faster
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51580
diff changeset
157 self._missing = missing
15838
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
158 self.excluded = []
15837
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
159
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
160 def _computecommonmissing(self):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
161 sets = self._revlog.findcommonmissing(
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
162 self.commonheads, self.ancestorsof
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
163 )
15837
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
164 self._common, self._missing = sets
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
165
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
166 @util.propertycache
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
167 def common(self):
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
168 if self._common is None:
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
169 self._computecommonmissing()
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
170 return self._common
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
171
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
172 @util.propertycache
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
173 def missing(self):
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
174 if self._missing is None:
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
175 self._computecommonmissing()
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
176 return self._missing
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
177
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
178
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
179 def findcommonoutgoing(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
180 repo, other, onlyheads=None, force=False, commoninc=None, portable=False
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
181 ):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
182 """Return an outgoing instance to identify the nodes present in repo but
15837
cd956049fc14 discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15713
diff changeset
183 not in other.
14213
30273f0c776b discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14184
diff changeset
184
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16657
diff changeset
185 If onlyheads is given, only nodes ancestral to nodes in onlyheads
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16657
diff changeset
186 (inclusive) are included. If you already know the local repo's heads,
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16657
diff changeset
187 passing them in onlyheads is faster than letting them be recomputed here.
14213
30273f0c776b discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14184
diff changeset
188
17251
98166640b356 help: fix some instances of 'the the'
Mads Kiilerich <mads@kiilerich.com>
parents: 17248
diff changeset
189 If commoninc is given, it must be the result of a prior call to
16736
025b3b763ba9 bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents: 16535
diff changeset
190 findcommonincoming(repo, other, force) to avoid recomputing it here.
025b3b763ba9 bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents: 16535
diff changeset
191
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
192 If portable is given, compute more conservative common and ancestorsof,
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
193 to make bundles created from the instance more portable."""
15838
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
194 # declare an empty outgoing object to be filled later
29804
7b9157aa752f outgoing: pass a repo object to the constructor
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29690
diff changeset
195 og = outgoing(repo, None, None)
15838
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
196
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
197 # get common set if not provided
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
198 if commoninc is None:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
199 commoninc = findcommonincoming(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
200 repo, other, force=force, ancestorsof=onlyheads
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
201 )
15838
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
202 og.commonheads, _any, _hds = commoninc
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
203
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
204 # compute outgoing
51402
2e10ddbb9faa phases: check secret presence the right way during discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50393
diff changeset
205 mayexclude = phases.hassecret(repo) or repo.obsstore
17206
70ebb4bd8083 obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17205
diff changeset
206 if not mayexclude:
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
207 og.ancestorsof = onlyheads or repo.heads()
15838
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
208 elif onlyheads is None:
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
209 # use visible heads as it should be cached
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
210 og.ancestorsof = repo.filtered(b"served").heads()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
211 og.excluded = [ctx.node() for ctx in repo.set(b'secret() or extinct()')]
15838
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
212 else:
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
213 # compute common, missing and exclude secret stuff
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
214 sets = repo.changelog.findcommonmissing(og.commonheads, onlyheads)
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
215 og._common, allmissing = sets
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
216 og._missing = missing = []
15951
bd84fc0b5f64 phases: properly register excluded changeset when revision are specified
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15932
diff changeset
217 og.excluded = excluded = []
15838
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
218 for node in allmissing:
17206
70ebb4bd8083 obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17205
diff changeset
219 ctx = repo[node]
17248
6ffb35b2284c discovery: add extinct changesets to outgoing.excluded
Patrick Mezard <patrick@mezard.eu>
parents: 17214
diff changeset
220 if ctx.phase() >= phases.secret or ctx.extinct():
6ffb35b2284c discovery: add extinct changesets to outgoing.excluded
Patrick Mezard <patrick@mezard.eu>
parents: 17214
diff changeset
221 excluded.append(node)
6ffb35b2284c discovery: add extinct changesets to outgoing.excluded
Patrick Mezard <patrick@mezard.eu>
parents: 17214
diff changeset
222 else:
6ffb35b2284c discovery: add extinct changesets to outgoing.excluded
Patrick Mezard <patrick@mezard.eu>
parents: 17214
diff changeset
223 missing.append(node)
17206
70ebb4bd8083 obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17205
diff changeset
224 if len(missing) == len(allmissing):
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
225 ancestorsof = onlyheads
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
226 else: # update missing heads
51580
b70628a9aa7e phases: use revision number in new_heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51402
diff changeset
227 to_rev = repo.changelog.index.rev
b70628a9aa7e phases: use revision number in new_heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51402
diff changeset
228 to_node = repo.changelog.node
b70628a9aa7e phases: use revision number in new_heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51402
diff changeset
229 excluded_revs = [to_rev(r) for r in excluded]
b70628a9aa7e phases: use revision number in new_heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51402
diff changeset
230 onlyheads_revs = [to_rev(r) for r in onlyheads]
b70628a9aa7e phases: use revision number in new_heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51402
diff changeset
231 new_heads = phases.new_heads(repo, onlyheads_revs, excluded_revs)
b70628a9aa7e phases: use revision number in new_heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51402
diff changeset
232 ancestorsof = [to_node(r) for r in new_heads]
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
233 og.ancestorsof = ancestorsof
16736
025b3b763ba9 bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents: 16535
diff changeset
234 if portable:
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
235 # recompute common and ancestorsof as if -r<rev> had been given for
16736
025b3b763ba9 bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents: 16535
diff changeset
236 # each head of missing, and --base <rev> for each head of the proper
025b3b763ba9 bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents: 16535
diff changeset
237 # ancestors of missing
025b3b763ba9 bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents: 16535
diff changeset
238 og._computecommonmissing()
025b3b763ba9 bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents: 16535
diff changeset
239 cl = repo.changelog
44452
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44306
diff changeset
240 missingrevs = {cl.rev(n) for n in og._missing}
16866
91f3ac205816 revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents: 16835
diff changeset
241 og._common = set(cl.ancestors(missingrevs)) - missingrevs
16736
025b3b763ba9 bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents: 16535
diff changeset
242 commonheads = set(og.commonheads)
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
243 og.ancestorsof = [h for h in og.ancestorsof if h not in commonheads]
16736
025b3b763ba9 bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents: 16535
diff changeset
244
15838
7299e09a85a2 phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15837
diff changeset
245 return og
14213
30273f0c776b discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 14184
diff changeset
246
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
247
32706
993f58db2045 headssummary: directly feed the function with the 'pushop' object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32705
diff changeset
248 def _headssummary(pushop):
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
249 """compute a summary of branch and heads status before and after push
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
250
32708
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
251 return {'branch': ([remoteheads], [newheads],
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
252 [unsyncedheads], [discardedheads])} mapping
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
253
32708
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
254 - branch: the branch name,
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
255 - remoteheads: the list of remote heads known locally
32708
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
256 None if the branch is new,
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
257 - newheads: the new remote heads (known locally) with outgoing pushed,
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
258 - unsyncedheads: the list of remote heads unknown locally,
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
259 - discardedheads: the list of heads made obsolete by the push.
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
260 """
32706
993f58db2045 headssummary: directly feed the function with the 'pushop' object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32705
diff changeset
261 repo = pushop.repo.unfiltered()
993f58db2045 headssummary: directly feed the function with the 'pushop' object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32705
diff changeset
262 remote = pushop.remote
993f58db2045 headssummary: directly feed the function with the 'pushop' object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32705
diff changeset
263 outgoing = pushop.outgoing
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
264 cl = repo.changelog
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
265 headssum = {}
42026
98908e36d58a discovery: prevent recomputing info about server and outgoing changesets
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 41566
diff changeset
266 missingctx = set()
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
267 # A. Create set of branches involved in the push.
42026
98908e36d58a discovery: prevent recomputing info about server and outgoing changesets
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 41566
diff changeset
268 branches = set()
98908e36d58a discovery: prevent recomputing info about server and outgoing changesets
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 41566
diff changeset
269 for n in outgoing.missing:
98908e36d58a discovery: prevent recomputing info about server and outgoing changesets
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 41566
diff changeset
270 ctx = repo[n]
98908e36d58a discovery: prevent recomputing info about server and outgoing changesets
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 41566
diff changeset
271 missingctx.add(ctx)
98908e36d58a discovery: prevent recomputing info about server and outgoing changesets
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 41566
diff changeset
272 branches.add(ctx.branch())
37637
1964d2d1f421 discovery: use command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37636
diff changeset
273
1964d2d1f421 discovery: use command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37636
diff changeset
274 with remote.commandexecutor() as e:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
275 remotemap = e.callcommand(b'branchmap', {}).result()
37637
1964d2d1f421 discovery: use command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37636
diff changeset
276
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
277 knownnode = cl.hasnode # do not use nodemap until it is filtered
42028
0cc9d7918754 discovery: prevent deleting items from a dictionary
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42027
diff changeset
278 # A. register remote heads of branches which are in outgoing set
48913
f254fc73d956 global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
279 for branch, heads in remotemap.items():
42028
0cc9d7918754 discovery: prevent deleting items from a dictionary
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42027
diff changeset
280 # don't add head info about branches which we don't have locally
0cc9d7918754 discovery: prevent deleting items from a dictionary
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42027
diff changeset
281 if branch not in branches:
0cc9d7918754 discovery: prevent deleting items from a dictionary
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42027
diff changeset
282 continue
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
283 known = []
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
284 unsynced = []
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
285 for h in heads:
20225
d2704c48f417 discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 20184
diff changeset
286 if knownnode(h):
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
287 known.append(h)
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
288 else:
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
289 unsynced.append(h)
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
290 headssum[branch] = (known, list(known), unsynced)
42028
0cc9d7918754 discovery: prevent deleting items from a dictionary
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42027
diff changeset
291
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
292 # B. add new branch data
42027
d36a7da96a5a discovery: drop some unused sets
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42026
diff changeset
293 for branch in branches:
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
294 if branch not in headssum:
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
295 headssum[branch] = (None, [], [])
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
296
42028
0cc9d7918754 discovery: prevent deleting items from a dictionary
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42027
diff changeset
297 # C. Update newmap with outgoing changes.
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
298 # This will possibly add new heads and remove existing ones.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
299 newmap = branchmap.remotebranchcache(
46780
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46119
diff changeset
300 repo,
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46119
diff changeset
301 (
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46119
diff changeset
302 (branch, heads[1])
48913
f254fc73d956 global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
303 for branch, heads in headssum.items()
46780
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46119
diff changeset
304 if heads[0] is not None
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46119
diff changeset
305 ),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
306 )
18305
2502a15e033d branchmap: pass revision insteads of changectx to the update function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18284
diff changeset
307 newmap.update(repo, (ctx.rev() for ctx in missingctx))
48913
f254fc73d956 global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
308 for branch, newheads in newmap.items():
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
309 headssum[branch][1][:] = newheads
48913
f254fc73d956 global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
310 for branch, items in headssum.items():
32672
315d74d0f059 headssummary: ensure all returned lists are sorted
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32671
diff changeset
311 for l in items:
315d74d0f059 headssummary: ensure all returned lists are sorted
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32671
diff changeset
312 if l is not None:
315d74d0f059 headssummary: ensure all returned lists are sorted
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32671
diff changeset
313 l.sort()
32708
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
314 headssum[branch] = items + ([],)
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
315
32707
32c8f98aebf4 checkheads: perform obsolescence post processing directly in _headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32706
diff changeset
316 # If there are no obsstore, no post processing are needed.
32c8f98aebf4 checkheads: perform obsolescence post processing directly in _headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32706
diff changeset
317 if repo.obsstore:
32791
1cb14923dee9 checkheads: use "revnum" in the "allfuturecommon" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32790
diff changeset
318 torev = repo.changelog.rev
45144
c93dd9d9f1e6 discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents: 45143
diff changeset
319 futureheads = {torev(h) for h in outgoing.ancestorsof}
44452
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44306
diff changeset
320 futureheads |= {torev(h) for h in outgoing.commonheads}
32792
4374e88e808c checkheads: use a "lazyancestors" object for allfuturecommon
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32791
diff changeset
321 allfuturecommon = repo.changelog.ancestors(futureheads, inclusive=True)
43106
d783f945a701 py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43077
diff changeset
322 for branch, heads in sorted(pycompat.iteritems(headssum)):
32708
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
323 remoteheads, newheads, unsyncedheads, placeholder = heads
32707
32c8f98aebf4 checkheads: perform obsolescence post processing directly in _headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32706
diff changeset
324 result = _postprocessobsolete(pushop, allfuturecommon, newheads)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
325 headssum[branch] = (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
326 remoteheads,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
327 sorted(result[0]),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
328 unsyncedheads,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
329 sorted(result[1]),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
330 )
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
331 return headssum
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
332
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
333
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
334 def _oldheadssummary(repo, remoteheads, outgoing, inc=False):
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
335 """Compute branchmapsummary for repo without branchmap support"""
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
336
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
337 # 1-4b. old servers: Check for new topological heads.
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
338 # Construct {old,new}map with branch = None (topological branch).
18120
88990d3e3d75 branchmap: extract _updatebranchcache from repo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18104
diff changeset
339 # (code based on update)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
340 knownnode = repo.changelog.hasnode # no nodemap until it is filtered
32672
315d74d0f059 headssummary: ensure all returned lists are sorted
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32671
diff changeset
341 oldheads = sorted(h for h in remoteheads if knownnode(h))
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
342 # all nodes in outgoing.missing are children of either:
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
343 # - an element of oldheads
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
344 # - another element of outgoing.missing
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
345 # - nullrev
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
346 # This explains why the new head are very simple to compute.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
347 r = repo.set(b'heads(%ln + %ln)', oldheads, outgoing.missing)
32672
315d74d0f059 headssummary: ensure all returned lists are sorted
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32671
diff changeset
348 newheads = sorted(c.node() for c in r)
22178
70383c6961b4 discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21580
diff changeset
349 # set some unsynced head to issue the "unsynced changes" warning
24306
6ddc86eedc3b style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 22178
diff changeset
350 if inc:
32671
81cbfaea1e0f discovery: also use lists for the returns of '_oldheadssummary'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32331
diff changeset
351 unsynced = [None]
24306
6ddc86eedc3b style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 22178
diff changeset
352 else:
32671
81cbfaea1e0f discovery: also use lists for the returns of '_oldheadssummary'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32331
diff changeset
353 unsynced = []
32708
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
354 return {None: (oldheads, newheads, unsynced, [])}
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
355
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
356
26936
d47ac02fcefa discovery: pass pushop to _nowarnheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26935
diff changeset
357 def _nowarnheads(pushop):
26862
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
358 # Compute newly pushed bookmarks. We don't warn about bookmarked heads.
26936
d47ac02fcefa discovery: pass pushop to _nowarnheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26935
diff changeset
359 repo = pushop.repo.unfiltered()
d47ac02fcefa discovery: pass pushop to _nowarnheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26935
diff changeset
360 remote = pushop.remote
26862
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
361 localbookmarks = repo._bookmarks
37637
1964d2d1f421 discovery: use command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37636
diff changeset
362
1964d2d1f421 discovery: use command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37636
diff changeset
363 with remote.commandexecutor() as e:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
364 remotebookmarks = e.callcommand(
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
365 b'listkeys',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
366 {
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
367 b'namespace': b'bookmarks',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
368 },
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
369 ).result()
37637
1964d2d1f421 discovery: use command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37636
diff changeset
370
26862
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
371 bookmarkedheads = set()
29229
89bba2beb03e bookmarks: allow pushing active bookmark on new remote head (issue5236)
liscju <piotr.listkiewicz@gmail.com>
parents: 26936
diff changeset
372
89bba2beb03e bookmarks: allow pushing active bookmark on new remote head (issue5236)
liscju <piotr.listkiewicz@gmail.com>
parents: 26936
diff changeset
373 # internal config: bookmarks.pushing
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
374 newbookmarks = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
375 localbookmarks.expandname(b)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
376 for b in pushop.ui.configlist(b'bookmarks', b'pushing')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
377 ]
29229
89bba2beb03e bookmarks: allow pushing active bookmark on new remote head (issue5236)
liscju <piotr.listkiewicz@gmail.com>
parents: 26936
diff changeset
378
26862
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
379 for bm in localbookmarks:
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
380 rnode = remotebookmarks.get(bm)
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
381 if rnode and rnode in repo:
42978
e3bb2a58af1e bookmarks: remove changectx() method from bmstore (API)
Augie Fackler <augie@google.com>
parents: 42216
diff changeset
382 lctx, rctx = repo[localbookmarks[bm]], repo[rnode]
26862
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
383 if bookmarks.validdest(repo, rctx, lctx):
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
384 bookmarkedheads.add(lctx.node())
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
385 else:
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
386 if bm in newbookmarks and bm not in remotebookmarks:
37451
444ed53f93df discovery: look up bookmarks only among bookmarks
Martin von Zweigbergk <martinvonz@google.com>
parents: 36715
diff changeset
387 bookmarkedheads.add(localbookmarks[bm])
26862
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
388
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
389 return bookmarkedheads
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
390
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
391
26935
c4a7bbc78c74 exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26862
diff changeset
392 def checkheads(pushop):
15932
4154338f0bc0 discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15893
diff changeset
393 """Check that a push won't add any outgoing head
3684
975c2469c316 correct remote heads test in prepush
Matt Mackall <mpm@selenic.com>
parents: 3682
diff changeset
394
46119
9261f6c1d39b errors: raise StateError when push fails because it creates new heads
Martin von Zweigbergk <martinvonz@google.com>
parents: 45942
diff changeset
395 raise StateError error and display ui message as needed.
15932
4154338f0bc0 discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15893
diff changeset
396 """
26935
c4a7bbc78c74 exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26862
diff changeset
397
c4a7bbc78c74 exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26862
diff changeset
398 repo = pushop.repo.unfiltered()
c4a7bbc78c74 exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26862
diff changeset
399 remote = pushop.remote
c4a7bbc78c74 exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26862
diff changeset
400 outgoing = pushop.outgoing
c4a7bbc78c74 exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26862
diff changeset
401 remoteheads = pushop.remoteheads
c4a7bbc78c74 exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26862
diff changeset
402 newbranch = pushop.newbranch
c4a7bbc78c74 exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26862
diff changeset
403 inc = bool(pushop.incoming)
c4a7bbc78c74 exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26862
diff changeset
404
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
405 # Check for each named branch if we're creating new remote heads.
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
406 # To be a remote head after push, node must be either:
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
407 # - unknown locally
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
408 # - a local outgoing head descended from update
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
409 # - a remote head that's known locally and not
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
410 # ancestral to an outgoing head
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46819
diff changeset
411 if remoteheads == [repo.nullid]:
15932
4154338f0bc0 discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15893
diff changeset
412 # remote is empty, nothing to check.
4154338f0bc0 discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15893
diff changeset
413 return
2439
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2424
diff changeset
414
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
415 if remote.capable(b'branchmap'):
32706
993f58db2045 headssummary: directly feed the function with the 'pushop' object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32705
diff changeset
416 headssum = _headssummary(pushop)
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
417 else:
17211
4f321eecbf8d checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17209
diff changeset
418 headssum = _oldheadssummary(repo, remoteheads, outgoing, inc)
32709
16ada4cbb1a9 push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32708
diff changeset
419 pushop.pushbranchmap = headssum
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
420 newbranches = [
48913
f254fc73d956 global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
421 branch for branch, heads in headssum.items() if heads[0] is None
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
422 ]
17209
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
423 # 1. Check for new branches on the remote.
5cd3e526ac37 checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17206
diff changeset
424 if newbranches and not newbranch: # new branch requires --new-branch
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
425 branchnames = b', '.join(sorted(newbranches))
42216
d0e773ad9077 discovery: only calculate closed branches if required
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42203
diff changeset
426 # Calculate how many of the new branches are closed branches
d0e773ad9077 discovery: only calculate closed branches if required
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42203
diff changeset
427 closedbranches = set()
d0e773ad9077 discovery: only calculate closed branches if required
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42203
diff changeset
428 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
d0e773ad9077 discovery: only calculate closed branches if required
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42203
diff changeset
429 if isclosed:
d0e773ad9077 discovery: only calculate closed branches if required
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42203
diff changeset
430 closedbranches.add(tag)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
431 closedbranches = closedbranches & set(newbranches)
42203
5997eabc7b85 push: added clear warning message when pushing closed branches(issue6080)
Taapas Agrawal <taapas2897@gmail.com>
parents: 42029
diff changeset
432 if closedbranches:
45908
122f0b59f5f0 errors: remove trailing "!" in messages about creating new heads on push
Martin von Zweigbergk <martinvonz@google.com>
parents: 45144
diff changeset
433 errmsg = _(b"push creates new remote branches: %s (%d closed)") % (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
434 branchnames,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
435 len(closedbranches),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
436 )
42203
5997eabc7b85 push: added clear warning message when pushing closed branches(issue6080)
Taapas Agrawal <taapas2897@gmail.com>
parents: 42029
diff changeset
437 else:
45908
122f0b59f5f0 errors: remove trailing "!" in messages about creating new heads on push
Martin von Zweigbergk <martinvonz@google.com>
parents: 45144
diff changeset
438 errmsg = _(b"push creates new remote branches: %s") % branchnames
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
439 hint = _(b"use 'hg push --new-branch' to create new remote branches")
46119
9261f6c1d39b errors: raise StateError when push fails because it creates new heads
Martin von Zweigbergk <martinvonz@google.com>
parents: 45942
diff changeset
440 raise error.StateError(errmsg, hint=hint)
1466
b6d9ea0bc107 Added a lot of comments to changegroupsubset.
Eric Hopper <hopper@omnifarious.org>
parents: 1464
diff changeset
441
26862
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
442 # 2. Find heads that we need not warn about
26936
d47ac02fcefa discovery: pass pushop to _nowarnheads
Ryan McElroy <rmcelroy@fb.com>
parents: 26935
diff changeset
443 nowarnheads = _nowarnheads(pushop)
17212
246131d670c2 checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17211
diff changeset
444
246131d670c2 checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17211
diff changeset
445 # 3. Check for new heads.
15932
4154338f0bc0 discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15893
diff changeset
446 # If there are more heads after the push than before, a suitable
4154338f0bc0 discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15893
diff changeset
447 # error message, depending on unsynced status, is displayed.
26585
b38d93735a4f discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25944
diff changeset
448 errormsg = None
43106
d783f945a701 py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43077
diff changeset
449 for branch, heads in sorted(pycompat.iteritems(headssum)):
32708
90cb4ec8df64 headsummary: expose the 'discardedheads' set in the headssummary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32707
diff changeset
450 remoteheads, newheads, unsyncedheads, discardedheads = heads
17214
738ad56dd8a6 checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 17212
diff changeset
451 # add unsynced data
20381
fff0a71f8177 discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents: 20225
diff changeset
452 if remoteheads is None:
19840
b00ba31313c3 discovery: abort also when pushing multiple headed new branch
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 18382
diff changeset
453 oldhs = set()
b00ba31313c3 discovery: abort also when pushing multiple headed new branch
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 18382
diff changeset
454 else:
20381
fff0a71f8177 discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents: 20225
diff changeset
455 oldhs = set(remoteheads)
fff0a71f8177 discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents: 20225
diff changeset
456 oldhs.update(unsyncedheads)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
457 dhs = None # delta heads, the new heads on branch
32675
fc9296c15112 checkheads: simplify the code around obsolescence post-processing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32674
diff changeset
458 newhs = set(newheads)
32673
bd966b9f3274 checkheads: clarify that we no longer touch the head unknown locally
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32672
diff changeset
459 newhs.update(unsyncedheads)
32674
7a7c4f3afb98 checkheads: drop now unused filtering of 'unsyncedheads'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32673
diff changeset
460 if unsyncedheads:
7a7c4f3afb98 checkheads: drop now unused filtering of 'unsyncedheads'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32673
diff changeset
461 if None in unsyncedheads:
22178
70383c6961b4 discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21580
diff changeset
462 # old remote, no heads data
70383c6961b4 discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21580
diff changeset
463 heads = None
21198
56a04085c23c discovery: don't report all "unsynced" remote heads (issue4230)
Mads Kiilerich <madski@unity3d.com>
parents: 20502
diff changeset
464 else:
35184
bc775b8cc020 scmutil: extra utility to display a reasonable amount of nodes
Boris Feld <boris.feld@octobus.net>
parents: 32792
diff changeset
465 heads = scmutil.nodesummaries(repo, unsyncedheads)
22178
70383c6961b4 discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21580
diff changeset
466 if heads is None:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
467 repo.ui.status(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43106
diff changeset
468 _(b"remote has heads that are not known locally\n")
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
469 )
22178
70383c6961b4 discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21580
diff changeset
470 elif branch is None:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
471 repo.ui.status(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43106
diff changeset
472 _(b"remote has heads that are not known locally: %s\n")
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
473 % heads
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
474 )
20501
8a9e0b523d2d discovery: improve "note: unsynced remote changes!" warning
Mads Kiilerich <madski@unity3d.com>
parents: 20403
diff changeset
475 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
476 repo.ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
477 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
478 b"remote has heads on branch '%s' that are "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
479 b"not known locally: %s\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
480 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
481 % (branch, heads)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
482 )
20381
fff0a71f8177 discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents: 20225
diff changeset
483 if remoteheads is None:
fff0a71f8177 discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents: 20225
diff changeset
484 if len(newhs) > 1:
19840
b00ba31313c3 discovery: abort also when pushing multiple headed new branch
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 18382
diff changeset
485 dhs = list(newhs)
26585
b38d93735a4f discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25944
diff changeset
486 if errormsg is None:
43049
6e8582ccf76d discovery: re-wrap expression to avoid a black bug
Augie Fackler <augie@google.com>
parents: 42978
diff changeset
487 errormsg = (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
488 _(b"push creates new branch '%s' with multiple heads")
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
489 % branch
43049
6e8582ccf76d discovery: re-wrap expression to avoid a black bug
Augie Fackler <augie@google.com>
parents: 42978
diff changeset
490 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
491 hint = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
492 b"merge or"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
493 b" see 'hg help push' for details about"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
494 b" pushing new heads"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
495 )
19840
b00ba31313c3 discovery: abort also when pushing multiple headed new branch
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 18382
diff changeset
496 elif len(newhs) > len(oldhs):
20381
fff0a71f8177 discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents: 20225
diff changeset
497 # remove bookmarked or existing remote heads from the new heads list
26862
894f54d84d4a discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents: 26819
diff changeset
498 dhs = sorted(newhs - nowarnheads - oldhs)
16835
4267c840c481 bookmarks: allow existing remote bookmarks to become heads when pushing
Levi Bard <levi@unity3d.com>
parents: 16746
diff changeset
499 if dhs:
26585
b38d93735a4f discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25944
diff changeset
500 if errormsg is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
501 if branch not in (b'default', None):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
502 errormsg = _(
45908
122f0b59f5f0 errors: remove trailing "!" in messages about creating new heads on push
Martin von Zweigbergk <martinvonz@google.com>
parents: 45144
diff changeset
503 b"push creates new remote head %s on branch '%s'"
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
504 ) % (
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
505 short(dhs[0]),
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
506 branch,
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45908
diff changeset
507 )
21580
32601b0b74c0 discovery: if a push would create a new head, mention the bookmark name if any
Stephen Lee <sphen.lee@gmail.com>
parents: 21198
diff changeset
508 elif repo[dhs[0]].bookmarks():
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
509 errormsg = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
510 b"push creates new remote head %s "
45908
122f0b59f5f0 errors: remove trailing "!" in messages about creating new heads on push
Martin von Zweigbergk <martinvonz@google.com>
parents: 45144
diff changeset
511 b"with bookmark '%s'"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
512 ) % (short(dhs[0]), repo[dhs[0]].bookmarks()[0])
15932
4154338f0bc0 discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15893
diff changeset
513 else:
45908
122f0b59f5f0 errors: remove trailing "!" in messages about creating new heads on push
Martin von Zweigbergk <martinvonz@google.com>
parents: 45144
diff changeset
514 errormsg = _(b"push creates new remote head %s") % short(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
515 dhs[0]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
516 )
20381
fff0a71f8177 discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents: 20225
diff changeset
517 if unsyncedheads:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
518 hint = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
519 b"pull and merge or"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
520 b" see 'hg help push' for details about"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
521 b" pushing new heads"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
522 )
15932
4154338f0bc0 discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15893
diff changeset
523 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
524 hint = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
525 b"merge or"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
526 b" see 'hg help push' for details about"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
527 b" pushing new heads"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
528 )
20051
b988b3b19303 discovery: make note messages for new heads more readable
Mads Kiilerich <madski@unity3d.com>
parents: 20050
diff changeset
529 if branch is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
530 repo.ui.note(_(b"new remote heads:\n"))
20051
b988b3b19303 discovery: make note messages for new heads more readable
Mads Kiilerich <madski@unity3d.com>
parents: 20050
diff changeset
531 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
532 repo.ui.note(_(b"new remote heads on branch '%s':\n") % branch)
15932
4154338f0bc0 discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15893
diff changeset
533 for h in dhs:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
534 repo.ui.note(b" %s\n" % short(h))
26585
b38d93735a4f discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25944
diff changeset
535 if errormsg:
46119
9261f6c1d39b errors: raise StateError when push fails because it creates new heads
Martin von Zweigbergk <martinvonz@google.com>
parents: 45942
diff changeset
536 raise error.StateError(errormsg, hint=hint)
31586
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
537
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
538
31586
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
539 def _postprocessobsolete(pushop, futurecommon, candidate_newhs):
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
540 """post process the list of new heads with obsolescence information
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
541
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
542 Exists as a sub-function to contain the complexity and allow extensions to
31586
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
543 experiment with smarter logic.
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
544
31586
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
545 Returns (newheads, discarded_heads) tuple
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
546 """
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
547 # known issue
31586
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
548 #
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
549 # * We "silently" skip processing on all changeset unknown locally
31586
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
550 #
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
551 # * if <nh> is public on the remote, it won't be affected by obsolete
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
552 # marker and a new is created
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
553
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
554 # define various utilities and containers
31586
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
555 repo = pushop.repo
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
556 unfi = repo.unfiltered()
43560
65d6770273c8 index: use `index.get_rev` in `discovery._postprocessobsolete`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
557 torev = unfi.changelog.index.get_rev
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
558 public = phases.public
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
559 getphase = unfi._phasecache.phase
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
560 ispublic = lambda r: getphase(unfi, r) == public
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
561 ispushed = lambda n: torev(n) in futurecommon
32789
443e8543a125 checkheads: pass "ispushed" function to the obsmarkers logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32709
diff changeset
562 hasoutmarker = functools.partial(pushingmarkerfor, unfi.obsstore, ispushed)
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
563 successorsmarkers = unfi.obsstore.successors
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
564 newhs = set() # final set of new heads
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
565 discarded = set() # new head of fully replaced branch
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
566
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
567 localcandidate = set() # candidate heads known locally
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
568 unknownheads = set() # candidate heads unknown locally
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
569 for h in candidate_newhs:
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
570 if h in unfi:
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
571 localcandidate.add(h)
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
572 else:
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
573 if successorsmarkers.get(h) is not None:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
574 msg = (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
575 b'checkheads: remote head unknown locally has'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
576 b' local marker: %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
577 )
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
578 repo.ui.debug(msg % hex(h))
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
579 unknownheads.add(h)
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
580
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
581 # fast path the simple case
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
582 if len(localcandidate) == 1:
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
583 return unknownheads | set(candidate_newhs), set()
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
584
48688
053a5bf508da discovery: port _postprocessobsolete() changes from evolve, add tests
Anton Shestakov <av6@dwimlabs.net>
parents: 48530
diff changeset
585 obsrevs = obsolete.getrevs(unfi, b'obsolete')
053a5bf508da discovery: port _postprocessobsolete() changes from evolve, add tests
Anton Shestakov <av6@dwimlabs.net>
parents: 48530
diff changeset
586 futurenonobsolete = frozenset(futurecommon) - obsrevs
053a5bf508da discovery: port _postprocessobsolete() changes from evolve, add tests
Anton Shestakov <av6@dwimlabs.net>
parents: 48530
diff changeset
587
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
588 # actually process branch replacement
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
589 while localcandidate:
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
590 nh = localcandidate.pop()
48688
053a5bf508da discovery: port _postprocessobsolete() changes from evolve, add tests
Anton Shestakov <av6@dwimlabs.net>
parents: 48530
diff changeset
591 r = torev(nh)
44450
7d5455b988ec discovery: avoid wrong detection of multiple branch heads (issue6256)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43560
diff changeset
592 current_branch = unfi[nh].branch()
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
593 # run this check early to skip the evaluation of the whole branch
48688
053a5bf508da discovery: port _postprocessobsolete() changes from evolve, add tests
Anton Shestakov <av6@dwimlabs.net>
parents: 48530
diff changeset
594 if ispublic(r) or r not in obsrevs:
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
595 newhs.add(nh)
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
596 continue
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
597
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
598 # Get all revs/nodes on the branch exclusive to this head
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
599 # (already filtered heads are "ignored"))
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
600 branchrevs = unfi.revs(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
601 b'only(%n, (%ln+%ln))', nh, localcandidate, newhs
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
602 )
44450
7d5455b988ec discovery: avoid wrong detection of multiple branch heads (issue6256)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43560
diff changeset
603
7d5455b988ec discovery: avoid wrong detection of multiple branch heads (issue6256)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43560
diff changeset
604 branchnodes = []
7d5455b988ec discovery: avoid wrong detection of multiple branch heads (issue6256)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43560
diff changeset
605 for r in branchrevs:
7d5455b988ec discovery: avoid wrong detection of multiple branch heads (issue6256)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43560
diff changeset
606 c = unfi[r]
7d5455b988ec discovery: avoid wrong detection of multiple branch heads (issue6256)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43560
diff changeset
607 if c.branch() == current_branch:
7d5455b988ec discovery: avoid wrong detection of multiple branch heads (issue6256)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43560
diff changeset
608 branchnodes.append(c.node())
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
609
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
610 # The branch won't be hidden on the remote if
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
611 # * any part of it is public,
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
612 # * any part of it is considered part of the result by previous logic,
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
613 # * if we have no markers to push to obsolete it.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
614 if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
615 any(ispublic(r) for r in branchrevs)
48688
053a5bf508da discovery: port _postprocessobsolete() changes from evolve, add tests
Anton Shestakov <av6@dwimlabs.net>
parents: 48530
diff changeset
616 or any(torev(n) in futurenonobsolete for n in branchnodes)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
617 or any(not hasoutmarker(n) for n in branchnodes)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
618 ):
31586
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
619 newhs.add(nh)
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
620 else:
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
621 # note: there is a corner case if there is a merge in the branch.
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
622 # we might end up with -more- heads. However, these heads are not
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
623 # "added" by the push, but more by the "removal" on the remote so I
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
624 # think is a okay to ignore them,
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
625 discarded.add(nh)
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
626 newhs |= unknownheads
31586
df82f375fa00 checkheads: extract obsolete post processing in its own function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29973
diff changeset
627 return newhs, discarded
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
628
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
629
32789
443e8543a125 checkheads: pass "ispushed" function to the obsmarkers logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32709
diff changeset
630 def pushingmarkerfor(obsstore, ispushed, node):
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
631 """true if some markers are to be pushed for node
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
632
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
633 We cannot just look in to the pushed obsmarkers from the pushop because
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
634 discovery might have filtered relevant markers. In addition listing all
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
635 markers relevant to all changesets in the pushed set would be too expensive
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
636 (O(len(repo)))
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
637
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
638 (note: There are cache opportunity in this function. but it would requires
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
639 a two dimensional stack.)
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
640 """
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
641 successorsmarkers = obsstore.successors
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
642 stack = [node]
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
643 seen = set(stack)
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
644 while stack:
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
645 current = stack.pop()
32789
443e8543a125 checkheads: pass "ispushed" function to the obsmarkers logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32709
diff changeset
646 if ispushed(current):
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
647 return True
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
648 markers = successorsmarkers.get(current, ())
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
649 # markers fields = ('prec', 'succs', 'flag', 'meta', 'date', 'parents')
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
650 for m in markers:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
651 nexts = m[1] # successors
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
652 if not nexts: # this is a prune marker
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43049
diff changeset
653 nexts = m[5] or () # parents
32009
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
654 for n in nexts:
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
655 if n not in seen:
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
656 seen.add(n)
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
657 stack.append(n)
c6cb21ddf74a checkheads: upgrade the obsolescence postprocessing logic (issue4354)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31586
diff changeset
658 return False