##// END OF EJS Templates
replace set-like dictionaries with real sets...
Martin Geisler -
r8152:08e1baf9 default
parent child Browse files
Show More
@@ -177,12 +177,12 b' class bugzilla_2_16(object):'
177 177 self.run('''select bug_id from longdescs where
178 178 bug_id in %s and thetext like "%%%s%%"''' %
179 179 (buglist(ids), short(node)))
180 unknown = dict.fromkeys(ids)
180 unknown = set(ids)
181 181 for (id,) in self.cursor.fetchall():
182 182 self.ui.status(_('bug %d already knows about changeset %s\n') %
183 183 (id, short(node)))
184 unknown.pop(id, None)
185 return util.sort(unknown.keys())
184 unknown.discard(id)
185 return util.sort(unknown)
186 186
187 187 def notify(self, ids, committer):
188 188 '''tell bugzilla to send mail.'''
@@ -1338,7 +1338,7 b' class queue:'
1338 1338 msg = ''
1339 1339 return '%s%s' % (patchname, msg)
1340 1340
1341 applied = dict.fromkeys([p.name for p in self.applied])
1341 applied = set([p.name for p in self.applied])
1342 1342 if length is None:
1343 1343 length = len(self.series) - start
1344 1344 if not missing:
@@ -1762,10 +1762,8 b' def clone(ui, source, dest=None, **opts)'
1762 1762 if sr.mq.applied:
1763 1763 qbase = bin(sr.mq.applied[0].rev)
1764 1764 if not hg.islocal(dest):
1765 heads = dict.fromkeys(sr.heads())
1766 for h in sr.heads(qbase):
1767 del heads[h]
1768 destrev = heads.keys()
1765 heads = set(sr.heads())
1766 destrev = list(heads.difference(sr.heads(qbase)))
1769 1767 destrev.append(sr.changelog.parents(qbase)[0])
1770 1768 elif sr.capable('lookup'):
1771 1769 try:
@@ -422,9 +422,9 b' def dorecord(ui, repo, committer, *pats,'
422 422 chunks = filterpatch(ui, parsepatch(fp))
423 423 del fp
424 424
425 contenders = {}
425 contenders = set()
426 426 for h in chunks:
427 try: contenders.update(dict.fromkeys(h.files()))
427 try: contenders.update(set(h.files()))
428 428 except AttributeError: pass
429 429
430 430 changed = changes[0] + changes[1] + changes[2]
@@ -433,7 +433,7 b' def dorecord(ui, repo, committer, *pats,'
433 433 ui.status(_('no changes to record\n'))
434 434 return 0
435 435
436 modified = dict.fromkeys(changes[0])
436 modified = set(changes[0])
437 437
438 438 # 2. backup changed files, so we can restore them in the end
439 439 backups = {}
@@ -1017,13 +1017,13 b' def walkchangerevs(ui, repo, pats, chang'
1017 1017 else:
1018 1018 defrange = '-1:0'
1019 1019 revs = revrange(repo, opts['rev'] or [defrange])
1020 wanted = {}
1020 wanted = set()
1021 1021 slowpath = m.anypats() or (m.files() and opts.get('removed'))
1022 1022 fncache = {}
1023 1023
1024 1024 if not slowpath and not m.files():
1025 1025 # No files, no patterns. Display all revs.
1026 wanted = dict.fromkeys(revs)
1026 wanted = set(revs)
1027 1027 copies = []
1028 1028 if not slowpath:
1029 1029 # Only files, no patterns. Check the history of each file.
@@ -1071,7 +1071,7 b' def walkchangerevs(ui, repo, pats, chang'
1071 1071 break
1072 1072 fncache.setdefault(rev, [])
1073 1073 fncache[rev].append(file_)
1074 wanted[rev] = 1
1074 wanted.add(rev)
1075 1075 if follow and copied:
1076 1076 copies.append(copied)
1077 1077 if slowpath:
@@ -1089,7 +1089,7 b' def walkchangerevs(ui, repo, pats, chang'
1089 1089 matches = filter(m, changefiles)
1090 1090 if matches:
1091 1091 fncache[rev] = matches
1092 wanted[rev] = 1
1092 wanted.add(rev)
1093 1093
1094 1094 class followfilter:
1095 1095 def __init__(self, onlyfirst=False):
@@ -1135,8 +1135,8 b' def walkchangerevs(ui, repo, pats, chang'
1135 1135 ff = followfilter()
1136 1136 stop = min(revs[0], revs[-1])
1137 1137 for x in xrange(rev, stop-1, -1):
1138 if ff.match(x) and x in wanted:
1139 del wanted[x]
1138 if ff.match(x):
1139 wanted.discard(x)
1140 1140
1141 1141 def iterate():
1142 1142 if follow and not m.files():
@@ -1480,8 +1480,8 b' def help_(ui, name=None, with_version=Fa'
1480 1480 except AttributeError:
1481 1481 ct = {}
1482 1482
1483 modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct])
1484 helplist(_('list of commands:\n\n'), modcmds.has_key)
1483 modcmds = set([c.split('|', 1)[0] for c in ct])
1484 helplist(_('list of commands:\n\n'), modcmds.__contains__)
1485 1485
1486 1486 if name and name != 'shortlist':
1487 1487 i = None
@@ -2503,14 +2503,14 b' def revert(ui, repo, *pats, **opts):'
2503 2503
2504 2504 m = cmdutil.matchfiles(repo, names)
2505 2505 changes = repo.status(match=m)[:4]
2506 modified, added, removed, deleted = map(dict.fromkeys, changes)
2506 modified, added, removed, deleted = map(set, changes)
2507 2507
2508 2508 # if f is a rename, also revert the source
2509 2509 cwd = repo.getcwd()
2510 2510 for f in added:
2511 2511 src = repo.dirstate.copied(f)
2512 2512 if src and src not in names and repo.dirstate[src] == 'r':
2513 removed[src] = None
2513 removed.add(src)
2514 2514 names[src] = (repo.pathto(src, cwd), True)
2515 2515
2516 2516 def removeforget(abs):
@@ -2824,7 +2824,7 b' def tag(ui, repo, name1, *names, **opts)'
2824 2824
2825 2825 rev_ = "."
2826 2826 names = (name1,) + names
2827 if len(names) != len(dict.fromkeys(names)):
2827 if len(names) != len(set(names)):
2828 2828 raise util.Abort(_('tag names must be unique'))
2829 2829 for n in names:
2830 2830 if n in ['tip', '.', 'null']:
@@ -160,12 +160,12 b' def copies(repo, c1, c2, ca, checkdirs=F'
160 160 for f in u2:
161 161 checkcopies(f, m2, m1)
162 162
163 diverge2 = {}
163 diverge2 = set()
164 164 for of, fl in diverge.items():
165 165 if len(fl) == 1:
166 166 del diverge[of] # not actually divergent
167 167 else:
168 diverge2.update(dict.fromkeys(fl)) # reverse map for below
168 diverge2.update(fl) # reverse map for below
169 169
170 170 if fullcopy:
171 171 repo.ui.debug(_(" all copies found (* = to merge, ! = divergent):\n"))
@@ -24,7 +24,7 b' def bisect(changelog, state):'
24 24 """
25 25
26 26 clparents = changelog.parentrevs
27 skip = dict.fromkeys([changelog.rev(n) for n in state['skip']])
27 skip = set([changelog.rev(n) for n in state['skip']])
28 28
29 29 def buildancestors(bad, good):
30 30 # only the earliest bad revision matters
@@ -109,7 +109,7 b' def bisect(changelog, state):'
109 109
110 110 for c in children.get(rev, []):
111 111 if ancestors[c]:
112 ancestors[c] = dict.fromkeys(ancestors[c] + a).keys()
112 ancestors[c] = list(set(ancestors[c] + a))
113 113 else:
114 114 ancestors[c] = a + [c]
115 115
@@ -1335,7 +1335,7 b' class localrepository(repo.repository):'
1335 1335 if not unknown:
1336 1336 return base.keys(), [], []
1337 1337
1338 req = dict.fromkeys(unknown)
1338 req = set(unknown)
1339 1339 reqcnt = 0
1340 1340
1341 1341 # search through remote branches
@@ -1375,7 +1375,7 b' class localrepository(repo.repository):'
1375 1375 for p in n[2:4]:
1376 1376 if p not in req and p not in m:
1377 1377 r.append(p)
1378 req[p] = 1
1378 req.add(p)
1379 1379 seen[n[0]] = 1
1380 1380
1381 1381 if r:
@@ -1447,15 +1447,15 b' class localrepository(repo.repository):'
1447 1447 self.ui.debug(_("common changesets up to ")
1448 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 1452 # prune everything remote has from the tree
1453 del remain[nullid]
1453 remain.remove(nullid)
1454 1454 remove = base.keys()
1455 1455 while remove:
1456 1456 n = remove.pop(0)
1457 1457 if n in remain:
1458 del remain[n]
1458 remain.remove(n)
1459 1459 for p in self.changelog.parents(n):
1460 1460 remove.append(p)
1461 1461
@@ -1670,11 +1670,11 b' class localrepository(repo.repository):'
1670 1670 has_cl_set, junk, junk = cl.nodesbetween(None, knownheads)
1671 1671 junk = None
1672 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 1674 else:
1675 1675 # If there were no known heads, the recipient cannot be assumed to
1676 1676 # know about any changesets.
1677 has_cl_set = {}
1677 has_cl_set = set()
1678 1678
1679 1679 # Make it easy to refer to self.manifest
1680 1680 mnfst = self.manifest
@@ -1932,7 +1932,7 b' class localrepository(repo.repository):'
1932 1932
1933 1933 cl = self.changelog
1934 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 1936 self.changegroupinfo(nodes, source)
1937 1937
1938 1938 def identity(x):
@@ -5,7 +5,7 b' class _match(object):'
5 5 self._root = root
6 6 self._cwd = cwd
7 7 self._files = files
8 self._fmap = dict.fromkeys(files)
8 self._fmap = set(files)
9 9 self.matchfn = mf
10 10 self._anypats = ap
11 11 def __call__(self, fn):
@@ -166,7 +166,7 b' def manifestmerge(repo, p1, p2, pa, over'
166 166 if repo.ui.configbool("merge", "followcopies", True):
167 167 dirs = repo.ui.configbool("merge", "followdirs", True)
168 168 copy, diverge = copies.copies(repo, p1, p2, pa, dirs)
169 copied = dict.fromkeys(copy.values())
169 copied = set(copy.values())
170 170 for of, fl in diverge.iteritems():
171 171 act("divergent renames", "dr", of, fl)
172 172
@@ -613,10 +613,9 b' class revlog(object):'
613 613 heads = [self.rev(n) for n in heads]
614 614
615 615 # we want the ancestors, but inclusive
616 has = dict.fromkeys(self.ancestors(*common))
617 has[nullrev] = None
618 for r in common:
619 has[r] = None
616 has = set(self.ancestors(*common))
617 has.add(nullrev)
618 has.update(common)
620 619
621 620 # take all ancestors from heads that aren't in has
622 621 missing = {}
@@ -726,9 +725,8 b' class revlog(object):'
726 725 # any other roots.
727 726 lowestrev = nullrev
728 727 roots = [nullid]
729 # Transform our roots list into a 'set' (i.e. a dictionary where the
730 # values don't matter.
731 descendents = dict.fromkeys(roots, 1)
728 # Transform our roots list into a set.
729 descendents = set(roots)
732 730 # Also, keep the original roots so we can filter out roots that aren't
733 731 # 'real' roots (i.e. are descended from other roots).
734 732 roots = descendents.copy()
@@ -752,14 +750,14 b' class revlog(object):'
752 750 p = tuple(self.parents(n))
753 751 # If any of its parents are descendents, it's not a root.
754 752 if (p[0] in descendents) or (p[1] in descendents):
755 roots.pop(n)
753 roots.remove(n)
756 754 else:
757 755 p = tuple(self.parents(n))
758 756 # A node is a descendent if either of its parents are
759 757 # descendents. (We seeded the dependents list with the roots
760 758 # up there, remember?)
761 759 if (p[0] in descendents) or (p[1] in descendents):
762 descendents[n] = 1
760 descendents.add(n)
763 761 isdescendent = True
764 762 if isdescendent and ((ancestors is None) or (n in ancestors)):
765 763 # Only include nodes that are both descendents and ancestors.
@@ -778,7 +776,7 b' class revlog(object):'
778 776 for p in self.parents(n):
779 777 heads.pop(p, None)
780 778 heads = [n for n in heads.iterkeys() if heads[n] != 0]
781 roots = roots.keys()
779 roots = list(roots)
782 780 assert orderedout
783 781 assert roots
784 782 assert heads
@@ -807,7 +805,7 b' class revlog(object):'
807 805 start = nullid
808 806 if stop is None:
809 807 stop = []
810 stoprevs = dict.fromkeys([self.rev(n) for n in stop])
808 stoprevs = set([self.rev(n) for n in stop])
811 809 startrev = self.rev(start)
812 810 reachable = {startrev: 1}
813 811 heads = {startrev: 1}
General Comments 0
You need to be logged in to leave comments. Login now