Mercurial > hg
comparison mercurial/discovery.py @ 14213:30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
discovery.findoutgoing used to be a useful hook for extensions like
hgsubversion. This patch reintroduces this version of findcommonincoming
which is meant to be used when computing outgoing changesets.
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Fri, 06 May 2011 14:44:18 +0200 |
parents | 4ab6e2d597cc |
children | 97d2259af787 |
comparison
equal
deleted
inserted
replaced
14212:8f551386abf0 | 14213:30273f0c776b |
---|---|
21 any longer. | 21 any longer. |
22 "heads" is either the supplied heads, or else the remote's heads. | 22 "heads" is either the supplied heads, or else the remote's heads. |
23 | 23 |
24 If you pass heads and they are all known locally, the reponse lists justs | 24 If you pass heads and they are all known locally, the reponse lists justs |
25 these heads in "common" and in "heads". | 25 these heads in "common" and in "heads". |
26 | |
27 Please use findcommonoutgoing to compute the set of outgoing nodes to give | |
28 extensions a good hook into outgoing. | |
26 """ | 29 """ |
27 | 30 |
28 if not remote.capable('getbundle'): | 31 if not remote.capable('getbundle'): |
29 return treediscovery.findcommonincoming(repo, remote, heads, force) | 32 return treediscovery.findcommonincoming(repo, remote, heads, force) |
30 | 33 |
41 res = setdiscovery.findcommonheads(repo.ui, repo, remote, | 44 res = setdiscovery.findcommonheads(repo.ui, repo, remote, |
42 abortwhenunrelated=not force) | 45 abortwhenunrelated=not force) |
43 common, anyinc, srvheads = res | 46 common, anyinc, srvheads = res |
44 return (list(common), anyinc, heads or list(srvheads)) | 47 return (list(common), anyinc, heads or list(srvheads)) |
45 | 48 |
49 def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): | |
50 '''Return a tuple (common, anyoutgoing, heads) used to identify the set | |
51 of nodes present in repo but not in other. | |
52 | |
53 If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) | |
54 are included. If you already know the local repo's heads, passing them in | |
55 onlyheads is faster than letting them be recomputed here. | |
56 | |
57 If commoninc is given, it must the the result of a prior call to | |
58 findcommonincoming(repo, other, force) to avoid recomputing it here. | |
59 | |
60 The returned tuple is meant to be passed to changelog.findmissing.''' | |
61 common, _any, _hds = commoninc or findcommonincoming(repo, other, force=force) | |
62 return (common, onlyheads or repo.heads()) | |
63 | |
46 def prepush(repo, remote, force, revs, newbranch): | 64 def prepush(repo, remote, force, revs, newbranch): |
47 '''Analyze the local and remote repositories and determine which | 65 '''Analyze the local and remote repositories and determine which |
48 changesets need to be pushed to the remote. Return value depends | 66 changesets need to be pushed to the remote. Return value depends |
49 on circumstances: | 67 on circumstances: |
50 | 68 |
55 | 73 |
56 Otherwise, return a tuple (changegroup, remoteheads), where | 74 Otherwise, return a tuple (changegroup, remoteheads), where |
57 changegroup is a readable file-like object whose read() returns | 75 changegroup is a readable file-like object whose read() returns |
58 successive changegroup chunks ready to be sent over the wire and | 76 successive changegroup chunks ready to be sent over the wire and |
59 remoteheads is the list of remote heads.''' | 77 remoteheads is the list of remote heads.''' |
60 common, inc, remoteheads = findcommonincoming(repo, remote, force=force) | 78 commoninc = findcommonincoming(repo, remote, force=force) |
79 common, revs = findcommonoutgoing(repo, remote, onlyheads=revs, | |
80 commoninc=commoninc, force=force) | |
81 _common, inc, remoteheads = commoninc | |
61 | 82 |
62 cl = repo.changelog | 83 cl = repo.changelog |
63 outg = cl.findmissing(common, revs) | 84 outg = cl.findmissing(common, revs) |
64 | 85 |
65 if not outg: | 86 if not outg: |