mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
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.
This commit is contained in:
parent
bbcab6cdef
commit
045d614415
@ -296,6 +296,11 @@ class bundle10(object):
|
||||
|
||||
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 @@ class bundle10(object):
|
||||
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 @@ class bundle10(object):
|
||||
|
||||
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 @@ class bundle10(object):
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user