Patchwork [1,of,3,stable] changegroup: don't define lookupmf() until it is needed

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 7, 2014, 8:12 a.m.
Message ID <b6b91dd825e07fcfe674.1415347929@gps-mbp.local>
Download mbox | patch
Permalink /patch/6629/
State Accepted
Headers show

Comments

Gregory Szorc - Nov. 7, 2014, 8:12 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1415336232 28800
#      Thu Nov 06 20:57:12 2014 -0800
# Node ID b6b91dd825e07fcfe67403f5716fc23e2e30f8c3
# Parent  2d54aa5397cdb1c697673ba10b7618d5ac25c69e
changegroup: don't define lookupmf() until it is needed

lookupmf() is currently defined earlier than when it is needed. Future
patches further refactoring this code will be easier to read when
lookupmf() is in its new home.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -338,8 +338,16 @@  class cg1packer(object):
             # record the first changeset introducing this manifest version
             mfs.setdefault(c[0], x)
             return x
 
+        for chunk in self.group(clnodes, cl, lookupcl, units=_('changesets'),
+                                reorder=reorder):
+            yield chunk
+        progress(msgbundling, None)
+
+        for f in changedfiles:
+            fnodes[f] = {}
+
         # Callback for the manifest, used to collect linkrevs for filelog
         # revisions.
         # Returns the linkrev node (collected in lookupcl).
         def lookupmf(x):
@@ -352,15 +360,8 @@  class cg1packer(object):
                         # version
                         fnodes[f].setdefault(n, clnode)
             return clnode
 
-        for chunk in self.group(clnodes, cl, lookupcl, units=_('changesets'),
-                                reorder=reorder):
-            yield chunk
-        progress(msgbundling, None)
-
-        for f in changedfiles:
-            fnodes[f] = {}
         mfnodes = self.prune(mf, mfs, commonrevs, source)
         for chunk in self.group(mfnodes, mf, lookupmf, units=_('manifests'),
                                 reorder=reorder):
             yield chunk