# HG changeset patch # User Benoit Boissinot # Date 1242522257 -7200 # Node ID e9e2a2c9b2949ecb70b7a8824dbd59265c3cad61 # Parent a858b54d072b43e5bd8354355a7621d9d3ac388b convert: use set instead of dict diff -r a858b54d072b -r e9e2a2c9b294 hgext/convert/convcmd.py --- a/hgext/convert/convcmd.py Sun May 17 03:02:12 2009 +0200 +++ b/hgext/convert/convcmd.py Sun May 17 03:04:17 2009 +0200 @@ -100,12 +100,12 @@ '''Return a mapping that identifies the uncommitted parents of every uncommitted changeset.''' visit = heads - known = {} + known = set() parents = {} while visit: n = visit.pop(0) if n in known or n in self.map: continue - known[n] = 1 + known.add(n) commit = self.cachecommit(n) parents[n] = [] for p in commit.parents: @@ -118,14 +118,14 @@ '''Return an ordering such that every uncommitted changeset is preceeded by all its uncommitted ancestors.''' visit = parents.keys() - seen = {} + seen = set() children = {} actives = [] while visit: n = visit.pop(0) if n in seen: continue - seen[n] = 1 + seen.add(n) # Ensure that nodes without parents are present in the 'children' # mapping. children.setdefault(n, []) diff -r a858b54d072b -r e9e2a2c9b294 hgext/convert/cvsps.py --- a/hgext/convert/cvsps.py Sun May 17 03:02:12 2009 +0200 +++ b/hgext/convert/cvsps.py Sun May 17 03:04:17 2009 +0200 @@ -463,7 +463,7 @@ listsort(log, key=lambda x:(x.comment, x.author, x.branch, x.date)) changesets = [] - files = {} + files = set() c = None for i, e in enumerate(log): @@ -480,13 +480,13 @@ branch=e.branch, date=e.date, entries=[], mergepoint=getattr(e, 'mergepoint', None)) changesets.append(c) - files = {} + files = set() if len(changesets) % 100 == 0: t = '%d %s' % (len(changesets), repr(e.comment)[1:-1]) ui.status(util.ellipsis(t, 80) + '\n') c.entries.append(e) - files[e.file] = True + files.add(e.file) c.date = e.date # changeset date is date of latest commit in it # Mark synthetic changesets @@ -564,19 +564,18 @@ globaltags = {} for c in changesets: - tags = {} for e in c.entries: for tag in e.tags: # remember which is the latest changeset to have this tag globaltags[tag] = c for c in changesets: - tags = {} + tags = set() for e in c.entries: for tag in e.tags: - tags[tag] = True + tags.add(tag) # remember tags only if this is the latest changeset to have it - c.tags = sorted([tag for tag in tags if globaltags[tag] is c]) + c.tags = sorted(tag for tag in tags if globaltags[tag] is c) # Find parent changesets, handle {{mergetobranch BRANCHNAME}} # by inserting dummy changesets with two parents, and handle diff -r a858b54d072b -r e9e2a2c9b294 hgext/convert/git.py --- a/hgext/convert/git.py Sun May 17 03:02:12 2009 +0200 +++ b/hgext/convert/git.py Sun May 17 03:04:17 2009 +0200 @@ -63,7 +63,7 @@ self.modecache = {} fh = self.gitcmd("git diff-tree -z --root -m -r %s" % version) changes = [] - seen = {} + seen = set() entry = None for l in fh.read().split('\x00'): if not entry: @@ -73,7 +73,7 @@ continue f = l if f not in seen: - seen[f] = 1 + seen.add(f) entry = entry.split() h = entry[3] p = (entry[1] == "100755") diff -r a858b54d072b -r e9e2a2c9b294 hgext/convert/hg.py --- a/hgext/convert/hg.py Sun May 17 03:02:12 2009 +0200 +++ b/hgext/convert/hg.py Sun May 17 03:04:17 2009 +0200 @@ -195,7 +195,7 @@ def __init__(self, ui, path, rev=None): converter_source.__init__(self, ui, path, rev) self.ignoreerrors = ui.configbool('convert', 'hg.ignoreerrors', False) - self.ignored = {} + self.ignored = set() self.saverev = ui.configbool('convert', 'hg.saverev', False) try: self.repo = hg.repository(self.ui, path) @@ -288,7 +288,7 @@ except error.LookupError, e: if not self.ignoreerrors: raise - self.ignored[name] = 1 + self.ignored.add(name) self.ui.warn(_('ignoring: %s\n') % e) return copies