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