Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/convert/__init__.py @ 4719:1069205a8894
fix 'convert' with single commit repositories
The attached patch passes the three 'convert' testcases, and also is
able to successfully convert the git.git repository.
author | Hollis Blanchard <hollisb@us.ibm.com> |
---|---|
date | Mon, 25 Jun 2007 14:50:25 -0500 |
parents | 63b9d2deed48 |
children | 07efcce17d28 72ac66e88c43 |
comparison
equal
deleted
inserted
replaced
4718:934275cd4526 | 4719:1069205a8894 |
---|---|
58 if opts.get('authors'): | 58 if opts.get('authors'): |
59 self.readauthormap(opts.get('authors')) | 59 self.readauthormap(opts.get('authors')) |
60 self.authorfile = self.dest.authorfile() | 60 self.authorfile = self.dest.authorfile() |
61 | 61 |
62 def walktree(self, heads): | 62 def walktree(self, heads): |
63 '''Return a mapping that identifies the uncommitted parents of every | |
64 uncommitted changeset.''' | |
63 visit = heads | 65 visit = heads |
64 known = {} | 66 known = {} |
65 parents = {} | 67 parents = {} |
66 while visit: | 68 while visit: |
67 n = visit.pop(0) | 69 n = visit.pop(0) |
68 if n in known or n in self.map: continue | 70 if n in known or n in self.map: continue |
69 known[n] = 1 | 71 known[n] = 1 |
70 self.commitcache[n] = self.source.getcommit(n) | 72 self.commitcache[n] = self.source.getcommit(n) |
71 cp = self.commitcache[n].parents | 73 cp = self.commitcache[n].parents |
74 parents[n] = [] | |
72 for p in cp: | 75 for p in cp: |
73 parents.setdefault(n, []).append(p) | 76 parents[n].append(p) |
74 visit.append(p) | 77 visit.append(p) |
75 | 78 |
76 return parents | 79 return parents |
77 | 80 |
78 def toposort(self, parents): | 81 def toposort(self, parents): |
82 '''Return an ordering such that every uncommitted changeset is | |
83 preceeded by all its uncommitted ancestors.''' | |
79 visit = parents.keys() | 84 visit = parents.keys() |
80 seen = {} | 85 seen = {} |
81 children = {} | 86 children = {} |
82 | 87 |
83 while visit: | 88 while visit: |
84 n = visit.pop(0) | 89 n = visit.pop(0) |
85 if n in seen: continue | 90 if n in seen: continue |
86 seen[n] = 1 | 91 seen[n] = 1 |
87 pc = 0 | 92 # Ensure that nodes without parents are present in the 'children' |
88 if n in parents: | 93 # mapping. |
89 for p in parents[n]: | 94 children.setdefault(n, []) |
90 if p not in self.map: pc += 1 | 95 for p in parents[n]: |
96 if not p in self.map: | |
91 visit.append(p) | 97 visit.append(p) |
92 children.setdefault(p, []).append(n) | 98 children.setdefault(p, []).append(n) |
93 if not pc: root = n | |
94 | 99 |
95 s = [] | 100 s = [] |
96 removed = {} | 101 removed = {} |
97 visit = children.keys() | 102 visit = children.keys() |
98 while visit: | 103 while visit: |