Patchwork [4,of,6] changegroup: clean up file lookup function

login
register
mail settings
Submitter Augie Fackler
Date Dec. 4, 2015, 7:20 p.m.
Message ID <b4cbe235713e04196a54.1449256839@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/11809/
State Superseded
Headers show

Comments

Augie Fackler - Dec. 4, 2015, 7:20 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1449247082 18000
#      Fri Dec 04 11:38:02 2015 -0500
# Node ID b4cbe235713e04196a5482111611610c8d02573d
# Parent  1477b679417ada21523eeb4ae945e907e8df5f8c
# EXP-Topic cg3
changegroup: clean up file lookup function

One case is basically degenerate, so just extract it and make the
function clearer.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -695,8 +695,11 @@  class cg1packer(object):
         mfs.clear()
         clrevs = set(cl.rev(x) for x in clnodes)
 
-        def linknodes(filerevlog, fname):
-            if fastpathlinkrev:
+        if not fastpathlinkrev:
+            def linknodes(unused, fname):
+                return fnodes.get(fname, {})
+        else:
+            def linknodes(filerevlog, fname):
                 llr = filerevlog.linkrev
                 def genfilenodes():
                     for r in filerevlog:
@@ -704,7 +707,6 @@  class cg1packer(object):
                         if linkrev in clrevs:
                             yield filerevlog.node(r), cl.node(linkrev)
                 return dict(genfilenodes())
-            return fnodes.get(fname, {})
 
         changedfiles = set()
         for x in mfchangedfiles.itervalues():