##// END OF EJS Templates
convert: use set instead of dict
Benoit Boissinot -
r8456:e9e2a2c9 default
parent child Browse files
Show More
@@ -100,12 +100,12 class converter(object):
100 100 '''Return a mapping that identifies the uncommitted parents of every
101 101 uncommitted changeset.'''
102 102 visit = heads
103 known = {}
103 known = set()
104 104 parents = {}
105 105 while visit:
106 106 n = visit.pop(0)
107 107 if n in known or n in self.map: continue
108 known[n] = 1
108 known.add(n)
109 109 commit = self.cachecommit(n)
110 110 parents[n] = []
111 111 for p in commit.parents:
@@ -118,14 +118,14 class converter(object):
118 118 '''Return an ordering such that every uncommitted changeset is
119 119 preceeded by all its uncommitted ancestors.'''
120 120 visit = parents.keys()
121 seen = {}
121 seen = set()
122 122 children = {}
123 123 actives = []
124 124
125 125 while visit:
126 126 n = visit.pop(0)
127 127 if n in seen: continue
128 seen[n] = 1
128 seen.add(n)
129 129 # Ensure that nodes without parents are present in the 'children'
130 130 # mapping.
131 131 children.setdefault(n, [])
@@ -463,7 +463,7 def createchangeset(ui, log, fuzz=60, me
463 463 listsort(log, key=lambda x:(x.comment, x.author, x.branch, x.date))
464 464
465 465 changesets = []
466 files = {}
466 files = set()
467 467 c = None
468 468 for i, e in enumerate(log):
469 469
@@ -480,13 +480,13 def createchangeset(ui, log, fuzz=60, me
480 480 branch=e.branch, date=e.date, entries=[],
481 481 mergepoint=getattr(e, 'mergepoint', None))
482 482 changesets.append(c)
483 files = {}
483 files = set()
484 484 if len(changesets) % 100 == 0:
485 485 t = '%d %s' % (len(changesets), repr(e.comment)[1:-1])
486 486 ui.status(util.ellipsis(t, 80) + '\n')
487 487
488 488 c.entries.append(e)
489 files[e.file] = True
489 files.add(e.file)
490 490 c.date = e.date # changeset date is date of latest commit in it
491 491
492 492 # Mark synthetic changesets
@@ -564,19 +564,18 def createchangeset(ui, log, fuzz=60, me
564 564
565 565 globaltags = {}
566 566 for c in changesets:
567 tags = {}
568 567 for e in c.entries:
569 568 for tag in e.tags:
570 569 # remember which is the latest changeset to have this tag
571 570 globaltags[tag] = c
572 571
573 572 for c in changesets:
574 tags = {}
573 tags = set()
575 574 for e in c.entries:
576 575 for tag in e.tags:
577 tags[tag] = True
576 tags.add(tag)
578 577 # remember tags only if this is the latest changeset to have it
579 c.tags = sorted([tag for tag in tags if globaltags[tag] is c])
578 c.tags = sorted(tag for tag in tags if globaltags[tag] is c)
580 579
581 580 # Find parent changesets, handle {{mergetobranch BRANCHNAME}}
582 581 # by inserting dummy changesets with two parents, and handle
@@ -63,7 +63,7 class convert_git(converter_source):
63 63 self.modecache = {}
64 64 fh = self.gitcmd("git diff-tree -z --root -m -r %s" % version)
65 65 changes = []
66 seen = {}
66 seen = set()
67 67 entry = None
68 68 for l in fh.read().split('\x00'):
69 69 if not entry:
@@ -73,7 +73,7 class convert_git(converter_source):
73 73 continue
74 74 f = l
75 75 if f not in seen:
76 seen[f] = 1
76 seen.add(f)
77 77 entry = entry.split()
78 78 h = entry[3]
79 79 p = (entry[1] == "100755")
@@ -195,7 +195,7 class mercurial_source(converter_source)
195 195 def __init__(self, ui, path, rev=None):
196 196 converter_source.__init__(self, ui, path, rev)
197 197 self.ignoreerrors = ui.configbool('convert', 'hg.ignoreerrors', False)
198 self.ignored = {}
198 self.ignored = set()
199 199 self.saverev = ui.configbool('convert', 'hg.saverev', False)
200 200 try:
201 201 self.repo = hg.repository(self.ui, path)
@@ -288,7 +288,7 class mercurial_source(converter_source)
288 288 except error.LookupError, e:
289 289 if not self.ignoreerrors:
290 290 raise
291 self.ignored[name] = 1
291 self.ignored.add(name)
292 292 self.ui.warn(_('ignoring: %s\n') % e)
293 293 return copies
294 294
General Comments 0
You need to be logged in to leave comments. Login now