changeset 26711:0ef0aec56090

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.
author Augie Fackler <augie@google.com>
date Thu, 01 Oct 2015 15:35:10 -0400
parents 730f328624ab
children 04176eaf911b
files mercurial/changegroup.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Wed Sep 30 19:59:12 2015 -0400
+++ b/mercurial/changegroup.py	Thu Oct 01 15:35:10 2015 -0400
@@ -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)