Show More
@@ -7,7 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from node import nullid, short |
|
8 | from node import nullid, short | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import util, setdiscovery, treediscovery |
|
10 | import util, setdiscovery, treediscovery, phases | |
11 |
|
11 | |||
12 | def findcommonincoming(repo, remote, heads=None, force=False): |
|
12 | def findcommonincoming(repo, remote, heads=None, force=False): | |
13 | """Return a tuple (common, anyincoming, heads) used to identify the common |
|
13 | """Return a tuple (common, anyincoming, heads) used to identify the common | |
@@ -54,6 +54,7 b' class outgoing(object):' | |||||
54 |
|
54 | |||
55 | missing is a list of all nodes present in local but not in remote. |
|
55 | missing is a list of all nodes present in local but not in remote. | |
56 | common is a list of all nodes shared between the two repos. |
|
56 | common is a list of all nodes shared between the two repos. | |
|
57 | excluded is the list of missing changeset that shouldn't be sent remotely. | |||
57 | missingheads is the list of heads of missing. |
|
58 | missingheads is the list of heads of missing. | |
58 | commonheads is the list of heads of common. |
|
59 | commonheads is the list of heads of common. | |
59 |
|
60 | |||
@@ -66,6 +67,7 b' class outgoing(object):' | |||||
66 | self._revlog = revlog |
|
67 | self._revlog = revlog | |
67 | self._common = None |
|
68 | self._common = None | |
68 | self._missing = None |
|
69 | self._missing = None | |
|
70 | self.excluded = [] | |||
69 |
|
71 | |||
70 | def _computecommonmissing(self): |
|
72 | def _computecommonmissing(self): | |
71 | sets = self._revlog.findcommonmissing(self.commonheads, |
|
73 | sets = self._revlog.findcommonmissing(self.commonheads, | |
@@ -94,8 +96,41 b' def findcommonoutgoing(repo, other, only' | |||||
94 |
|
96 | |||
95 | If commoninc is given, it must the the result of a prior call to |
|
97 | If commoninc is given, it must the the result of a prior call to | |
96 | findcommonincoming(repo, other, force) to avoid recomputing it here.''' |
|
98 | findcommonincoming(repo, other, force) to avoid recomputing it here.''' | |
97 | common, _any, _hds = commoninc or findcommonincoming(repo, other, force=force) |
|
99 | # declare an empty outgoing object to be filled later | |
98 |
|
|
100 | og = outgoing(repo.changelog, None, None) | |
|
101 | ||||
|
102 | # get common set if not provided | |||
|
103 | if commoninc is None: | |||
|
104 | commoninc = findcommonincoming(repo, other, force=force) | |||
|
105 | og.commonheads, _any, _hds = commoninc | |||
|
106 | ||||
|
107 | # compute outgoing | |||
|
108 | if not repo._phaseroots[phases.secret]: | |||
|
109 | og.missingheads = onlyheads or repo.heads() | |||
|
110 | elif onlyheads is None: | |||
|
111 | # use visible heads as it should be cached | |||
|
112 | og.missingheads = phases.visibleheads(repo) | |||
|
113 | og.excluded = [ctx.node() for ctx in repo.set('secret()')] | |||
|
114 | else: | |||
|
115 | # compute common, missing and exclude secret stuff | |||
|
116 | sets = repo.changelog.findcommonmissing(og.commonheads, onlyheads) | |||
|
117 | og._common, allmissing = sets | |||
|
118 | og._missing = missing = [] | |||
|
119 | og._excluded = excluded = [] | |||
|
120 | for node in allmissing: | |||
|
121 | if repo[node].phase() >= phases.secret: | |||
|
122 | excluded.append(node) | |||
|
123 | else: | |||
|
124 | missing.append(node) | |||
|
125 | if excluded: | |||
|
126 | # update missing heads | |||
|
127 | rset = repo.set('heads(%ln)', missing) | |||
|
128 | missingheads = [ctx.node() for ctx in rset] | |||
|
129 | else: | |||
|
130 | missingheads = onlyheads | |||
|
131 | og.missingheads = missingheads | |||
|
132 | ||||
|
133 | return og | |||
99 |
|
134 | |||
100 | def prepush(repo, remote, force, revs, newbranch): |
|
135 | def prepush(repo, remote, force, revs, newbranch): | |
101 | '''Analyze the local and remote repositories and determine which |
|
136 | '''Analyze the local and remote repositories and determine which | |
@@ -121,29 +156,17 b' def prepush(repo, remote, force, revs, n' | |||||
121 | _common, inc, remoteheads = commoninc |
|
156 | _common, inc, remoteheads = commoninc | |
122 |
|
157 | |||
123 | cl = repo.changelog |
|
158 | cl = repo.changelog | |
124 |
|
|
159 | outg = outgoing.missing | |
125 | common = outgoing.commonheads |
|
160 | common = outgoing.commonheads | |
126 | outg = [] |
|
|||
127 | secret = [] |
|
|||
128 | for o in alloutg: |
|
|||
129 | if repo[o].phase() >= 2: |
|
|||
130 | secret.append(o) |
|
|||
131 | else: |
|
|||
132 | outg.append(o) |
|
|||
133 |
|
161 | |||
134 | if not outg: |
|
162 | if not outg: | |
135 |
if |
|
163 | if outgoing.excluded: | |
136 | repo.ui.status(_("no changes to push but %i secret changesets\n") |
|
164 | repo.ui.status(_("no changes to push but %i secret changesets\n") | |
137 |
% len( |
|
165 | % len(outgoing.excluded)) | |
138 | else: |
|
166 | else: | |
139 | repo.ui.status(_("no changes found\n")) |
|
167 | repo.ui.status(_("no changes found\n")) | |
140 | return None, 1, common |
|
168 | return None, 1, common | |
141 |
|
169 | |||
142 | if secret: |
|
|||
143 | # recompute target revs |
|
|||
144 | revs = [ctx.node() for ctx in repo.set('heads(::(%ld))', |
|
|||
145 | map(repo.changelog.rev, outg))] |
|
|||
146 |
|
||||
147 | if not force and remoteheads != [nullid]: |
|
170 | if not force and remoteheads != [nullid]: | |
148 | if remote.capable('branchmap'): |
|
171 | if remote.capable('branchmap'): | |
149 | # Check for each named branch if we're creating new remote heads. |
|
172 | # Check for each named branch if we're creating new remote heads. | |
@@ -241,7 +264,8 b' def prepush(repo, remote, force, revs, n' | |||||
241 | if unsynced: |
|
264 | if unsynced: | |
242 | repo.ui.warn(_("note: unsynced remote changes!\n")) |
|
265 | repo.ui.warn(_("note: unsynced remote changes!\n")) | |
243 |
|
266 | |||
244 | if revs is None: |
|
267 | if revs is None and not outgoing.excluded: | |
|
268 | # push everything, | |||
245 | # use the fast path, no race possible on push |
|
269 | # use the fast path, no race possible on push | |
246 | cg = repo._changegroup(outg, 'push') |
|
270 | cg = repo._changegroup(outg, 'push') | |
247 | else: |
|
271 | else: |
@@ -351,9 +351,6 b'' | |||||
351 | > If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) |
|
351 | > If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) | |
352 | warning: line over 80 characters |
|
352 | warning: line over 80 characters | |
353 | mercurial/discovery.py:0: |
|
353 | mercurial/discovery.py:0: | |
354 | > common, _any, _hds = commoninc or findcommonincoming(repo, other, force=force) |
|
|||
355 | warning: line over 80 characters |
|
|||
356 | mercurial/discovery.py:0: |
|
|||
357 | > def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): |
|
354 | > def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): | |
358 | warning: line over 80 characters |
|
355 | warning: line over 80 characters | |
359 | mercurial/dispatch.py:0: |
|
356 | mercurial/dispatch.py:0: |
@@ -95,6 +95,23 b' Test secret changeset are not pushed' | |||||
95 | > [phases] |
|
95 | > [phases] | |
96 | > publish=False |
|
96 | > publish=False | |
97 | > EOF |
|
97 | > EOF | |
|
98 | $ hg outgoing ../push-dest --template='{rev} {phase} {desc|firstline}\n' | |||
|
99 | comparing with ../push-dest | |||
|
100 | searching for changes | |||
|
101 | 0 public A | |||
|
102 | 1 public B | |||
|
103 | 2 draft C | |||
|
104 | 3 draft D | |||
|
105 | 6 draft B' | |||
|
106 | $ hg outgoing -r default ../push-dest --template='{rev} {phase} {desc|firstline}\n' | |||
|
107 | comparing with ../push-dest | |||
|
108 | searching for changes | |||
|
109 | 0 public A | |||
|
110 | 1 public B | |||
|
111 | 2 draft C | |||
|
112 | 3 draft D | |||
|
113 | 6 draft B' | |||
|
114 | ||||
98 | $ hg push ../push-dest -f # force because we push multiple heads |
|
115 | $ hg push ../push-dest -f # force because we push multiple heads | |
99 | pushing to ../push-dest |
|
116 | pushing to ../push-dest | |
100 | searching for changes |
|
117 | searching for changes | |
@@ -140,6 +157,13 b' Test secret changeset are not pull' | |||||
140 | 0 0 A |
|
157 | 0 0 A | |
141 | $ cd .. |
|
158 | $ cd .. | |
142 |
|
159 | |||
|
160 | But secret can still be bundled explicitly | |||
|
161 | ||||
|
162 | $ cd initialrepo | |||
|
163 | $ hg bundle --base '4^' -r 'children(4)' ../secret-bundle.hg | |||
|
164 | 4 changesets found | |||
|
165 | $ cd .. | |||
|
166 | ||||
143 | Test revset |
|
167 | Test revset | |
144 |
|
168 | |||
145 | $ cd initialrepo |
|
169 | $ cd initialrepo |
General Comments 0
You need to be logged in to leave comments.
Login now