Mercurial > hg-stable
changeset 20925:5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.
The method had 3 callers total, far too few for being kept in local repo.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 01 Apr 2014 13:59:55 -0700 |
parents | e10000369b47 |
children | 7c1ed40e3325 |
files | mercurial/changegroup.py mercurial/exchange.py mercurial/localrepo.py |
diffstat | 3 files changed, 24 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changegroup.py Tue Apr 01 13:45:48 2014 -0700 +++ b/mercurial/changegroup.py Tue Apr 01 13:59:55 2014 -0700 @@ -428,3 +428,20 @@ 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')
--- a/mercurial/exchange.py Tue Apr 01 13:45:48 2014 -0700 +++ b/mercurial/exchange.py Tue Apr 01 13:59:55 2014 -0700 @@ -181,10 +181,11 @@ # 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)
--- a/mercurial/localrepo.py Tue Apr 01 13:45:48 2014 -0700 +++ b/mercurial/localrepo.py Tue Apr 01 13:59:55 2014 -0700 @@ -1714,7 +1714,7 @@ 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 @@ 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 @@ 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)