diff mercurial/graphmod.py @ 12951:101366ad816c stable

graphmod: safer code when a changeset has two identical parents While this situation should never under normal use, some real life repos sometimes contain such changesets (older hg versions, broken rebases, etc...) hgweb was displaying an "Internal error" in this case, and graphlog displayed a redundant branch all the way to null: it does not cost us much to just ignore this extra parent when constructing the DAG.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Mon, 08 Nov 2010 22:45:56 +0900
parents 94145b531cf9
children 9966c95b8c4f
line wrap: on
line diff
--- a/mercurial/graphmod.py	Sun Nov 07 18:23:48 2010 +0900
+++ b/mercurial/graphmod.py	Mon Nov 08 22:45:56 2010 +0900
@@ -32,7 +32,7 @@
     cur = start
     while cur >= stop:
         ctx = repo[cur]
-        parents = [p.rev() for p in ctx.parents() if p.rev() != nullrev]
+        parents = set([p.rev() for p in ctx.parents() if p.rev() != nullrev])
         yield (cur, CHANGESET, ctx, sorted(parents))
         cur -= 1
 
@@ -47,7 +47,7 @@
     count = 0
     while filerev >= 0 and rev > stop:
         fctx = repo.filectx(path, fileid=filerev)
-        parents = [f.linkrev() for f in fctx.parents() if f.path() == path]
+        parents = set([f.linkrev() for f in fctx.parents() if f.path() == path])
         rev = fctx.rev()
         if rev <= start:
             yield (rev, CHANGESET, fctx.changectx(), sorted(parents))
@@ -65,7 +65,7 @@
     include = set(nodes)
     for node in nodes:
         ctx = repo[node]
-        parents = [p.rev() for p in ctx.parents() if p.node() in include]
+        parents = set([p.rev() for p in ctx.parents() if p.node() in include])
         yield (ctx.rev(), CHANGESET, ctx, sorted(parents))
 
 def colored(dag):