Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 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 |
comparison
equal
deleted
inserted
replaced
20924:e10000369b47 | 20925:5174c48ed8d8 |
---|---|
1712 discbases = [] | 1712 discbases = [] |
1713 for n in roots: | 1713 for n in roots: |
1714 discbases.extend([p for p in cl.parents(n) if p != nullid]) | 1714 discbases.extend([p for p in cl.parents(n) if p != nullid]) |
1715 outgoing = discovery.outgoing(cl, discbases, heads) | 1715 outgoing = discovery.outgoing(cl, discbases, heads) |
1716 bundler = changegroup.bundle10(self) | 1716 bundler = changegroup.bundle10(self) |
1717 return self._changegroupsubset(outgoing, bundler, source) | 1717 return changegroup.getsubset(self, outgoing, bundler, source) |
1718 | 1718 |
1719 def getlocalbundle(self, source, outgoing, bundlecaps=None): | 1719 def getlocalbundle(self, source, outgoing, bundlecaps=None): |
1720 """Like getbundle, but taking a discovery.outgoing as an argument. | 1720 """Like getbundle, but taking a discovery.outgoing as an argument. |
1721 | 1721 |
1722 This is only implemented for local repos and reuses potentially | 1722 This is only implemented for local repos and reuses potentially |
1723 precomputed sets in outgoing.""" | 1723 precomputed sets in outgoing.""" |
1724 if not outgoing.missing: | 1724 if not outgoing.missing: |
1725 return None | 1725 return None |
1726 bundler = changegroup.bundle10(self, bundlecaps) | 1726 bundler = changegroup.bundle10(self, bundlecaps) |
1727 return self._changegroupsubset(outgoing, bundler, source) | 1727 return changegroup.getsubset(self, outgoing, bundler, source) |
1728 | 1728 |
1729 def getbundle(self, source, heads=None, common=None, bundlecaps=None): | 1729 def getbundle(self, source, heads=None, common=None, bundlecaps=None): |
1730 """Like changegroupsubset, but returns the set difference between the | 1730 """Like changegroupsubset, but returns the set difference between the |
1731 ancestors of heads and the ancestors common. | 1731 ancestors of heads and the ancestors common. |
1732 | 1732 |
1744 if not heads: | 1744 if not heads: |
1745 heads = cl.heads() | 1745 heads = cl.heads() |
1746 return self.getlocalbundle(source, | 1746 return self.getlocalbundle(source, |
1747 discovery.outgoing(cl, common, heads), | 1747 discovery.outgoing(cl, common, heads), |
1748 bundlecaps=bundlecaps) | 1748 bundlecaps=bundlecaps) |
1749 | |
1750 @unfilteredmethod | |
1751 def _changegroupsubset(self, outgoing, bundler, source, | |
1752 fastpath=False): | |
1753 commonrevs = outgoing.common | |
1754 csets = outgoing.missing | |
1755 heads = outgoing.missingheads | |
1756 # We go through the fast path if we get told to, or if all (unfiltered | |
1757 # heads have been requested (since we then know there all linkrevs will | |
1758 # be pulled by the client). | |
1759 heads.sort() | |
1760 fastpathlinkrev = fastpath or ( | |
1761 self.filtername is None and heads == sorted(self.heads())) | |
1762 | |
1763 self.hook('preoutgoing', throw=True, source=source) | |
1764 self.changegroupinfo(csets, source) | |
1765 gengroup = bundler.generate(commonrevs, csets, fastpathlinkrev, source) | |
1766 return changegroup.unbundle10(util.chunkbuffer(gengroup), 'UN') | |
1767 | 1749 |
1768 def changegroup(self, basenodes, source): | 1750 def changegroup(self, basenodes, source): |
1769 # to avoid a race we use changegroupsubset() (issue1320) | 1751 # to avoid a race we use changegroupsubset() (issue1320) |
1770 return self.changegroupsubset(basenodes, self.heads(), source) | 1752 return self.changegroupsubset(basenodes, self.heads(), source) |
1771 | 1753 |