Patchwork [5,of,6] changegroup: restate file linknode callback using generator expressions

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

Comments

Augie Fackler - Dec. 4, 2015, 7:20 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1449247143 18000
#      Fri Dec 04 11:39:03 2015 -0500
# Node ID 0da8e39dfdb8c971dd355be930c84067a2a8edc3
# Parent  b4cbe235713e04196a5482111611610c8d02573d
# EXP-Topic cg3
changegroup: restate file linknode callback using generator expressions

I think this is slightly clearer, and it nicely avoids an extra nested
function.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -699,14 +699,12 @@  class cg1packer(object):
             def linknodes(unused, fname):
                 return fnodes.get(fname, {})
         else:
+            cln = cl.node
             def linknodes(filerevlog, fname):
                 llr = filerevlog.linkrev
-                def genfilenodes():
-                    for r in filerevlog:
-                        linkrev = llr(r)
-                        if linkrev in clrevs:
-                            yield filerevlog.node(r), cl.node(linkrev)
-                return dict(genfilenodes())
+                fln = filerevlog.node
+                revs = ((r, llr(r)) for r in filerevlog)
+                return dict((fln(r), cln(lr)) for r, lr in revs if lr in clrevs)
 
         changedfiles = set()
         for x in mfchangedfiles.itervalues():