diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -428,3 +428,20 @@ class bundle10(object): def builddeltaheader(self, node, p1n, p2n, basenode, linknode): # do nothing with basenode, it is implicitly the previous one in HG10 return struct.pack(self.deltaheader, node, p1n, p2n, linknode) + +def getsubset(repo, outgoing, bundler, source, fastpath=False): + repo = repo.unfiltered() + commonrevs = outgoing.common + csets = outgoing.missing + heads = outgoing.missingheads + # We go through the fast path if we get told to, or if all (unfiltered + # heads have been requested (since we then know there all linkrevs will + # be pulled by the client). + heads.sort() + fastpathlinkrev = fastpath or ( + repo.filtername is None and heads == sorted(repo.heads())) + + repo.hook('preoutgoing', throw=True, source=source) + repo.changegroupinfo(csets, source) + gengroup = bundler.generate(commonrevs, csets, fastpathlinkrev, source) + return unbundle10(util.chunkbuffer(gengroup), 'UN') diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -181,10 +181,11 @@ def _pushchangeset(pushop): # push everything, # use the fast path, no race possible on push bundler = changegroup.bundle10(pushop.repo, bundlecaps) - cg = pushop.repo._changegroupsubset(outgoing, - bundler, - 'push', - fastpath=True) + cg = changegroup.getsubset(pushop.repo, + outgoing, + bundler, + 'push', + fastpath=True) else: cg = pushop.repo.getlocalbundle('push', outgoing, bundlecaps) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1714,7 +1714,7 @@ class localrepository(object): discbases.extend([p for p in cl.parents(n) if p != nullid]) outgoing = discovery.outgoing(cl, discbases, heads) bundler = changegroup.bundle10(self) - return self._changegroupsubset(outgoing, bundler, source) + return changegroup.getsubset(self, outgoing, bundler, source) def getlocalbundle(self, source, outgoing, bundlecaps=None): """Like getbundle, but taking a discovery.outgoing as an argument. @@ -1724,7 +1724,7 @@ class localrepository(object): if not outgoing.missing: return None bundler = changegroup.bundle10(self, bundlecaps) - return self._changegroupsubset(outgoing, bundler, source) + return changegroup.getsubset(self, outgoing, bundler, source) def getbundle(self, source, heads=None, common=None, bundlecaps=None): """Like changegroupsubset, but returns the set difference between the @@ -1747,24 +1747,6 @@ class localrepository(object): discovery.outgoing(cl, common, heads), bundlecaps=bundlecaps) - @unfilteredmethod - def _changegroupsubset(self, outgoing, bundler, source, - fastpath=False): - commonrevs = outgoing.common - csets = outgoing.missing - heads = outgoing.missingheads - # We go through the fast path if we get told to, or if all (unfiltered - # heads have been requested (since we then know there all linkrevs will - # be pulled by the client). - heads.sort() - fastpathlinkrev = fastpath or ( - self.filtername is None and heads == sorted(self.heads())) - - self.hook('preoutgoing', throw=True, source=source) - self.changegroupinfo(csets, source) - gengroup = bundler.generate(commonrevs, csets, fastpathlinkrev, source) - return changegroup.unbundle10(util.chunkbuffer(gengroup), 'UN') - def changegroup(self, basenodes, source): # to avoid a race we use changegroupsubset() (issue1320) return self.changegroupsubset(basenodes, self.heads(), source)