changeset 26712:04176eaf911b

changegroup: move manifest unpacking into its own method The upcoming cg3 will need different logic for unpacking manifests.
author Augie Fackler <augie@google.com>
date Wed, 14 Oct 2015 15:11:53 -0400
parents 0ef0aec56090
children a271925699d6
files mercurial/changegroup.py
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Thu Oct 01 15:35:10 2015 -0400
+++ b/mercurial/changegroup.py	Wed Oct 14 15:11:53 2015 -0400
@@ -287,6 +287,18 @@
                     pos = next
             yield closechunk()
 
+    def _unpackmanifests(self, repo, revmap, trp, prog, numchanges):
+        # We know that we'll never have more manifests than we had
+        # changesets.
+        self.callback = prog(_('manifests'), numchanges)
+        # no need to check for empty manifest group here:
+        # if the result of the merge of 1 and 2 is the same in 3 and 4,
+        # no new manifest will be created and the manifest group will
+        # be empty during the pull
+        self.manifestheader()
+        repo.manifest.addgroup(self, revmap, trp)
+        repo.ui.progress(_('manifests'), None)
+
     def apply(self, repo, srctype, url, emptyok=False,
               targetphase=phases.draft, expectedtotal=None):
         """Add the changegroup returned by source.read() to this repo.
@@ -357,15 +369,7 @@
 
             # pull off the manifest group
             repo.ui.status(_("adding manifests\n"))
-            # manifests <= changesets
-            self.callback = prog(_('manifests'), changesets)
-            # no need to check for empty manifest group here:
-            # if the result of the merge of 1 and 2 is the same in 3 and 4,
-            # no new manifest will be created and the manifest group will
-            # be empty during the pull
-            self.manifestheader()
-            repo.manifest.addgroup(self, revmap, trp)
-            repo.ui.progress(_('manifests'), None)
+            self._unpackmanifests(repo, revmap, trp, prog, changesets)
 
             needfiles = {}
             if repo.ui.configbool('server', 'validate', default=False):