Mercurial > hg
changeset 13782:9131724c3f4b
changegroup: combine infocollect and lookup callbacks
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 28 Mar 2011 11:18:56 -0500 |
parents | 66c54d2ebe72 |
children | c196352d935b |
files | contrib/shrink-revlog.py mercurial/localrepo.py mercurial/revlog.py |
diffstat | 3 files changed, 36 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/shrink-revlog.py Thu Mar 24 17:16:30 2011 -0500 +++ b/contrib/shrink-revlog.py Mon Mar 28 11:18:56 2011 -0500 @@ -110,7 +110,10 @@ order = [r1.node(r) for r in order] # this is a bit ugly, but it works - lookup = lambda x: "%020d" % r1.linkrev(r1.rev(x)) + def lookup(x): + progress(x) + return "%020d" % r1.linkrev(r1.rev(x)) + unlookup = lambda x: int(x, 10) try:
--- a/mercurial/localrepo.py Thu Mar 24 17:16:30 2011 -0500 +++ b/mercurial/localrepo.py Mon Mar 28 11:18:56 2011 -0500 @@ -1529,11 +1529,15 @@ def gengroup(): # The set of changed files starts empty. changedfiles = set() + collect = changegroup.collector(cl, mfs, changedfiles) + def clookup(x): + collect(x) + return x # Create a changenode group generator that will call our functions # back to lookup the owning changenode and collect information. - group = cl.group(csets, lambda x: x, collect) + group = cl.group(csets, clookup) for count, chunk in enumerate(group): yield chunk # revlog.group yields three entries per node, so @@ -1548,9 +1552,12 @@ prune(mf, mfs) # Create a generator for the manifestnodes that calls our lookup # and data collection functions back. - group = mf.group(sorted(mfs, key=mf.rev), - lambda mnode: mfs[mnode], - filenode_collector(changedfiles)) + fcollect = filenode_collector(changedfiles) + def mlookup(x): + fcollect(x) + return mfs[x] + + group = mf.group(sorted(mfs, key=mf.rev), mlookup) for count, chunk in enumerate(group): yield chunk # see above comment for why we divide by 3 @@ -1577,9 +1584,12 @@ # Create a group generator and only pass in a changenode # lookup function as we need to collect no information # from filenodes. + def flookup(x): + return missingfnodes[x] + group = filerevlog.group( sorted(missingfnodes, key=filerevlog.rev), - lambda fnode: missingfnodes[fnode]) + flookup) for chunk in group: # even though we print the same progress on # most loop iterations, put the progress call @@ -1632,9 +1642,13 @@ # construct a list of all changed files changedfiles = set() mmfs = {} - collect = changegroup.collector(cl, mmfs, changedfiles) - for count, chunk in enumerate(cl.group(nodes, lambda x: x, collect)): + collect = changegroup.collector(cl, mmfs, changedfiles) + def clookup(x): + collect(x) + return x + + for count, chunk in enumerate(cl.group(nodes, clookup)): # revlog.group yields three entries per node, so # dividing by 3 gives an approximation of how many # nodes have been processed. @@ -1646,8 +1660,11 @@ mnfst = self.manifest nodeiter = gennodelst(mnfst) - for count, chunk in enumerate(mnfst.group(nodeiter, - lookuplinkrev_func(mnfst))): + mfunc = lookuplinkrev_func(mnfst) + def mlookup(x): + return mfunc(x) + + for count, chunk in enumerate(mnfst.group(nodeiter, mlookup)): # see above comment for why we divide by 3 self.ui.progress(_('bundling'), count / 3, unit=_('manifests'), total=changecount) @@ -1663,8 +1680,11 @@ if nodeiter: yield changegroup.chunkheader(len(fname)) yield fname - lookup = lookuplinkrev_func(filerevlog) - for chunk in filerevlog.group(nodeiter, lookup): + ffunc = lookuplinkrev_func(filerevlog) + def flookup(x): + return ffunc(x) + + for chunk in filerevlog.group(nodeiter, flookup): self.ui.progress( _('bundling'), idx, item=fname, total=efiles, unit=_('files'))
--- a/mercurial/revlog.py Thu Mar 24 17:16:30 2011 -0500 +++ b/mercurial/revlog.py Mon Mar 28 11:18:56 2011 -0500 @@ -1058,7 +1058,7 @@ self._cache = (node, curr, text) return node - def group(self, nodelist, lookup, infocollect=None): + def group(self, nodelist, lookup): """Calculate a delta group, yielding a sequence of changegroup chunks (strings). @@ -1086,9 +1086,6 @@ a, b = revs[r], revs[r + 1] nb = self.node(b) - if infocollect is not None: - infocollect(nb) - p = self.parents(nb) meta = nb + p[0] + p[1] + lookup(nb) if a == nullrev: