Mercurial > hg
annotate mercurial/discovery.py @ 17232:25248e2ebaee stable
largefiles: ensure addlargefiles() doesn't add a standin as a largefile
An easy way to force this (and cause a traceback) prior to the fix for 3507 was
$ touch large
$ hg add --large large
$ hg ci -m "add"
$ hg remove large
$ touch large
$ hg addremove --config largefiles.patterns=**large
This patch also detected (and corrected) a previous test where a standin got
added as a largefile (without a traceback).
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 19 Jul 2012 23:35:13 -0400 |
parents | 738ad56dd8a6 |
children | 6ffb35b2284c |
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 # |
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 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
8 from node import nullid, short |
3891 | 9 from i18n import _ |
17214
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
10 import util, setdiscovery, treediscovery, phases, obsolete |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8108
diff
changeset
|
11 |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
12 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
|
13 """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
|
14 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
|
15 |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
16 "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
|
17 "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
|
18 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
|
19 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
|
20 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
|
21 any longer. |
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
22 "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
|
23 |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
24 If you pass heads and they are all known locally, the reponse lists justs |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
25 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
|
26 |
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
27 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
|
28 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
|
29 """ |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
30 |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
31 if not remote.capable('getbundle'): |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
32 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
|
33 |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
34 if heads: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
35 allknown = True |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
36 nm = repo.changelog.nodemap |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
37 for h in heads: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
38 if nm.get(h) is None: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
39 allknown = False |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
40 break |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
41 if allknown: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
42 return (heads, False, heads) |
8404
a2bc39ade36b
commit: move 'nothing changed' test into commit()
Matt Mackall <mpm@selenic.com>
parents:
8403
diff
changeset
|
43 |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
44 res = setdiscovery.findcommonheads(repo.ui, repo, remote, |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
45 abortwhenunrelated=not force) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
46 common, anyinc, srvheads = res |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
47 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
|
48 |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
49 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
|
50 '''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
|
51 (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
|
52 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
53 Members: |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
54 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
61 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
|
62 by discovery.''' |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
63 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
72 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
|
73 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
|
74 self.missingheads) |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
75 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
|
76 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
77 @util.propertycache |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
78 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
|
79 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
|
80 self._computecommonmissing() |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
81 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
|
82 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
83 @util.propertycache |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
84 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
|
85 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
|
86 self._computecommonmissing() |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
87 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
|
88 |
16683 | 89 def findcommonoutgoing(repo, other, onlyheads=None, force=False, |
16746 | 90 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
|
91 '''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
|
92 not in other. |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
93 |
16683 | 94 If onlyheads is given, only nodes ancestral to nodes in onlyheads |
95 (inclusive) are included. If you already know the local repo's heads, | |
96 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
|
97 |
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
98 If commoninc is given, it must the the result of a prior call to |
16736
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
99 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
|
100 |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
101 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
|
102 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
|
103 # 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
|
104 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
|
105 |
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
106 # 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
|
107 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
|
108 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
|
109 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
|
110 |
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
111 # compute outgoing |
17206
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 # use visible heads as it should be cached |
17205
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
117 og.missingheads = visibleheads(repo) |
17206
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
118 # extinct changesets are silently ignored |
15838
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
119 og.excluded = [ctx.node() for ctx in repo.set('secret()')] |
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
120 else: |
7299e09a85a2
phases: make outgoing object and discovery aware of exclusion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15837
diff
changeset
|
121 # 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
|
122 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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 ctx = repo[node] |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
128 if not ctx.extinct(): |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
129 # extinct changesets are silently ignored |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
130 if ctx.phase() >= phases.secret: |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
131 excluded.append(node) |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
132 else: |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
133 missing.append(node) |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
134 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
|
135 missingheads = onlyheads |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
136 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
|
137 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
|
138 og.missingheads = missingheads |
16736
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
139 if portable: |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
140 # 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
|
141 # 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
|
142 # ancestors of missing |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
143 og._computecommonmissing() |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
144 cl = repo.changelog |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
145 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
|
146 og._common = set(cl.ancestors(missingrevs)) - missingrevs |
16736
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
147 commonheads = set(og.commonheads) |
025b3b763ba9
bundle: make bundles more portable (isue3441)
Sune Foldager <cryo@cyanite.org>
parents:
16535
diff
changeset
|
148 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
|
149 |
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 return og |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
151 |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
152 def _headssummary(repo, remote, outgoing): |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
153 """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
|
154 |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
155 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
|
156 |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
157 - branch: the branch name |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
158 - remoteheads: the list of remote heads known locally |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
159 None is the branch is new |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
160 - 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
|
161 - 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
|
162 """ |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
163 cl = repo.changelog |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
164 headssum = {} |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
165 # 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
|
166 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
|
167 remotemap = remote.branchmap() |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
168 newbranches = branches - set(remotemap) |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
169 branches.difference_update(newbranches) |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
170 |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
171 # A. register remote heads |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
172 remotebranches = set() |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
173 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
|
174 remotebranches.add(branch) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
175 known = [] |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
176 unsynced = [] |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
177 for h in heads: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
178 if h in cl.nodemap: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
179 known.append(h) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
180 else: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
181 unsynced.append(h) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
182 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
|
183 # 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
|
184 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
|
185 touchedbranches = set() |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
186 for ctx in missingctx: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
187 branch = ctx.branch() |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
188 touchedbranches.add(branch) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
189 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
|
190 headssum[branch] = (None, [], []) |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
191 |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
192 # 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
|
193 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
|
194 del headssum[branch] |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
195 |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
196 # D. Update newmap with outgoing changes. |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
197 # This will possibly add new heads and remove existing ones. |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
198 newmap = dict((branch, heads[1]) 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
|
199 if heads[0] is not None) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
200 repo._updatebranchcache(newmap, missingctx) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
201 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
|
202 headssum[branch][1][:] = newheads |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
203 return headssum |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
204 |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
205 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
|
206 """Compute branchmapsummary for repo without branchmap support""" |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
207 |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
208 cl = repo.changelog |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
209 # 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
|
210 # Construct {old,new}map with branch = None (topological branch). |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
211 # (code based on _updatebranchcache) |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
212 oldheads = set(h for h in remoteheads if h in cl.nodemap) |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
213 # 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
|
214 # - an element of oldheads |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
215 # - another element of outgoing.missing |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
216 # - nullrev |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
217 # 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
|
218 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
|
219 newheads = list(c.node() for c in r) |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
220 unsynced = inc and set([None]) or set() |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
221 return {None: (oldheads, newheads, unsynced)} |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
222 |
15986
ba959f6e10f8
discovery: fix regression when checking heads for pre 1.4 client (issue3218)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15955
diff
changeset
|
223 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False): |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
224 """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
|
225 |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
226 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
|
227 """ |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
228 # 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
|
229 # 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
|
230 # - unknown locally |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
231 # - a local outgoing head descended from update |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
232 # - 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
|
233 # 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
|
234 if remoteheads == [nullid]: |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
235 # 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
|
236 return |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2424
diff
changeset
|
237 |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
238 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
|
239 headssum = _headssummary(repo, remote, outgoing) |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
240 else: |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
241 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
|
242 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
|
243 if heads[0] is None] |
17209
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
244 # 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
|
245 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
|
246 branchnames = ', '.join(sorted(newbranches)) |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
247 raise util.Abort(_("push creates new remote branches: %s!") |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
248 % branchnames, |
5cd3e526ac37
checkheads: extract branchmap preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17206
diff
changeset
|
249 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
|
250 " new remote branches")) |
1466
b6d9ea0bc107
Added a lot of comments to changegroupsubset.
Eric Hopper <hopper@omnifarious.org>
parents:
1464
diff
changeset
|
251 |
17212
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
252 # 2 compute newly pushed bookmarks. We |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
253 # we don't warned about bookmarked heads. |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
254 localbookmarks = repo._bookmarks |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
255 remotebookmarks = remote.listkeys('bookmarks') |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
256 bookmarkedheads = set() |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
257 for bm in localbookmarks: |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
258 rnode = remotebookmarks.get(bm) |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
259 if rnode and rnode in repo: |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
260 lctx, rctx = repo[bm], repo[rnode] |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
261 if rctx == lctx.ancestor(rctx): |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
262 bookmarkedheads.add(lctx.node()) |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
263 |
246131d670c2
checkheads: extract bookmark computation from the branch loop
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17211
diff
changeset
|
264 # 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
|
265 # 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
|
266 # error message, depending on unsynced status, is displayed. |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
267 error = None |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
268 unsynced = False |
17214
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
269 allmissing = set(outgoing.missing) |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
270 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
|
271 if heads[0] is None: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
272 # Maybe we should abort if we push more that one head |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
273 # for new branches ? |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
274 continue |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
275 if heads[2]: |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
276 unsynced = True |
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
277 oldhs = set(heads[0]) |
17214
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
278 candidate_newhs = set(heads[1]) |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
279 # add unsynced data |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
280 oldhs.update(heads[2]) |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
281 candidate_newhs.update(heads[2]) |
16835
4267c840c481
bookmarks: allow existing remote bookmarks to become heads when pushing
Levi Bard <levi@unity3d.com>
parents:
16746
diff
changeset
|
282 dhs = None |
17214
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
283 if repo.obsstore: |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
284 # remove future heads which are actually obsolete by another |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
285 # pushed element: |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
286 # |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
287 # XXX There is several case this case does not handle properly |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
288 # |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
289 # (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
|
290 # 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
|
291 # |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
292 # (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
|
293 # 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
|
294 # |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
295 # This two case will be easy to handle for know changeset but much |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
296 # more tricky for unsynced changes. |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
297 newhs = set() |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
298 for nh in candidate_newhs: |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
299 for suc in obsolete.anysuccessors(repo.obsstore, nh): |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
300 if suc != nh and suc in allmissing: |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
301 break |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
302 else: |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
303 newhs.add(nh) |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
304 else: |
738ad56dd8a6
checkheads: take future obsoleted heads into account
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17212
diff
changeset
|
305 newhs = candidate_newhs |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
306 if len(newhs) > len(oldhs): |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
307 # strip updates to existing remote heads from the new heads list |
16835
4267c840c481
bookmarks: allow existing remote bookmarks to become heads when pushing
Levi Bard <levi@unity3d.com>
parents:
16746
diff
changeset
|
308 dhs = list(newhs - bookmarkedheads - oldhs) |
4267c840c481
bookmarks: allow existing remote bookmarks to become heads when pushing
Levi Bard <levi@unity3d.com>
parents:
16746
diff
changeset
|
309 if dhs: |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
310 if error is None: |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
311 if branch not in ('default', None): |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
312 error = _("push creates new remote head %s " |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
313 "on branch '%s'!") % (short(dhs[0]), branch) |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
314 else: |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
315 error = _("push creates new remote head %s!" |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
316 ) % short(dhs[0]) |
17211
4f321eecbf8d
checkheads: simplify the structure build by preprocessing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17209
diff
changeset
|
317 if heads[2]: # unsynced |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
318 hint = _("you should pull and merge or " |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
319 "use push -f to force") |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
320 else: |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
321 hint = _("did you forget to merge? " |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
322 "use push -f to force") |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
323 if branch is not None: |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
324 repo.ui.note(_("new remote heads on branch '%s'\n") % branch) |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
325 for h in dhs: |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
326 repo.ui.note(_("new remote head %s\n") % short(h)) |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
327 if error: |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
328 raise util.Abort(error, hint=hint) |
11578
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
329 |
15932
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
330 # 6. Check for unsynced changes on involved branches. |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
331 if unsynced: |
4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15893
diff
changeset
|
332 repo.ui.warn(_("note: unsynced remote changes!\n")) |
17205
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
333 |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
334 def visibleheads(repo): |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
335 """return the set of visible head of this repo""" |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
336 # XXX we want a cache on this |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
337 sroots = repo._phasecache.phaseroots[phases.secret] |
17206
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
338 if sroots or repo.obsstore: |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
339 # XXX very slow revset. storing heads or secret "boundary" |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
340 # would help. |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
341 revset = repo.set('heads(not (%ln:: + extinct()))', sroots) |
17205
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
342 |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
343 vheads = [ctx.node() for ctx in revset] |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
344 if not vheads: |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
345 vheads.append(nullid) |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
346 else: |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
347 vheads = repo.heads() |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
348 return vheads |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
349 |
17206
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
350 |
17205
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
351 def visiblebranchmap(repo): |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
352 """return a branchmap for the visible set""" |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
353 # XXX Recomputing this data on the fly is very slow. We should build a |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
354 # XXX cached version while computin the standard branchmap version. |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
355 sroots = repo._phasecache.phaseroots[phases.secret] |
17206
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
356 if sroots or repo.obsstore: |
17205
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
357 vbranchmap = {} |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
358 for branch, nodes in repo.branchmap().iteritems(): |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
359 # search for secret heads. |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
360 for n in nodes: |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
361 if repo[n].phase() >= phases.secret: |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
362 nodes = None |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
363 break |
17206
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
364 # if secret heads were found we must compute them again |
17205
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
365 if nodes is None: |
17206
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
366 s = repo.set('heads(branch(%s) - secret() - extinct())', |
70ebb4bd8083
obsolete: do not exchange extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17205
diff
changeset
|
367 branch) |
17205
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
368 nodes = [c.node() for c in s] |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
369 vbranchmap[branch] = nodes |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
370 else: |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
371 vbranchmap = repo.branchmap() |
97eff00046de
repo: move visibleheads and visiblebranchmap logic in discovery
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17204
diff
changeset
|
372 return vbranchmap |