author | Gregory Szorc <gregory.szorc@gmail.com> |
Sat, 06 Aug 2016 13:55:21 -0700 | |
changeset 29734 | 62e2e048d068 |
parent 29690 | 5684bc429e6a |
child 29804 | 7b9157aa752f |
permissions | -rw-r--r-- |
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 |
# |
11313
0bb14798cd07
discovery: fix description line
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11301
diff
changeset
|
3 |
# Copyright 2010 Matt Mackall <mpm@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 | 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 |
from __future__ import absolute_import |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
9 |
|
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
10 |
from .i18n import _ |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
11 |
from .node import ( |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
12 |
nullid, |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
13 |
short, |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
14 |
) |
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 |
from . import ( |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
17 |
bookmarks, |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
18 |
branchmap, |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26585
diff
changeset
|
19 |
error, |
25944
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
20 |
obsolete, |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
21 |
phases, |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
22 |
setdiscovery, |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
23 |
treediscovery, |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
24 |
util, |
337d010f31e6
discovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24702
diff
changeset
|
25 |
) |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8108
diff
changeset
|
26 |
|
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
27 |
def findcommonincoming(repo, remote, heads=None, force=False): |
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
28 |
"""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
|
29 |
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
|
30 |
|
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
31 |
"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
|
32 |
"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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
any longer. |
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
37 |
"heads" is either the supplied heads, or else the remote's heads. |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
38 |
|
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17254
diff
changeset
|
39 |
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
|
40 |
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
|
41 |
|
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
42 |
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
|
43 |
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
|
44 |
""" |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
45 |
|
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
46 |
if not remote.capable('getbundle'): |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
47 |
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
|
48 |
|
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
49 |
if heads: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
50 |
allknown = True |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
20184
diff
changeset
|
51 |
knownnode = repo.changelog.hasnode # no nodemap until it is filtered |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
52 |
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
|
53 |
if not knownnode(h): |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
54 |
allknown = False |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
55 |
break |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
56 |
if allknown: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
57 |
return (heads, False, heads) |
8404
a2bc39ade36b
commit: move 'nothing changed' test into commit()
Matt Mackall <mpm@selenic.com>
parents:
8403
diff
changeset
|
58 |
|
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
59 |
res = setdiscovery.findcommonheads(repo.ui, repo, remote, |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
60 |
abortwhenunrelated=not force) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
61 |
common, anyinc, srvheads = res |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
62 |
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
|
63 |
|
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
64 |
class outgoing(object): |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
65 |
'''Represents the set of nodes present in a local repo but not in a |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
66 |
(possibly) remote one. |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
67 |
|
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
68 |
Members: |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
69 |
|
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
70 |
missing is a list of all nodes present in local but not in remote. |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
71 |
common is a list of all nodes shared between the two repos. |
15838
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
72 |
excluded is the list of missing changeset that shouldn't be sent remotely. |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
73 |
missingheads is the list of heads of missing. |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
74 |
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
|
75 |
|
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
76 |
The sets are computed on demand from the heads, unless provided upfront |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
77 |
by discovery.''' |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
78 |
|
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
79 |
def __init__(self, revlog, commonheads, missingheads): |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
80 |
self.commonheads = commonheads |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
81 |
self.missingheads = missingheads |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
82 |
self._revlog = revlog |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
83 |
self._common = None |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
84 |
self._missing = 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
|
85 |
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
|
86 |
|
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
87 |
def _computecommonmissing(self): |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
88 |
sets = self._revlog.findcommonmissing(self.commonheads, |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
89 |
self.missingheads) |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
90 |
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
|
91 |
|
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
92 |
@util.propertycache |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
93 |
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
|
94 |
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
|
95 |
self._computecommonmissing() |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
96 |
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
|
97 |
|
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
98 |
@util.propertycache |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
99 |
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
|
100 |
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
|
101 |
self._computecommonmissing() |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
102 |
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
|
103 |
|
29690
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
104 |
def outgoingbetween(repo, roots, heads): |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
105 |
"""create an ``outgoing`` consisting of nodes between roots and heads |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
106 |
|
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
107 |
The ``missing`` nodes will be descendants of any of the ``roots`` and |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
108 |
ancestors of any of the ``heads``, both are which are defined as a list |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
109 |
of binary nodes. |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
110 |
""" |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
111 |
cl = repo.changelog |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
112 |
if not roots: |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
113 |
roots = [nullid] |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
114 |
discbases = [] |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
115 |
for n in roots: |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
116 |
discbases.extend([p for p in cl.parents(n) if p != nullid]) |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
117 |
# TODO remove call to nodesbetween. |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
118 |
# TODO populate attributes on outgoing instance instead of setting |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
119 |
# discbases. |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
120 |
csets, roots, heads = cl.nodesbetween(roots, heads) |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
121 |
included = set(csets) |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
122 |
discbases = [n for n in discbases if n not in included] |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
123 |
return outgoing(cl, discbases, heads) |
5684bc429e6a
discovery: move code to create outgoing from roots and heads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29229
diff
changeset
|
124 |
|
16683 | 125 |
def findcommonoutgoing(repo, other, onlyheads=None, force=False, |
16746 | 126 |
commoninc=None, portable=False): |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
127 |
'''Return an outgoing instance to identify the nodes present in repo but |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
128 |
not in other. |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
129 |
|
16683 | 130 |
If onlyheads is given, only nodes ancestral to nodes in onlyheads |
131 |
(inclusive) are included. If you already know the local repo's heads, |
|
132 |
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
|
133 |
|
17251
98166640b356
help: fix some instances of 'the the'
Mads Kiilerich <mads@kiilerich.com>
parents:
17248
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
|
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
137 |
If portable is given, compute more conservative common and missingheads, |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
138 |
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
|
139 |
# declare an empty outgoing object to be filled later |
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
140 |
og = outgoing(repo.changelog, None, None) |
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
141 |
|
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
142 |
# 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
|
143 |
if commoninc 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
|
144 |
commoninc = findcommonincoming(repo, other, force=force) |
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
145 |
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
|
146 |
|
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
147 |
# compute outgoing |
17206
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
148 |
mayexclude = (repo._phasecache.phaseroots[phases.secret] or repo.obsstore) |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
149 |
if not mayexclude: |
15838
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
150 |
og.missingheads = onlyheads or repo.heads() |
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
151 |
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
|
152 |
# use visible heads as it should be cached |
18382
f3b21beb9802
filtering: rename filters to their antonyms
Kevin Bullock <kbullock@ringworld.org>
parents:
18361
diff
changeset
|
153 |
og.missingheads = repo.filtered("served").heads() |
17248
6ffb35b2284c
discovery: add extinct changesets to outgoing.excluded
Patrick Mezard <patrick@mezard.eu>
parents:
17214
diff
changeset
|
154 |
og.excluded = [ctx.node() for ctx in repo.set('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
|
155 |
else: |
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
156 |
# 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
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
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
|
161 |
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
|
162 |
ctx = repo[node] |
17248
6ffb35b2284c
discovery: add extinct changesets to outgoing.excluded
Patrick Mezard <patrick@mezard.eu>
parents:
17214
diff
changeset
|
163 |
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
|
164 |
excluded.append(node) |
6ffb35b2284c
discovery: add extinct changesets to outgoing.excluded
Patrick Mezard <patrick@mezard.eu>
parents:
17214
diff
changeset
|
165 |
else: |
6ffb35b2284c
discovery: add extinct changesets to outgoing.excluded
Patrick Mezard <patrick@mezard.eu>
parents:
17214
diff
changeset
|
166 |
missing.append(node) |
17206
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
167 |
if len(missing) == len(allmissing): |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
168 |
missingheads = onlyheads |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
169 |
else: # update missing heads |
15955
5a14f48d6b9a
discovery: ensure that missingheads are always heads of everything we tried
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15951
diff
changeset
|
170 |
missingheads = phases.newheads(repo, onlyheads, 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
|
171 |
og.missingheads = missingheads |
16736
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
172 |
if portable: |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
173 |
# recompute common and missingheads as if -r<rev> had been given for |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
174 |
# 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
|
175 |
# ancestors of missing |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
176 |
og._computecommonmissing() |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
177 |
cl = repo.changelog |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
178 |
missingrevs = set(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
|
179 |
og._common = set(cl.ancestors(missingrevs)) - missingrevs |
16736
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
180 |
commonheads = set(og.commonheads) |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
181 |
og.missingheads = [h for h in og.missingheads if h not in commonheads] |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
182 |
|
15838
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
183 |
return og |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
184 |
|
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
185 |
def _headssummary(repo, remote, outgoing): |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
186 |
"""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
|
187 |
|
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
188 |
return {'branch': ([remoteheads], [newheads], [unsyncedheads])} mapping |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
189 |
|
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
190 |
- branch: the branch name |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
191 |
- remoteheads: the list of remote heads known locally |
20381
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
192 |
None if the branch is new |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
193 |
- newheads: the new remote heads (known locally) with outgoing pushed |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
194 |
- unsyncedheads: the list of remote heads unknown locally. |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
195 |
""" |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
196 |
cl = repo.changelog |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
197 |
headssum = {} |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
198 |
# A. Create set of branches involved in the push. |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
199 |
branches = set(repo[n].branch() for n in outgoing.missing) |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
200 |
remotemap = remote.branchmap() |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
201 |
newbranches = branches - set(remotemap) |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
202 |
branches.difference_update(newbranches) |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
203 |
|
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
204 |
# A. register remote heads |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
205 |
remotebranches = set() |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
206 |
for branch, heads in remote.branchmap().iteritems(): |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
207 |
remotebranches.add(branch) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
208 |
known = [] |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
209 |
unsynced = [] |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
20184
diff
changeset
|
210 |
knownnode = cl.hasnode # do not use nodemap until it is filtered |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
211 |
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
|
212 |
if knownnode(h): |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
213 |
known.append(h) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
214 |
else: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
215 |
unsynced.append(h) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
216 |
headssum[branch] = (known, list(known), unsynced) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
217 |
# B. add new branch data |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
218 |
missingctx = list(repo[n] for n in outgoing.missing) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
219 |
touchedbranches = set() |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
220 |
for ctx in missingctx: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
221 |
branch = ctx.branch() |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
222 |
touchedbranches.add(branch) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
223 |
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
|
224 |
headssum[branch] = (None, [], []) |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
225 |
|
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
226 |
# C drop data about untouched branches: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
227 |
for branch in remotebranches - touchedbranches: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
228 |
del headssum[branch] |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
229 |
|
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
230 |
# D. Update newmap with outgoing changes. |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
231 |
# This will possibly add new heads and remove existing ones. |
18124
79db6d40bced
branchmap: store branchcache in a dedicated object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18120
diff
changeset
|
232 |
newmap = branchmap.branchcache((branch, heads[1]) |
79db6d40bced
branchmap: store branchcache in a dedicated object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18120
diff
changeset
|
233 |
for branch, heads in headssum.iteritems() |
79db6d40bced
branchmap: store branchcache in a dedicated object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18120
diff
changeset
|
234 |
if heads[0] is not None) |
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
|
235 |
newmap.update(repo, (ctx.rev() for ctx in missingctx)) |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
236 |
for branch, newheads in newmap.iteritems(): |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
237 |
headssum[branch][1][:] = newheads |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
238 |
return headssum |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
239 |
|
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
240 |
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
|
241 |
"""Compute branchmapsummary for repo without branchmap support""" |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
242 |
|
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
243 |
# 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
|
244 |
# 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
|
245 |
# (code based on update) |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
20184
diff
changeset
|
246 |
knownnode = repo.changelog.hasnode # no nodemap until it is filtered |
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
20184
diff
changeset
|
247 |
oldheads = set(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
|
248 |
# 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
|
249 |
# - an element of oldheads |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
250 |
# - another element of outgoing.missing |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
251 |
# - nullrev |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
252 |
# This explains why the new head are very simple to compute. |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
253 |
r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing) |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
254 |
newheads = list(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
|
255 |
# 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
|
256 |
if inc: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22178
diff
changeset
|
257 |
unsynced = set([None]) |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22178
diff
changeset
|
258 |
else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22178
diff
changeset
|
259 |
unsynced = set() |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
260 |
return {None: (oldheads, newheads, unsynced)} |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
261 |
|
26936
d47ac02fcefa
discovery: pass pushop to _nowarnheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26935
diff
changeset
|
262 |
def _nowarnheads(pushop): |
26862
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
263 |
# 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
|
264 |
repo = pushop.repo.unfiltered() |
d47ac02fcefa
discovery: pass pushop to _nowarnheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26935
diff
changeset
|
265 |
remote = pushop.remote |
26862
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
266 |
localbookmarks = repo._bookmarks |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
267 |
remotebookmarks = remote.listkeys('bookmarks') |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
268 |
bookmarkedheads = set() |
29229
89bba2beb03e
bookmarks: allow pushing active bookmark on new remote head (issue5236)
liscju <piotr.listkiewicz@gmail.com>
parents:
26936
diff
changeset
|
269 |
|
89bba2beb03e
bookmarks: allow pushing active bookmark on new remote head (issue5236)
liscju <piotr.listkiewicz@gmail.com>
parents:
26936
diff
changeset
|
270 |
# internal config: bookmarks.pushing |
89bba2beb03e
bookmarks: allow pushing active bookmark on new remote head (issue5236)
liscju <piotr.listkiewicz@gmail.com>
parents:
26936
diff
changeset
|
271 |
newbookmarks = [localbookmarks.expandname(b) |
89bba2beb03e
bookmarks: allow pushing active bookmark on new remote head (issue5236)
liscju <piotr.listkiewicz@gmail.com>
parents:
26936
diff
changeset
|
272 |
for b in pushop.ui.configlist('bookmarks', 'pushing')] |
89bba2beb03e
bookmarks: allow pushing active bookmark on new remote head (issue5236)
liscju <piotr.listkiewicz@gmail.com>
parents:
26936
diff
changeset
|
273 |
|
26862
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
274 |
for bm in localbookmarks: |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
275 |
rnode = remotebookmarks.get(bm) |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
276 |
if rnode and rnode in repo: |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
277 |
lctx, rctx = repo[bm], repo[rnode] |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
278 |
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
|
279 |
bookmarkedheads.add(lctx.node()) |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
280 |
else: |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
281 |
if bm in newbookmarks and bm not in remotebookmarks: |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
282 |
bookmarkedheads.add(repo[bm].node()) |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
283 |
|
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
284 |
return bookmarkedheads |
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
285 |
|
26935
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26862
diff
changeset
|
286 |
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
|
287 |
"""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
|
288 |
|
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
289 |
raise Abort error and display ui message as needed. |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
290 |
""" |
26935
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26862
diff
changeset
|
291 |
|
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26862
diff
changeset
|
292 |
repo = pushop.repo.unfiltered() |
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26862
diff
changeset
|
293 |
remote = pushop.remote |
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26862
diff
changeset
|
294 |
outgoing = pushop.outgoing |
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26862
diff
changeset
|
295 |
remoteheads = pushop.remoteheads |
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26862
diff
changeset
|
296 |
newbranch = pushop.newbranch |
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26862
diff
changeset
|
297 |
inc = bool(pushop.incoming) |
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26862
diff
changeset
|
298 |
|
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
299 |
# 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
|
300 |
# 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
|
301 |
# - unknown locally |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
302 |
# - a local outgoing head descended from update |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
303 |
# - 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
|
304 |
# ancestral to an outgoing head |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
305 |
if remoteheads == [nullid]: |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
306 |
# 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
|
307 |
return |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2424
diff
changeset
|
308 |
|
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
309 |
if remote.capable('branchmap'): |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
310 |
headssum = _headssummary(repo, remote, outgoing) |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
311 |
else: |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
312 |
headssum = _oldheadssummary(repo, remoteheads, outgoing, inc) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
313 |
newbranches = [branch for branch, heads in headssum.iteritems() |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
314 |
if heads[0] is None] |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
315 |
# 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
|
316 |
if newbranches and not newbranch: # new branch requires --new-branch |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
317 |
branchnames = ', '.join(sorted(newbranches)) |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26585
diff
changeset
|
318 |
raise error.Abort(_("push creates new remote branches: %s!") |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
319 |
% branchnames, |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
320 |
hint=_("use 'hg push --new-branch' to create" |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
321 |
" new remote branches")) |
1466
b6d9ea0bc107
Added a lot of comments to changegroupsubset.
Eric Hopper <hopper@omnifarious.org>
parents:
1464
diff
changeset
|
322 |
|
26862
894f54d84d4a
discovery: factor out calculation of heads to not warn about
Ryan McElroy <rmcelroy@fb.com>
parents:
26819
diff
changeset
|
323 |
# 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
|
324 |
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
|
325 |
|
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
326 |
# 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
|
327 |
# 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
|
328 |
# 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
|
329 |
errormsg = None |
24702
2b0449255800
discovery: don't compute allfuturecommon when it won't be used
Michael O'Connor <moconnor@janestreet.com>
parents:
24306
diff
changeset
|
330 |
# If there is no obsstore, allfuturecommon won't be used, so no |
2b0449255800
discovery: don't compute allfuturecommon when it won't be used
Michael O'Connor <moconnor@janestreet.com>
parents:
24306
diff
changeset
|
331 |
# need to compute it. |
2b0449255800
discovery: don't compute allfuturecommon when it won't be used
Michael O'Connor <moconnor@janestreet.com>
parents:
24306
diff
changeset
|
332 |
if repo.obsstore: |
2b0449255800
discovery: don't compute allfuturecommon when it won't be used
Michael O'Connor <moconnor@janestreet.com>
parents:
24306
diff
changeset
|
333 |
allmissing = set(outgoing.missing) |
2b0449255800
discovery: don't compute allfuturecommon when it won't be used
Michael O'Connor <moconnor@janestreet.com>
parents:
24306
diff
changeset
|
334 |
cctx = repo.set('%ld', outgoing.common) |
2b0449255800
discovery: don't compute allfuturecommon when it won't be used
Michael O'Connor <moconnor@janestreet.com>
parents:
24306
diff
changeset
|
335 |
allfuturecommon = set(c.node() for c in cctx) |
2b0449255800
discovery: don't compute allfuturecommon when it won't be used
Michael O'Connor <moconnor@janestreet.com>
parents:
24306
diff
changeset
|
336 |
allfuturecommon.update(allmissing) |
18361
06f075836010
discovery: process heads in sorted order
Mads Kiilerich <mads@kiilerich.com>
parents:
18305
diff
changeset
|
337 |
for branch, heads in sorted(headssum.iteritems()): |
20381
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
338 |
remoteheads, newheads, unsyncedheads = heads |
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
339 |
candidate_newhs = set(newheads) |
17214
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
340 |
# add unsynced data |
20381
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
341 |
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
|
342 |
oldhs = set() |
b00ba31313c3
discovery: abort also when pushing multiple headed new branch
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18382
diff
changeset
|
343 |
else: |
20381
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
344 |
oldhs = set(remoteheads) |
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
345 |
oldhs.update(unsyncedheads) |
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
346 |
candidate_newhs.update(unsyncedheads) |
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
347 |
dhs = None # delta heads, the new heads on branch |
17549
be0fcbb1c92f
checkheads: don't warn about unsynced changes that we ill obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17548
diff
changeset
|
348 |
discardedheads = set() |
26603
517ffec37dee
discovery: put trivial branch first
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26597
diff
changeset
|
349 |
if not repo.obsstore: |
517ffec37dee
discovery: put trivial branch first
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26597
diff
changeset
|
350 |
newhs = candidate_newhs |
517ffec37dee
discovery: put trivial branch first
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26597
diff
changeset
|
351 |
else: |
20381
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
352 |
# remove future heads which are actually obsoleted by another |
17214
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
353 |
# pushed element: |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
354 |
# |
26596
8688590ca03c
discovery: fix a typo in a comment
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
355 |
# XXX as above, There are several cases this code does not handle |
17549
be0fcbb1c92f
checkheads: don't warn about unsynced changes that we ill obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17548
diff
changeset
|
356 |
# XXX properly |
17214
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
357 |
# |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
358 |
# (1) if <nh> is public, it won't be affected by obsolete marker |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
359 |
# and a new is created |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
360 |
# |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
361 |
# (2) if the new heads have ancestors which are not obsolete and |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
362 |
# not ancestors of any other heads we will have a new head too. |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
363 |
# |
20381
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
364 |
# These two cases will be easy to handle for known changeset but |
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
365 |
# much more tricky for unsynced changes. |
26597
d58721d684cb
discovery: reference relevant bug in the faulty code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26596
diff
changeset
|
366 |
# |
d58721d684cb
discovery: reference relevant bug in the faulty code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26596
diff
changeset
|
367 |
# In addition, this code is confused by prune as it only looks for |
d58721d684cb
discovery: reference relevant bug in the faulty code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26596
diff
changeset
|
368 |
# successors of the heads (none if pruned) leading to issue4354 |
17214
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
369 |
newhs = set() |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
370 |
for nh in candidate_newhs: |
17548
eaa5fcc5bd20
checkheads: check successors for new heads in both missing and common
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17547
diff
changeset
|
371 |
if nh in repo and repo[nh].phase() <= phases.public: |
17547
e6de4761d26f
checkheads: attend to phases when computing new heads with obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17537
diff
changeset
|
372 |
newhs.add(nh) |
17214
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
373 |
else: |
17827
612db9d7e76a
obsolete: have `allsuccessors` takes a list of nodes
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17826
diff
changeset
|
374 |
for suc in obsolete.allsuccessors(repo.obsstore, [nh]): |
17548
eaa5fcc5bd20
checkheads: check successors for new heads in both missing and common
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17547
diff
changeset
|
375 |
if suc != nh and suc in allfuturecommon: |
17549
be0fcbb1c92f
checkheads: don't warn about unsynced changes that we ill obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17548
diff
changeset
|
376 |
discardedheads.add(nh) |
17547
e6de4761d26f
checkheads: attend to phases when computing new heads with obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17537
diff
changeset
|
377 |
break |
e6de4761d26f
checkheads: attend to phases when computing new heads with obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17537
diff
changeset
|
378 |
else: |
e6de4761d26f
checkheads: attend to phases when computing new heads with obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17537
diff
changeset
|
379 |
newhs.add(nh) |
20501
8a9e0b523d2d
discovery: improve "note: unsynced remote changes!" warning
Mads Kiilerich <madski@unity3d.com>
parents:
20403
diff
changeset
|
380 |
unsynced = sorted(h for h in unsyncedheads if h not in discardedheads) |
8a9e0b523d2d
discovery: improve "note: unsynced remote changes!" warning
Mads Kiilerich <madski@unity3d.com>
parents:
20403
diff
changeset
|
381 |
if unsynced: |
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
|
382 |
if None in unsynced: |
70383c6961b4
discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21580
diff
changeset
|
383 |
# 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
|
384 |
heads = None |
70383c6961b4
discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21580
diff
changeset
|
385 |
elif len(unsynced) <= 4 or repo.ui.verbose: |
21198
56a04085c23c
discovery: don't report all "unsynced" remote heads (issue4230)
Mads Kiilerich <madski@unity3d.com>
parents:
20502
diff
changeset
|
386 |
heads = ' '.join(short(h) for h in unsynced) |
56a04085c23c
discovery: don't report all "unsynced" remote heads (issue4230)
Mads Kiilerich <madski@unity3d.com>
parents:
20502
diff
changeset
|
387 |
else: |
56a04085c23c
discovery: don't report all "unsynced" remote heads (issue4230)
Mads Kiilerich <madski@unity3d.com>
parents:
20502
diff
changeset
|
388 |
heads = (' '.join(short(h) for h in unsynced[:4]) + |
56a04085c23c
discovery: don't report all "unsynced" remote heads (issue4230)
Mads Kiilerich <madski@unity3d.com>
parents:
20502
diff
changeset
|
389 |
' ' + _("and %s others") % (len(unsynced) - 4)) |
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
|
390 |
if heads is None: |
70383c6961b4
discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21580
diff
changeset
|
391 |
repo.ui.status(_("remote has heads that are " |
70383c6961b4
discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21580
diff
changeset
|
392 |
"not known locally\n")) |
70383c6961b4
discovery: prevent crash on unknown remote heads with old repo (issue4337)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21580
diff
changeset
|
393 |
elif branch is None: |
20502
7648e9aef6ee
discovery: make "note: unsynced remote changes!" less serious than a warning
Mads Kiilerich <madski@unity3d.com>
parents:
20501
diff
changeset
|
394 |
repo.ui.status(_("remote has heads that are " |
7648e9aef6ee
discovery: make "note: unsynced remote changes!" less serious than a warning
Mads Kiilerich <madski@unity3d.com>
parents:
20501
diff
changeset
|
395 |
"not known locally: %s\n") % heads) |
20501
8a9e0b523d2d
discovery: improve "note: unsynced remote changes!" warning
Mads Kiilerich <madski@unity3d.com>
parents:
20403
diff
changeset
|
396 |
else: |
20502
7648e9aef6ee
discovery: make "note: unsynced remote changes!" less serious than a warning
Mads Kiilerich <madski@unity3d.com>
parents:
20501
diff
changeset
|
397 |
repo.ui.status(_("remote has heads on branch '%s' that are " |
7648e9aef6ee
discovery: make "note: unsynced remote changes!" less serious than a warning
Mads Kiilerich <madski@unity3d.com>
parents:
20501
diff
changeset
|
398 |
"not known locally: %s\n") % (branch, heads)) |
20381
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
399 |
if remoteheads is None: |
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
400 |
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
|
401 |
dhs = list(newhs) |
26585
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
402 |
if errormsg is None: |
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
403 |
errormsg = (_("push creates new branch '%s' " |
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
404 |
"with multiple heads") % (branch)) |
19840
b00ba31313c3
discovery: abort also when pushing multiple headed new branch
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18382
diff
changeset
|
405 |
hint = _("merge or" |
19936
8179eb28983b
discovery: revise hint message introduced by changeset b00ba31313c3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19934
diff
changeset
|
406 |
" see \"hg help push\" for details about" |
19840
b00ba31313c3
discovery: abort also when pushing multiple headed new branch
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18382
diff
changeset
|
407 |
" pushing new heads") |
b00ba31313c3
discovery: abort also when pushing multiple headed new branch
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18382
diff
changeset
|
408 |
elif len(newhs) > len(oldhs): |
20381
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
409 |
# 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
|
410 |
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
|
411 |
if dhs: |
26585
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
412 |
if errormsg is None: |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
413 |
if branch not in ('default', None): |
26585
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
414 |
errormsg = _("push creates new remote head %s " |
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
415 |
"on branch '%s'!") % (short(dhs[0]), branch) |
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
|
416 |
elif repo[dhs[0]].bookmarks(): |
26585
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
417 |
errormsg = _("push creates new remote head %s " |
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
418 |
"with bookmark '%s'!") % ( |
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
419 |
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
|
420 |
else: |
26585
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
421 |
errormsg = _("push creates new remote head %s!" |
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
422 |
) % short(dhs[0]) |
20381
fff0a71f8177
discovery: cleanup of variable names and comments
Mads Kiilerich <madski@unity3d.com>
parents:
20225
diff
changeset
|
423 |
if unsyncedheads: |
19934
bfc6ed892349
push: hide description about "-f" in the hint to prevent from using it easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19840
diff
changeset
|
424 |
hint = _("pull and merge or" |
bfc6ed892349
push: hide description about "-f" in the hint to prevent from using it easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19840
diff
changeset
|
425 |
" see \"hg help push\" for details about" |
bfc6ed892349
push: hide description about "-f" in the hint to prevent from using it easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19840
diff
changeset
|
426 |
" pushing new heads") |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
427 |
else: |
19934
bfc6ed892349
push: hide description about "-f" in the hint to prevent from using it easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19840
diff
changeset
|
428 |
hint = _("merge or" |
bfc6ed892349
push: hide description about "-f" in the hint to prevent from using it easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19840
diff
changeset
|
429 |
" see \"hg help push\" for details about" |
bfc6ed892349
push: hide description about "-f" in the hint to prevent from using it easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19840
diff
changeset
|
430 |
" pushing new heads") |
20051
b988b3b19303
discovery: make note messages for new heads more readable
Mads Kiilerich <madski@unity3d.com>
parents:
20050
diff
changeset
|
431 |
if branch is None: |
b988b3b19303
discovery: make note messages for new heads more readable
Mads Kiilerich <madski@unity3d.com>
parents:
20050
diff
changeset
|
432 |
repo.ui.note(_("new remote heads:\n")) |
b988b3b19303
discovery: make note messages for new heads more readable
Mads Kiilerich <madski@unity3d.com>
parents:
20050
diff
changeset
|
433 |
else: |
b988b3b19303
discovery: make note messages for new heads more readable
Mads Kiilerich <madski@unity3d.com>
parents:
20050
diff
changeset
|
434 |
repo.ui.note(_("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
|
435 |
for h in dhs: |
20051
b988b3b19303
discovery: make note messages for new heads more readable
Mads Kiilerich <madski@unity3d.com>
parents:
20050
diff
changeset
|
436 |
repo.ui.note((" %s\n") % short(h)) |
26585
b38d93735a4f
discovery: rename 'error' to 'errormsg'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25944
diff
changeset
|
437 |
if errormsg: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26585
diff
changeset
|
438 |
raise error.Abort(errormsg, hint=hint) |