localrepo: use sets in findcommonincoming
authorMartin Geisler <mg@lazybytes.net>
Fri, 24 Apr 2009 17:32:18 +0200
changeset 8156 9fd0822c2ec3
parent 8155 b7cdfa2527be
child 8157 77c5877a668c
localrepo: use sets in findcommonincoming
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Fri Apr 24 17:32:18 2009 +0200
+++ b/mercurial/localrepo.py	Fri Apr 24 17:32:18 2009 +0200
@@ -1305,9 +1305,9 @@
         """
         m = self.changelog.nodemap
         search = []
-        fetch = {}
-        seen = {}
-        seenbranch = {}
+        fetch = set()
+        seen = set()
+        seenbranch = set()
         if base == None:
             base = {}
 
@@ -1361,13 +1361,13 @@
                     self.ui.debug(_("found incomplete branch %s:%s\n")
                                   % (short(n[0]), short(n[1])))
                     search.append(n[0:2]) # schedule branch range for scanning
-                    seenbranch[n] = 1
+                    seenbranch.add(n)
                 else:
                     if n[1] not in seen and n[1] not in fetch:
                         if n[2] in m and n[3] in m:
                             self.ui.debug(_("found new changeset %s\n") %
                                           short(n[1]))
-                            fetch[n[1]] = 1 # earliest unknown
+                            fetch.add(n[1]) # earliest unknown
                         for p in n[2:4]:
                             if p in m:
                                 base[p] = 1 # latest known
@@ -1376,7 +1376,7 @@
                         if p not in req and p not in m:
                             r.append(p)
                             req.add(p)
-                seen[n[0]] = 1
+                seen.add(n[0])
 
             if r:
                 reqcnt += 1
@@ -1402,7 +1402,7 @@
                         if f <= 2:
                             self.ui.debug(_("found new branch changeset %s\n") %
                                               short(p))
-                            fetch[p] = 1
+                            fetch.add(p)
                             base[i] = 1
                         else:
                             self.ui.debug(_("narrowed branch search to %s:%s\n")
@@ -1413,7 +1413,7 @@
                 search = newsearch
 
         # sanity check our fetch list
-        for f in fetch.keys():
+        for f in fetch:
             if f in m:
                 raise error.RepoError(_("already have changeset ")
                                       + short(f[:4]))
@@ -1429,7 +1429,7 @@
 
         self.ui.debug(_("%d total queries\n") % reqcnt)
 
-        return base.keys(), fetch.keys(), heads
+        return base.keys(), list(fetch), heads
 
     def findoutgoing(self, remote, base=None, heads=None, force=False):
         """Return list of nodes that are roots of subsets not in remote