Show More
@@ -977,18 +977,18 b' def bundle(ui, repo, fname, dest=None, *' | |||
|
977 | 977 | raise util.Abort(_("--base is incompatible with specifying " |
|
978 | 978 | "a destination")) |
|
979 | 979 | common = [repo.lookup(rev) for rev in base] |
|
980 |
|
|
|
980 | heads = revs and map(repo.lookup, revs) or revs | |
|
981 | cg = repo.getbundle('bundle', heads=heads, common=common) | |
|
981 | 982 | else: |
|
982 | 983 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
983 | 984 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
984 | 985 | other = hg.peer(repo, opts, dest) |
|
985 | 986 | revs, checkout = hg.addbranchrevs(repo, other, branches, revs) |
|
986 | 987 | heads = revs and map(repo.lookup, revs) or revs |
|
987 |
|
|
|
988 |
|
|
|
989 |
|
|
|
990 | ||
|
991 | cg = repo.getbundle('bundle', common=common, heads=outheads) | |
|
988 | outgoing = discovery.findcommonoutgoing(repo, other, | |
|
989 | onlyheads=heads, | |
|
990 | force=opts.get('force')) | |
|
991 | cg = repo.getlocalbundle('bundle', outgoing) | |
|
992 | 992 | if not cg: |
|
993 | 993 | ui.status(_("no changes found\n")) |
|
994 | 994 | return 1 |
@@ -5436,10 +5436,10 b' def summary(ui, repo, **opts):' | |||
|
5436 | 5436 | commoninc = None |
|
5437 | 5437 | ui.debug('comparing with %s\n' % util.hidepassword(dest)) |
|
5438 | 5438 | repo.ui.pushbuffer() |
|
5439 |
|
|
|
5440 |
|
|
|
5439 | outgoing = discovery.findcommonoutgoing(repo, other, | |
|
5440 | commoninc=commoninc) | |
|
5441 | 5441 | repo.ui.popbuffer() |
|
5442 | o = repo.changelog.findmissing(common=common, heads=outheads) | |
|
5442 | o = outgoing.missing | |
|
5443 | 5443 | if o: |
|
5444 | 5444 | t.append(_('%d outgoing') % len(o)) |
|
5445 | 5445 | if 'bookmarks' in other.listkeys('namespaces'): |
@@ -46,20 +46,56 b' def findcommonincoming(repo, remote, hea' | |||
|
46 | 46 | common, anyinc, srvheads = res |
|
47 | 47 | return (list(common), anyinc, heads or list(srvheads)) |
|
48 | 48 | |
|
49 | class outgoing(object): | |
|
50 | '''Represents the set of nodes present in a local repo but not in a | |
|
51 | (possibly) remote one. | |
|
52 | ||
|
53 | Members: | |
|
54 | ||
|
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. | |
|
57 | missingheads is the list of heads of missing. | |
|
58 | commonheads is the list of heads of common. | |
|
59 | ||
|
60 | The sets are computed on demand from the heads, unless provided upfront | |
|
61 | by discovery.''' | |
|
62 | ||
|
63 | def __init__(self, revlog, commonheads, missingheads): | |
|
64 | self.commonheads = commonheads | |
|
65 | self.missingheads = missingheads | |
|
66 | self._revlog = revlog | |
|
67 | self._common = None | |
|
68 | self._missing = None | |
|
69 | ||
|
70 | def _computecommonmissing(self): | |
|
71 | sets = self._revlog.findcommonmissing(self.commonheads, | |
|
72 | self.missingheads) | |
|
73 | self._common, self._missing = sets | |
|
74 | ||
|
75 | @util.propertycache | |
|
76 | def common(self): | |
|
77 | if self._common is None: | |
|
78 | self._computecommonmissing() | |
|
79 | return self._common | |
|
80 | ||
|
81 | @util.propertycache | |
|
82 | def missing(self): | |
|
83 | if self._missing is None: | |
|
84 | self._computecommonmissing() | |
|
85 | return self._missing | |
|
86 | ||
|
49 | 87 | def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): |
|
50 |
'''Return a |
|
|
51 | of nodes present in repo but not in other. | |
|
88 | '''Return an outgoing instance to identify the nodes present in repo but | |
|
89 | not in other. | |
|
52 | 90 | |
|
53 | 91 | If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) |
|
54 | 92 | are included. If you already know the local repo's heads, passing them in |
|
55 | 93 | onlyheads is faster than letting them be recomputed here. |
|
56 | 94 | |
|
57 | 95 | 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.''' | |
|
96 | findcommonincoming(repo, other, force) to avoid recomputing it here.''' | |
|
61 | 97 | common, _any, _hds = commoninc or findcommonincoming(repo, other, force=force) |
|
62 | return (common, onlyheads or repo.heads()) | |
|
98 | return outgoing(repo.changelog, common, onlyheads or repo.heads()) | |
|
63 | 99 | |
|
64 | 100 | def prepush(repo, remote, force, revs, newbranch): |
|
65 | 101 | '''Analyze the local and remote repositories and determine which |
@@ -80,12 +116,13 b' def prepush(repo, remote, force, revs, n' | |||
|
80 | 116 | be after push completion. |
|
81 | 117 | ''' |
|
82 | 118 | commoninc = findcommonincoming(repo, remote, force=force) |
|
83 |
|
|
|
119 | outgoing = findcommonoutgoing(repo, remote, onlyheads=revs, | |
|
84 | 120 | commoninc=commoninc, force=force) |
|
85 | 121 | _common, inc, remoteheads = commoninc |
|
86 | 122 | |
|
87 | 123 | cl = repo.changelog |
|
88 |
alloutg = |
|
|
124 | alloutg = outgoing.missing | |
|
125 | common = outgoing.commonheads | |
|
89 | 126 | outg = [] |
|
90 | 127 | secret = [] |
|
91 | 128 | for o in alloutg: |
@@ -208,7 +245,7 b' def prepush(repo, remote, force, revs, n' | |||
|
208 | 245 | # use the fast path, no race possible on push |
|
209 | 246 | cg = repo._changegroup(outg, 'push') |
|
210 | 247 | else: |
|
211 |
cg = repo.getbundle('push', |
|
|
248 | cg = repo.getlocalbundle('push', outgoing) | |
|
212 | 249 | # no need to compute outg ancestor. All node in outg have either: |
|
213 | 250 | # - parents in outg |
|
214 | 251 | # - parents in common |
@@ -507,9 +507,9 b' def _outgoing(ui, repo, dest, opts):' | |||
|
507 | 507 | revs = [repo.lookup(rev) for rev in revs] |
|
508 | 508 | |
|
509 | 509 | other = peer(repo, opts, dest) |
|
510 |
|
|
|
511 |
|
|
|
512 | o = repo.changelog.findmissing(common, outheads) | |
|
510 | outgoing = discovery.findcommonoutgoing(repo, other, revs, | |
|
511 | force=opts.get('force')) | |
|
512 | o = outgoing.missing | |
|
513 | 513 | if not o: |
|
514 | 514 | ui.status(_("no changes found\n")) |
|
515 | 515 | return None |
@@ -1739,6 +1739,18 b' class localrepository(repo.repository):' | |||
|
1739 | 1739 | common = set(cl.ancestors(*[cl.rev(n) for n in bases])) |
|
1740 | 1740 | return self._changegroupsubset(common, csets, heads, source) |
|
1741 | 1741 | |
|
1742 | def getlocalbundle(self, source, outgoing): | |
|
1743 | """Like getbundle, but taking a discovery.outgoing as an argument. | |
|
1744 | ||
|
1745 | This is only implemented for local repos and reuses potentially | |
|
1746 | precomputed sets in outgoing.""" | |
|
1747 | if not outgoing.missing: | |
|
1748 | return None | |
|
1749 | return self._changegroupsubset(outgoing.common, | |
|
1750 | outgoing.missing, | |
|
1751 | outgoing.missingheads, | |
|
1752 | source) | |
|
1753 | ||
|
1742 | 1754 | def getbundle(self, source, heads=None, common=None): |
|
1743 | 1755 | """Like changegroupsubset, but returns the set difference between the |
|
1744 | 1756 | ancestors of heads and the ancestors common. |
@@ -1756,10 +1768,8 b' class localrepository(repo.repository):' | |||
|
1756 | 1768 | common = [nullid] |
|
1757 | 1769 | if not heads: |
|
1758 | 1770 | heads = cl.heads() |
|
1759 | common, missing = cl.findcommonmissing(common, heads) | |
|
1760 | if not missing: | |
|
1761 | return None | |
|
1762 | return self._changegroupsubset(common, missing, heads, source) | |
|
1771 | return self.getlocalbundle(source, | |
|
1772 | discovery.outgoing(cl, common, heads)) | |
|
1763 | 1773 | |
|
1764 | 1774 | def _changegroupsubset(self, commonrevs, csets, heads, source): |
|
1765 | 1775 |
@@ -644,10 +644,10 b' def outgoing(repo, subset, x):' | |||
|
644 | 644 | revs = [repo.lookup(rev) for rev in revs] |
|
645 | 645 | other = hg.peer(repo, {}, dest) |
|
646 | 646 | repo.ui.pushbuffer() |
|
647 |
|
|
|
647 | outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs) | |
|
648 | 648 | repo.ui.popbuffer() |
|
649 | 649 | cl = repo.changelog |
|
650 |
o = set([cl.rev(r) for r in |
|
|
650 | o = set([cl.rev(r) for r in outgoing.missing]) | |
|
651 | 651 | return [r for r in subset if r in o] |
|
652 | 652 | |
|
653 | 653 | def p1(repo, subset, x): |
General Comments 0
You need to be logged in to leave comments.
Login now