[PATCH 4 of 7] cleanup: fix some list comprehension redefinitions of existing vars

Mads Kiilerich mads at kiilerich.com
Fri Aug 15 09:21:20 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1408070266 -7200
#      Fri Aug 15 04:37:46 2014 +0200
# Node ID 8a93e52d2b0d74d55baa9681a26f40363b6cf193
# Parent  acee2c1d3c12c1c6624d269f77fb8e0819a39a7d
cleanup: fix some list comprehension redefinitions of existing vars

In all the remaining cases the comprehension variable is used for the same
thing as a previous loop variable.

This will mute some pyflakes "list comprehension redefines" warnings.

diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -490,10 +490,10 @@ class svn_source(converter_source):
             self._fetch_revisions(revnum, stop)
             if rev not in self.commits:
                 raise util.Abort(_('svn: revision %s not found') % revnum)
-        commit = self.commits[rev]
+        revcommit = self.commits[rev]
         # caller caches the result, so free it here to release memory
         del self.commits[rev]
-        return commit
+        return revcommit
 
     def checkrevformat(self, revstr, mapname='splicemap'):
         """ fails if revision format does not match the correct format"""
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5593,7 +5593,7 @@ def summary(ui, repo, **opts):
         ui.write(_('commit: %s\n') % t.strip())
 
     # all ancestors of branch heads - all ancestors of parent = new csets
-    new = len(repo.changelog.findmissing([ctx.node() for ctx in parents],
+    new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
                                          bheads))
 
     if new == 0:
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -735,9 +735,9 @@ class basefilectx(object):
         return True
 
     def parents(self):
-        p = self._path
+        _path = self._path
         fl = self._filelog
-        pl = [(p, n, fl) for n in self._filelog.parents(self._filenode)]
+        pl = [(_path, n, fl) for n in self._filelog.parents(self._filenode)]
 
         r = self._filelog.renamed(self._filenode)
         if r:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -676,8 +676,7 @@ class localrepository(object):
         if not self._tagscache.tagslist:
             l = []
             for t, n in self.tags().iteritems():
-                r = self.changelog.rev(n)
-                l.append((r, t, n))
+                l.append((self.changelog.rev(n), t, n))
             self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
 
         return self._tagscache.tagslist
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -249,7 +249,7 @@ class wirepeer(peer.peerrepository):
         yield {'nodes': encodelist(nodes)}, f
         d = f.value
         try:
-            yield [bool(int(f)) for f in d]
+            yield [bool(int(b)) for b in d]
         except ValueError:
             self._abort(error.ResponseError(_("unexpected response:"), d))
 


More information about the Mercurial-devel mailing list