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

login
register
mail settings
Submitter Augie Fackler
Date Dec. 4, 2015, 7:38 p.m.
Message ID <d357e1c6126accf134cd.1449257933@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/11816/
State Accepted
Headers show

Comments

Augie Fackler - Dec. 4, 2015, 7:38 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1449247082 18000
#      Fri Dec 04 11:38:02 2015 -0500
# Node ID d357e1c6126accf134cd5ad26c90a1728650bc2c
# Parent  a1ae74e5441d7ec1abb76b4699e394b06f9b9924
# 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
@@ -694,8 +694,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:
@@ -703,7 +706,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():