# HG changeset patch # User Augie Fackler <augie@google.com> # Date 1443728110 14400 # Thu Oct 01 15:35:10 2015 -0400 # Node ID 0ef0aec56090e67983d4ab4810e51c24a67f07b2 # Parent 730f328624ab0ca64f8596d54842ca345d0457f1 changegroup: move manifest packing into a separate function A future change will introduce a new function on a cg3packer that can pack treemanifests as well as flatmanifests. diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -591,6 +591,16 @@ rr, rl = revlog.rev, revlog.linkrev return [n for n in missing if rl(rr(n)) not in commonrevs] + def _packmanifests(self, mfnodes, lookuplinknode): + """Pack flat manifests into a changegroup stream.""" + ml = self._repo.manifest + size = 0 + for chunk in self.group( + mfnodes, ml, lookuplinknode, units=_('manifests')): + size += len(chunk) + yield chunk + self._verbosenote(_('%8.i (manifests)\n') % size) + def generate(self, commonrevs, clnodes, fastpathlinkrev, source): '''yield a sequence of changegroup chunks (strings)''' repo = self._repo @@ -654,12 +664,8 @@ return clnode mfnodes = self.prune(ml, mfs, commonrevs) - size = 0 - for chunk in self.group( - mfnodes, ml, lookupmflinknode, units=_('manifests')): - size += len(chunk) - yield chunk - self._verbosenote(_('%8.i (manifests)\n') % size) + for x in self._packmanifests(mfnodes, lookupmflinknode): + yield x mfs.clear() clrevs = set(cl.rev(x) for x in clnodes)