comparison mercurial/localrepo.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 127281884959
children 9fd0822c2ec3
comparison
equal deleted inserted replaced
8151:127281884959 8152:08e1baf924ca
1333 1333
1334 heads = unknown 1334 heads = unknown
1335 if not unknown: 1335 if not unknown:
1336 return base.keys(), [], [] 1336 return base.keys(), [], []
1337 1337
1338 req = dict.fromkeys(unknown) 1338 req = set(unknown)
1339 reqcnt = 0 1339 reqcnt = 0
1340 1340
1341 # search through remote branches 1341 # search through remote branches
1342 # a 'branch' here is a linear segment of history, with four parts: 1342 # a 'branch' here is a linear segment of history, with four parts:
1343 # head, root, first parent, second parent 1343 # head, root, first parent, second parent
1373 base[p] = 1 # latest known 1373 base[p] = 1 # latest known
1374 1374
1375 for p in n[2:4]: 1375 for p in n[2:4]:
1376 if p not in req and p not in m: 1376 if p not in req and p not in m:
1377 r.append(p) 1377 r.append(p)
1378 req[p] = 1 1378 req.add(p)
1379 seen[n[0]] = 1 1379 seen[n[0]] = 1
1380 1380
1381 if r: 1381 if r:
1382 reqcnt += 1 1382 reqcnt += 1
1383 self.ui.debug(_("request %d: %s\n") % 1383 self.ui.debug(_("request %d: %s\n") %
1445 self.findincoming(remote, base, heads, force=force) 1445 self.findincoming(remote, base, heads, force=force)
1446 1446
1447 self.ui.debug(_("common changesets up to ") 1447 self.ui.debug(_("common changesets up to ")
1448 + " ".join(map(short, base.keys())) + "\n") 1448 + " ".join(map(short, base.keys())) + "\n")
1449 1449
1450 remain = dict.fromkeys(self.changelog.nodemap) 1450 remain = set(self.changelog.nodemap)
1451 1451
1452 # prune everything remote has from the tree 1452 # prune everything remote has from the tree
1453 del remain[nullid] 1453 remain.remove(nullid)
1454 remove = base.keys() 1454 remove = base.keys()
1455 while remove: 1455 while remove:
1456 n = remove.pop(0) 1456 n = remove.pop(0)
1457 if n in remain: 1457 if n in remain:
1458 del remain[n] 1458 remain.remove(n)
1459 for p in self.changelog.parents(n): 1459 for p in self.changelog.parents(n):
1460 remove.append(p) 1460 remove.append(p)
1461 1461
1462 # find every node whose parents have been pruned 1462 # find every node whose parents have been pruned
1463 subset = [] 1463 subset = []
1668 # changesets required to reach the known heads from the null 1668 # changesets required to reach the known heads from the null
1669 # changeset. 1669 # changeset.
1670 has_cl_set, junk, junk = cl.nodesbetween(None, knownheads) 1670 has_cl_set, junk, junk = cl.nodesbetween(None, knownheads)
1671 junk = None 1671 junk = None
1672 # Transform the list into an ersatz set. 1672 # Transform the list into an ersatz set.
1673 has_cl_set = dict.fromkeys(has_cl_set) 1673 has_cl_set = set(has_cl_set)
1674 else: 1674 else:
1675 # If there were no known heads, the recipient cannot be assumed to 1675 # If there were no known heads, the recipient cannot be assumed to
1676 # know about any changesets. 1676 # know about any changesets.
1677 has_cl_set = {} 1677 has_cl_set = set()
1678 1678
1679 # Make it easy to refer to self.manifest 1679 # Make it easy to refer to self.manifest
1680 mnfst = self.manifest 1680 mnfst = self.manifest
1681 # We don't know which manifests are missing yet 1681 # We don't know which manifests are missing yet
1682 msng_mnfst_set = {} 1682 msng_mnfst_set = {}
1930 1930
1931 self.hook('preoutgoing', throw=True, source=source) 1931 self.hook('preoutgoing', throw=True, source=source)
1932 1932
1933 cl = self.changelog 1933 cl = self.changelog
1934 nodes = cl.findmissing(common) 1934 nodes = cl.findmissing(common)
1935 revset = dict.fromkeys([cl.rev(n) for n in nodes]) 1935 revset = set([cl.rev(n) for n in nodes])
1936 self.changegroupinfo(nodes, source) 1936 self.changegroupinfo(nodes, source)
1937 1937
1938 def identity(x): 1938 def identity(x):
1939 return x 1939 return x
1940 1940