[PATCH 5 of 6 py3] dirstate: use list comprehension to get a list of keys

Pulkit Goyal 7895pulkit at gmail.com
Thu Mar 16 00:13:20 EDT 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1489635027 -19800
#      Thu Mar 16 09:00:27 2017 +0530
# Node ID b5673a08993652a92c0e20a4e24d842194872454
# Parent  69aafa5d3e0f109c7b501758381f65fd9b375196
dirstate: use list comprehension to get a list of keys

We have used dict.keys() which returns a dict_keys() object instead
of list on Python 3. So this patch replaces that with list comprehension
which works both on Python 2 and 3.

diff -r 69aafa5d3e0f -r b5673a089936 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Thu Mar 16 08:57:53 2017 +0530
+++ b/mercurial/dirstate.py	Thu Mar 16 09:00:27 2017 +0530
@@ -1079,7 +1079,7 @@
             # a) not matching matchfn b) ignored, c) missing, or d) under a
             # symlink directory.
             if not results and matchalways:
-                visit = dmap.keys()
+                visit = [f for f in dmap]
             else:
                 visit = [f for f in dmap if f not in results and matchfn(f)]
             visit.sort()


More information about the Mercurial-devel mailing list