diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py --- a/hgext/bugzilla.py +++ b/hgext/bugzilla.py @@ -177,12 +177,12 @@ class bugzilla_2_16(object): self.run('''select bug_id from longdescs where bug_id in %s and thetext like "%%%s%%"''' % (buglist(ids), short(node))) - unknown = dict.fromkeys(ids) + unknown = set(ids) for (id,) in self.cursor.fetchall(): self.ui.status(_('bug %d already knows about changeset %s\n') % (id, short(node))) - unknown.pop(id, None) - return util.sort(unknown.keys()) + unknown.discard(id) + return util.sort(unknown) def notify(self, ids, committer): '''tell bugzilla to send mail.''' diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1338,7 +1338,7 @@ class queue: msg = '' return '%s%s' % (patchname, msg) - applied = dict.fromkeys([p.name for p in self.applied]) + applied = set([p.name for p in self.applied]) if length is None: length = len(self.series) - start if not missing: @@ -1762,10 +1762,8 @@ def clone(ui, source, dest=None, **opts) if sr.mq.applied: qbase = bin(sr.mq.applied[0].rev) if not hg.islocal(dest): - heads = dict.fromkeys(sr.heads()) - for h in sr.heads(qbase): - del heads[h] - destrev = heads.keys() + heads = set(sr.heads()) + destrev = list(heads.difference(sr.heads(qbase))) destrev.append(sr.changelog.parents(qbase)[0]) elif sr.capable('lookup'): try: diff --git a/hgext/record.py b/hgext/record.py --- a/hgext/record.py +++ b/hgext/record.py @@ -422,9 +422,9 @@ def dorecord(ui, repo, committer, *pats, chunks = filterpatch(ui, parsepatch(fp)) del fp - contenders = {} + contenders = set() for h in chunks: - try: contenders.update(dict.fromkeys(h.files())) + try: contenders.update(set(h.files())) except AttributeError: pass changed = changes[0] + changes[1] + changes[2] @@ -433,7 +433,7 @@ def dorecord(ui, repo, committer, *pats, ui.status(_('no changes to record\n')) return 0 - modified = dict.fromkeys(changes[0]) + modified = set(changes[0]) # 2. backup changed files, so we can restore them in the end backups = {} diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1017,13 +1017,13 @@ def walkchangerevs(ui, repo, pats, chang else: defrange = '-1:0' revs = revrange(repo, opts['rev'] or [defrange]) - wanted = {} + wanted = set() slowpath = m.anypats() or (m.files() and opts.get('removed')) fncache = {} if not slowpath and not m.files(): # No files, no patterns. Display all revs. - wanted = dict.fromkeys(revs) + wanted = set(revs) copies = [] if not slowpath: # Only files, no patterns. Check the history of each file. @@ -1071,7 +1071,7 @@ def walkchangerevs(ui, repo, pats, chang break fncache.setdefault(rev, []) fncache[rev].append(file_) - wanted[rev] = 1 + wanted.add(rev) if follow and copied: copies.append(copied) if slowpath: @@ -1089,7 +1089,7 @@ def walkchangerevs(ui, repo, pats, chang matches = filter(m, changefiles) if matches: fncache[rev] = matches - wanted[rev] = 1 + wanted.add(rev) class followfilter: def __init__(self, onlyfirst=False): @@ -1135,8 +1135,8 @@ def walkchangerevs(ui, repo, pats, chang ff = followfilter() stop = min(revs[0], revs[-1]) for x in xrange(rev, stop-1, -1): - if ff.match(x) and x in wanted: - del wanted[x] + if ff.match(x): + wanted.discard(x) def iterate(): if follow and not m.files(): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1480,8 +1480,8 @@ def help_(ui, name=None, with_version=Fa except AttributeError: ct = {} - modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct]) - helplist(_('list of commands:\n\n'), modcmds.has_key) + modcmds = set([c.split('|', 1)[0] for c in ct]) + helplist(_('list of commands:\n\n'), modcmds.__contains__) if name and name != 'shortlist': i = None @@ -2503,14 +2503,14 @@ def revert(ui, repo, *pats, **opts): m = cmdutil.matchfiles(repo, names) changes = repo.status(match=m)[:4] - modified, added, removed, deleted = map(dict.fromkeys, changes) + modified, added, removed, deleted = map(set, changes) # if f is a rename, also revert the source cwd = repo.getcwd() for f in added: src = repo.dirstate.copied(f) if src and src not in names and repo.dirstate[src] == 'r': - removed[src] = None + removed.add(src) names[src] = (repo.pathto(src, cwd), True) def removeforget(abs): @@ -2824,7 +2824,7 @@ def tag(ui, repo, name1, *names, **opts) rev_ = "." names = (name1,) + names - if len(names) != len(dict.fromkeys(names)): + if len(names) != len(set(names)): raise util.Abort(_('tag names must be unique')) for n in names: if n in ['tip', '.', 'null']: diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -160,12 +160,12 @@ def copies(repo, c1, c2, ca, checkdirs=F for f in u2: checkcopies(f, m2, m1) - diverge2 = {} + diverge2 = set() for of, fl in diverge.items(): if len(fl) == 1: del diverge[of] # not actually divergent else: - diverge2.update(dict.fromkeys(fl)) # reverse map for below + diverge2.update(fl) # reverse map for below if fullcopy: repo.ui.debug(_(" all copies found (* = to merge, ! = divergent):\n")) diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py --- a/mercurial/hbisect.py +++ b/mercurial/hbisect.py @@ -24,7 +24,7 @@ def bisect(changelog, state): """ clparents = changelog.parentrevs - skip = dict.fromkeys([changelog.rev(n) for n in state['skip']]) + skip = set([changelog.rev(n) for n in state['skip']]) def buildancestors(bad, good): # only the earliest bad revision matters @@ -109,7 +109,7 @@ def bisect(changelog, state): for c in children.get(rev, []): if ancestors[c]: - ancestors[c] = dict.fromkeys(ancestors[c] + a).keys() + ancestors[c] = list(set(ancestors[c] + a)) else: ancestors[c] = a + [c] diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1335,7 +1335,7 @@ class localrepository(repo.repository): if not unknown: return base.keys(), [], [] - req = dict.fromkeys(unknown) + req = set(unknown) reqcnt = 0 # search through remote branches @@ -1375,7 +1375,7 @@ class localrepository(repo.repository): for p in n[2:4]: if p not in req and p not in m: r.append(p) - req[p] = 1 + req.add(p) seen[n[0]] = 1 if r: @@ -1447,15 +1447,15 @@ class localrepository(repo.repository): self.ui.debug(_("common changesets up to ") + " ".join(map(short, base.keys())) + "\n") - remain = dict.fromkeys(self.changelog.nodemap) + remain = set(self.changelog.nodemap) # prune everything remote has from the tree - del remain[nullid] + remain.remove(nullid) remove = base.keys() while remove: n = remove.pop(0) if n in remain: - del remain[n] + remain.remove(n) for p in self.changelog.parents(n): remove.append(p) @@ -1670,11 +1670,11 @@ class localrepository(repo.repository): has_cl_set, junk, junk = cl.nodesbetween(None, knownheads) junk = None # Transform the list into an ersatz set. - has_cl_set = dict.fromkeys(has_cl_set) + has_cl_set = set(has_cl_set) else: # If there were no known heads, the recipient cannot be assumed to # know about any changesets. - has_cl_set = {} + has_cl_set = set() # Make it easy to refer to self.manifest mnfst = self.manifest @@ -1932,7 +1932,7 @@ class localrepository(repo.repository): cl = self.changelog nodes = cl.findmissing(common) - revset = dict.fromkeys([cl.rev(n) for n in nodes]) + revset = set([cl.rev(n) for n in nodes]) self.changegroupinfo(nodes, source) def identity(x): diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -5,7 +5,7 @@ class _match(object): self._root = root self._cwd = cwd self._files = files - self._fmap = dict.fromkeys(files) + self._fmap = set(files) self.matchfn = mf self._anypats = ap def __call__(self, fn): diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -166,7 +166,7 @@ def manifestmerge(repo, p1, p2, pa, over if repo.ui.configbool("merge", "followcopies", True): dirs = repo.ui.configbool("merge", "followdirs", True) copy, diverge = copies.copies(repo, p1, p2, pa, dirs) - copied = dict.fromkeys(copy.values()) + copied = set(copy.values()) for of, fl in diverge.iteritems(): act("divergent renames", "dr", of, fl) diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -613,10 +613,9 @@ class revlog(object): heads = [self.rev(n) for n in heads] # we want the ancestors, but inclusive - has = dict.fromkeys(self.ancestors(*common)) - has[nullrev] = None - for r in common: - has[r] = None + has = set(self.ancestors(*common)) + has.add(nullrev) + has.update(common) # take all ancestors from heads that aren't in has missing = {} @@ -726,9 +725,8 @@ class revlog(object): # any other roots. lowestrev = nullrev roots = [nullid] - # Transform our roots list into a 'set' (i.e. a dictionary where the - # values don't matter. - descendents = dict.fromkeys(roots, 1) + # Transform our roots list into a set. + descendents = set(roots) # Also, keep the original roots so we can filter out roots that aren't # 'real' roots (i.e. are descended from other roots). roots = descendents.copy() @@ -752,14 +750,14 @@ class revlog(object): p = tuple(self.parents(n)) # If any of its parents are descendents, it's not a root. if (p[0] in descendents) or (p[1] in descendents): - roots.pop(n) + roots.remove(n) else: p = tuple(self.parents(n)) # A node is a descendent if either of its parents are # descendents. (We seeded the dependents list with the roots # up there, remember?) if (p[0] in descendents) or (p[1] in descendents): - descendents[n] = 1 + descendents.add(n) isdescendent = True if isdescendent and ((ancestors is None) or (n in ancestors)): # Only include nodes that are both descendents and ancestors. @@ -778,7 +776,7 @@ class revlog(object): for p in self.parents(n): heads.pop(p, None) heads = [n for n in heads.iterkeys() if heads[n] != 0] - roots = roots.keys() + roots = list(roots) assert orderedout assert roots assert heads @@ -807,7 +805,7 @@ class revlog(object): start = nullid if stop is None: stop = [] - stoprevs = dict.fromkeys([self.rev(n) for n in stop]) + stoprevs = set([self.rev(n) for n in stop]) startrev = self.rev(start) reachable = {startrev: 1} heads = {startrev: 1}