changegroup: restate file linknode callback using generator expressions
authorAugie Fackler <augie@google.com>
Fri, 04 Dec 2015 11:39:03 -0500
changeset 27241 ead8e7069998
parent 27240 94a3d6fdc315
child 27242 58f473908951
changegroup: restate file linknode callback using generator expressions I think this is slightly clearer, and it nicely avoids an extra nested function.
mercurial/changegroup.py
--- a/mercurial/changegroup.py	Fri Dec 04 11:38:02 2015 -0500
+++ b/mercurial/changegroup.py	Fri Dec 04 11:39:03 2015 -0500
@@ -698,14 +698,12 @@
             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():