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