changegroup*(): use set instead of dict
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Thu, 22 Jul 2010 14:34:37 +0200
changeset 11648 801533a52799
parent 11647 96d3d340f6ec
child 11651 817258259bc9
changegroup*(): use set instead of dict
mercurial/changegroup.py
mercurial/localrepo.py
--- a/mercurial/changegroup.py	Thu Jul 22 10:49:55 2010 +0200
+++ b/mercurial/changegroup.py	Thu Jul 22 14:34:37 2010 +0200
@@ -61,8 +61,7 @@
     # We want to gather manifests needed and filelogs affected.
     def collect(node):
         c = cl.read(node)
-        for fn in c[3]:
-            files.setdefault(fn, fn)
+        files.update(c[3])
         mmfs.setdefault(c[0], node)
     return collect
 
--- a/mercurial/localrepo.py	Thu Jul 22 10:49:55 2010 +0200
+++ b/mercurial/localrepo.py	Thu Jul 22 14:34:37 2010 +0200
@@ -1373,10 +1373,9 @@
                     deltamf = mnfst.readdelta(mnfstnode)
                     # For each line in the delta
                     for f, fnode in deltamf.iteritems():
-                        f = changedfiles.get(f, None)
                         # And if the file is in the list of files we care
                         # about.
-                        if f is not None:
+                        if f in changedfiles:
                             # Get the changenode this manifest belongs to
                             clnode = msng_mnfst_set[mnfstnode]
                             # Create the set of filenodes for the file if
@@ -1435,7 +1434,7 @@
         # logically divide up the task, generate the group.
         def gengroup():
             # The set of changed files starts empty.
-            changedfiles = {}
+            changedfiles = set()
             collect = changegroup.collector(cl, msng_mnfst_set, changedfiles)
 
             # Create a changenode group generator that will call our functions
@@ -1486,7 +1485,7 @@
                     if isinstance(fname, int):
                         continue
                     msng_filenode_set.setdefault(fname, {})
-                    changedfiles[fname] = 1
+                    changedfiles.add(fname)
             # Go through all our files in order sorted by name.
             cnt = 0
             for fname in sorted(changedfiles):
@@ -1566,7 +1565,7 @@
         def gengroup():
             '''yield a sequence of changegroup chunks (strings)'''
             # construct a list of all changed files
-            changedfiles = {}
+            changedfiles = set()
             mmfs = {}
             collect = changegroup.collector(cl, mmfs, changedfiles)