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