Mercurial > public > mercurial-scm > hg
annotate mercurial/discovery.py @ 15837:cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Simplifies client logic in multiple places since it encapsulates the
computation of the common and, more importantly, the missing node lists.
This also allows an upcomping patch to communicate precomputed versions of
these lists to clients.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 09 Jan 2012 03:47:16 +0100 |
parents | cff25e4b37d2 |
children | 7299e09a85a2 |
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 _ |
14184
4ab6e2d597cc
fix errors reported by pyflakes test
Sune Foldager <cryo@cyanite.org>
parents:
14164
diff
changeset
|
10 import util, setdiscovery, treediscovery |
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. |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
57 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
|
58 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
|
59 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
60 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
|
61 by discovery.''' |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
62 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 self._missing = None |
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 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
|
71 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
|
72 self.missingheads) |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
73 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
|
74 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
75 @util.propertycache |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
76 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
|
77 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
|
78 self._computecommonmissing() |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
79 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
|
80 |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
81 @util.propertycache |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
82 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
|
83 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
|
84 self._computecommonmissing() |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
85 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
|
86 |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
87 def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
88 '''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
|
89 not in other. |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
90 |
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
91 If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) |
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
92 are included. If you already know the local repo's heads, passing them in |
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
93 onlyheads is faster than letting them be recomputed here. |
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
94 |
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
95 If commoninc is given, it must the the result of a prior call to |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
96 findcommonincoming(repo, other, force) to avoid recomputing it here.''' |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
97 common, _any, _hds = commoninc or findcommonincoming(repo, other, force=force) |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
98 return outgoing(repo.changelog, common, onlyheads or repo.heads()) |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
99 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
100 def prepush(repo, remote, force, revs, newbranch): |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
101 '''Analyze the local and remote repositories and determine which |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
102 changesets need to be pushed to the remote. Return value depends |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
103 on circumstances: |
10353
36b6b5ef7820
prepush: rename variables, refactor
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10327
diff
changeset
|
104 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
105 If we are not going to push anything, return a tuple (None, |
15485
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
106 outgoing, common) where outgoing is 0 if there are no outgoing |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
107 changesets and 1 if there are, but we refuse to push them |
15485
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
108 (e.g. would create new remote heads). The third element "common" |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
109 is the list of heads of the common set between local and remote. |
3684
975c2469c316
correct remote heads test in prepush
Matt Mackall <mpm@selenic.com>
parents:
3682
diff
changeset
|
110 |
15485
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
111 Otherwise, return a tuple (changegroup, remoteheads, futureheads), |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
112 where changegroup is a readable file-like object whose read() |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
113 returns successive changegroup chunks ready to be sent over the |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
114 wire, remoteheads is the list of remote heads and futureheads is |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
115 the list of heads of the common set between local and remote to |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
116 be after push completion. |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
117 ''' |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
118 commoninc = findcommonincoming(repo, remote, force=force) |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
119 outgoing = findcommonoutgoing(repo, remote, onlyheads=revs, |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
120 commoninc=commoninc, force=force) |
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14184
diff
changeset
|
121 _common, inc, remoteheads = commoninc |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2424
diff
changeset
|
122 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
123 cl = repo.changelog |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
124 alloutg = outgoing.missing |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
125 common = outgoing.commonheads |
15713
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
126 outg = [] |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
127 secret = [] |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
128 for o in alloutg: |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
129 if repo[o].phase() >= 2: |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
130 secret.append(o) |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
131 else: |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
132 outg.append(o) |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2424
diff
changeset
|
133 |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
134 if not outg: |
15713
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
135 if secret: |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
136 repo.ui.status(_("no changes to push but %i secret changesets\n") |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
137 % len(secret)) |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
138 else: |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
139 repo.ui.status(_("no changes found\n")) |
15485
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
140 return None, 1, common |
622
e9fe5d5e67f7
Add generic repo commands for pull and push
Matt Mackall <mpm@selenic.com>
parents:
621
diff
changeset
|
141 |
15713
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
142 if secret: |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
143 # recompute target revs |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
144 revs = [ctx.node() for ctx in repo.set('heads(::(%ld))', |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
145 map(repo.changelog.rev, outg))] |
cff25e4b37d2
phases: do not exchange secret changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15513
diff
changeset
|
146 |
11577
0bc450253312
discovery: better coding style
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11576
diff
changeset
|
147 if not force and remoteheads != [nullid]: |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
148 if remote.capable('branchmap'): |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
149 # Check for each named branch if we're creating new remote heads. |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
150 # To be a remote head after push, node must be either: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
151 # - unknown locally |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
152 # - a local outgoing head descended from update |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
153 # - a remote head that's known locally and not |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
154 # ancestral to an outgoing head |
10405
2d30d66a89ad
whitespace cleanup
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
10396
diff
changeset
|
155 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
156 # 1. Create set of branches involved in the push. |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
157 branches = set(repo[n].branch() for n in outg) |
1466
b6d9ea0bc107
Added a lot of comments to changegroupsubset.
Eric Hopper <hopper@omnifarious.org>
parents:
1464
diff
changeset
|
158 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
159 # 2. Check for new branches on the remote. |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
160 remotemap = remote.branchmap() |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
161 newbranches = branches - set(remotemap) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
162 if newbranches and not newbranch: # new branch requires --new-branch |
11429
d420ff348c49
discovery: use stable sort order in --new-branch warning
Martin Geisler <mg@aragost.com>
parents:
11313
diff
changeset
|
163 branchnames = ', '.join(sorted(newbranches)) |
11574
6381fa7bfa53
Abort: add a hint argument, printed in the next line inside parenthesis
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11573
diff
changeset
|
164 raise util.Abort(_("push creates new remote branches: %s!") |
6381fa7bfa53
Abort: add a hint argument, printed in the next line inside parenthesis
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11573
diff
changeset
|
165 % branchnames, |
6381fa7bfa53
Abort: add a hint argument, printed in the next line inside parenthesis
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11573
diff
changeset
|
166 hint=_("use 'hg push --new-branch' to create" |
6381fa7bfa53
Abort: add a hint argument, printed in the next line inside parenthesis
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11573
diff
changeset
|
167 " new remote branches")) |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
168 branches.difference_update(newbranches) |
1458
1033892bbb87
This changes the revlog.group and re-implements the localrepo.changeroup
Eric Hopper <hopper@omnifarious.org>
parents:
1457
diff
changeset
|
169 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
170 # 3. Construct the initial oldmap and newmap dicts. |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
171 # They contain information about the remote heads before and |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
172 # after the push, respectively. |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
173 # Heads not found locally are not included in either dict, |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
174 # since they won't be affected by the push. |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
175 # unsynced contains all branches with incoming changesets. |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
176 oldmap = {} |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
177 newmap = {} |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
178 unsynced = set() |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
179 for branch in branches: |
11577
0bc450253312
discovery: better coding style
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11576
diff
changeset
|
180 remotebrheads = remotemap[branch] |
0bc450253312
discovery: better coding style
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11576
diff
changeset
|
181 prunedbrheads = [h for h in remotebrheads if h in cl.nodemap] |
0bc450253312
discovery: better coding style
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11576
diff
changeset
|
182 oldmap[branch] = prunedbrheads |
0bc450253312
discovery: better coding style
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11576
diff
changeset
|
183 newmap[branch] = list(prunedbrheads) |
0bc450253312
discovery: better coding style
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11576
diff
changeset
|
184 if len(remotebrheads) > len(prunedbrheads): |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
185 unsynced.add(branch) |
635
85e2209d401c
Protocol switch from using generators to stream-like objects.
Matt Mackall <mpm@selenic.com>
parents:
634
diff
changeset
|
186 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
187 # 4. Update newmap with outgoing changes. |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
188 # This will possibly add new heads and remove existing ones. |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
189 ctxgen = (repo[n] for n in outg) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
190 repo._updatebranchcache(newmap, ctxgen) |
1998
65cc17ae9649
fix race in localrepo.addchangegroup.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1995
diff
changeset
|
191 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
192 else: |
11578
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
193 # 1-4b. old servers: Check for new topological heads. |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
194 # Construct {old,new}map with branch = None (topological branch). |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
195 # (code based on _updatebranchcache) |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
196 oldheads = set(h for h in remoteheads if h in cl.nodemap) |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
197 newheads = oldheads.union(outg) |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
198 if len(newheads) > 1: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
199 for latest in reversed(outg): |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
200 if latest not in newheads: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
201 continue |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
202 minhrev = min(cl.rev(h) for h in newheads) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
203 reachable = cl.reachable(latest, cl.node(minhrev)) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
204 reachable.remove(latest) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
205 newheads.difference_update(reachable) |
11578
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
206 branches = set([None]) |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
207 newmap = {None: newheads} |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
208 oldmap = {None: oldheads} |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
209 unsynced = inc and branches or set() |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
210 |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
211 # 5. Check for new heads. |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
212 # If there are more heads after the push than before, a suitable |
12998
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
213 # error message, depending on unsynced status, is displayed. |
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
214 error = None |
11578
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
215 for branch in branches: |
12998
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
216 newhs = set(newmap[branch]) |
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
217 oldhs = set(oldmap[branch]) |
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
218 if len(newhs) > len(oldhs): |
14525
826a13720fbc
prepush: print short hash of first new head in abort message
Adrian Buehlmann <adrian@cadifra.com>
parents:
14524
diff
changeset
|
219 dhs = list(newhs - oldhs) |
12998
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
220 if error is None: |
15292
7fa471248185
discovery: Fix error print mentioning a 'None' branch
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
14526
diff
changeset
|
221 if branch not in ('default', None): |
14525
826a13720fbc
prepush: print short hash of first new head in abort message
Adrian Buehlmann <adrian@cadifra.com>
parents:
14524
diff
changeset
|
222 error = _("push creates new remote head %s " |
826a13720fbc
prepush: print short hash of first new head in abort message
Adrian Buehlmann <adrian@cadifra.com>
parents:
14524
diff
changeset
|
223 "on branch '%s'!") % (short(dhs[0]), branch) |
826a13720fbc
prepush: print short hash of first new head in abort message
Adrian Buehlmann <adrian@cadifra.com>
parents:
14524
diff
changeset
|
224 else: |
826a13720fbc
prepush: print short hash of first new head in abort message
Adrian Buehlmann <adrian@cadifra.com>
parents:
14524
diff
changeset
|
225 error = _("push creates new remote head %s!" |
826a13720fbc
prepush: print short hash of first new head in abort message
Adrian Buehlmann <adrian@cadifra.com>
parents:
14524
diff
changeset
|
226 ) % short(dhs[0]) |
12998
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
227 if branch in unsynced: |
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
228 hint = _("you should pull and merge or " |
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
229 "use push -f to force") |
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
230 else: |
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
231 hint = _("did you forget to merge? " |
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
232 "use push -f to force") |
15292
7fa471248185
discovery: Fix error print mentioning a 'None' branch
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
14526
diff
changeset
|
233 if branch is not None: |
15497
9bea3aed6ee1
add missing localization markup
Mads Kiilerich <mads@kiilerich.com>
parents:
15292
diff
changeset
|
234 repo.ui.note(_("new remote heads on branch '%s'\n") % branch) |
14525
826a13720fbc
prepush: print short hash of first new head in abort message
Adrian Buehlmann <adrian@cadifra.com>
parents:
14524
diff
changeset
|
235 for h in dhs: |
15497
9bea3aed6ee1
add missing localization markup
Mads Kiilerich <mads@kiilerich.com>
parents:
15292
diff
changeset
|
236 repo.ui.note(_("new remote head %s\n") % short(h)) |
12998
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
237 if error: |
91cb08a9e7fb
discovery: list new remote heads in prepush() on --debug
Adrian Buehlmann <adrian@cadifra.com>
parents:
12997
diff
changeset
|
238 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
|
239 |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
240 # 6. Check for unsynced changes on involved branches. |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
241 if unsynced: |
bb7af1de5e38
discovery: remove duplication for new remote head discovery
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11577
diff
changeset
|
242 repo.ui.warn(_("note: unsynced remote changes!\n")) |
515 | 243 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
244 if revs is None: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
245 # use the fast path, no race possible on push |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
246 cg = repo._changegroup(outg, 'push') |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
247 else: |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15713
diff
changeset
|
248 cg = repo.getlocalbundle('push', outgoing) |
15485
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
249 # no need to compute outg ancestor. All node in outg have either: |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
250 # - parents in outg |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
251 # - parents in common |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
252 # - nullid parent |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
253 rset = repo.set('heads(%ln + %ln)', common, outg) |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
254 futureheads = [ctx.node() for ctx in rset] |
fa47291b3f1f
phases: mark content pushed as public in local repo on push
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15292
diff
changeset
|
255 return cg, remoteheads, futureheads |