diff mercurial/cmdutil.py @ 8152:08e1baf924ca

replace set-like dictionaries with real sets Many of the dictionaries created by dict.fromkeys were emulating sets. These can now be replaced with real sets.
author Martin Geisler <mg@lazybytes.net>
date Wed, 22 Apr 2009 00:57:28 +0200
parents af44d0b953c6
children f3abe032fc89
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Apr 22 00:56:06 2009 +0200
+++ b/mercurial/cmdutil.py	Wed Apr 22 00:57:28 2009 +0200
@@ -1017,13 +1017,13 @@
     else:
         defrange = '-1:0'
     revs = revrange(repo, opts['rev'] or [defrange])
-    wanted = {}
+    wanted = set()
     slowpath = m.anypats() or (m.files() and opts.get('removed'))
     fncache = {}
 
     if not slowpath and not m.files():
         # No files, no patterns.  Display all revs.
-        wanted = dict.fromkeys(revs)
+        wanted = set(revs)
     copies = []
     if not slowpath:
         # Only files, no patterns.  Check the history of each file.
@@ -1071,7 +1071,7 @@
                         break
                     fncache.setdefault(rev, [])
                     fncache[rev].append(file_)
-                    wanted[rev] = 1
+                    wanted.add(rev)
                     if follow and copied:
                         copies.append(copied)
     if slowpath:
@@ -1089,7 +1089,7 @@
             matches = filter(m, changefiles)
             if matches:
                 fncache[rev] = matches
-                wanted[rev] = 1
+                wanted.add(rev)
 
     class followfilter:
         def __init__(self, onlyfirst=False):
@@ -1135,8 +1135,8 @@
         ff = followfilter()
         stop = min(revs[0], revs[-1])
         for x in xrange(rev, stop-1, -1):
-            if ff.match(x) and x in wanted:
-                del wanted[x]
+            if ff.match(x):
+                wanted.discard(x)
 
     def iterate():
         if follow and not m.files():