Mercurial > hg
changeset 19289:6ea1f858efd9
bundle: refactor changegroup prune to be its own function
Moving the prune function to be a non-nested function allows extensions to
control which revisions are allowed in the changegroup. For example, in my
shallow repo extension I want to prevent filelogs from being added to the
bundle.
This also allows an extension to use a filelog implementation that doesn't
have revlog.linkrev implemented.
author | Durham Goode <durham@fb.com> |
---|---|
date | Thu, 30 May 2013 17:51:13 -0700 |
parents | ec367f203cb5 |
children | f21f4a1b6c24 |
files | mercurial/changegroup.py |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changegroup.py Thu May 30 17:49:37 2013 -0700 +++ b/mercurial/changegroup.py Thu May 30 17:51:13 2013 -0700 @@ -296,6 +296,11 @@ yield self.close() + # filter any nodes that claim to be part of the known set + def prune(self, revlog, missing, commonrevs, source): + rr, rl = revlog.rev, revlog.linkrev + return [n for n in missing if rl(rr(n)) not in commonrevs] + def generate(self, commonrevs, clnodes, fastpathlinkrev, source): '''yield a sequence of changegroup chunks (strings)''' repo = self._repo @@ -311,11 +316,6 @@ fnodes = {} # needed file nodes changedfiles = set() - # filter any nodes that claim to be part of the known set - def prune(revlog, missing): - rr, rl = revlog.rev, revlog.linkrev - return [n for n in missing if rl(rr(n)) not in commonrevs] - # Callback for the changelog, used to collect changed files and manifest # nodes. # Returns the linkrev node (identity in the changelog case). @@ -347,7 +347,7 @@ for f in changedfiles: fnodes[f] = {} - mfnodes = prune(mf, mfs) + mfnodes = self.prune(mf, mfs, commonrevs, source) for chunk in self.group(mfnodes, mf, lookupmf, units=_('manifests'), reorder=reorder): yield chunk @@ -377,7 +377,7 @@ def lookupfilelog(x): return linkrevnodes[x] - filenodes = prune(filerevlog, linkrevnodes) + filenodes = self.prune(filerevlog, linkrevnodes, commonrevs, source) if filenodes: progress(msgbundling, i + 1, item=fname, unit=msgfiles, total=total)