# HG changeset patch # User Hollis Blanchard # Date 1182801025 18000 # Node ID 1069205a8894cc6e73c1c5775d1d175a141d3925 # Parent 934275cd45264011c179bd9b22104a3ce420cad5 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. diff -r 934275cd4526 -r 1069205a8894 hgext/convert/__init__.py --- a/hgext/convert/__init__.py Mon Jun 25 12:44:48 2007 -0500 +++ b/hgext/convert/__init__.py Mon Jun 25 14:50:25 2007 -0500 @@ -60,6 +60,8 @@ self.authorfile = self.dest.authorfile() def walktree(self, heads): + '''Return a mapping that identifies the uncommitted parents of every + uncommitted changeset.''' visit = heads known = {} parents = {} @@ -69,13 +71,16 @@ known[n] = 1 self.commitcache[n] = self.source.getcommit(n) cp = self.commitcache[n].parents + parents[n] = [] for p in cp: - parents.setdefault(n, []).append(p) + parents[n].append(p) visit.append(p) return parents def toposort(self, parents): + '''Return an ordering such that every uncommitted changeset is + preceeded by all its uncommitted ancestors.''' visit = parents.keys() seen = {} children = {} @@ -84,13 +89,13 @@ n = visit.pop(0) if n in seen: continue seen[n] = 1 - pc = 0 - if n in parents: - for p in parents[n]: - if p not in self.map: pc += 1 + # Ensure that nodes without parents are present in the 'children' + # mapping. + children.setdefault(n, []) + for p in parents[n]: + if not p in self.map: visit.append(p) - children.setdefault(p, []).append(n) - if not pc: root = n + children.setdefault(p, []).append(n) s = [] removed = {}