All pastes #1985310 Raw Edit

nicdumz

public text v1 · immutable
#1985310 ·published 2010-11-08 13:46 UTC
rendered paste body
# HG changeset patch# User Nicolas Dumazet <nicdumz.commits@gmail.com># Date 1289223956 -32400# Branch stable# Node ID e093b1da75b8d19000fc8345440d69ae89cc7cb1# Parent  f30f92be07e4b2cf2b23bbfb5b525e32b58f2156graphmod: safer code when a changeset has two identical parentsWhile this situation should never happen in usual situations, some reallife repos sometime contain such changesets due to incorrect tools.hgweb was displaying an "Internal error" in this case, and graphlogdisplayed a redundant branch all the way to null.diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py--- a/mercurial/graphmod.py+++ b/mercurial/graphmod.py@@ -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):diff --git a/tests/test-glog.t b/tests/test-glog.t--- a/tests/test-glog.t+++ b/tests/test-glog.t@@ -887,3 +887,39 @@   | |  summary:     (33) head   | | +Do not crash or produce strange graphs if history is buggy++  $ commit 36 "buggy merge: identical parents" 35 35+  $ hg glog -l5+  @  changeset:   36:95fa8febd08a+  |  tag:         tip+  |  parent:      35:9159c3644c5e+  |  parent:      35:9159c3644c5e+  |  user:        test+  |  date:        Thu Jan 01 00:00:36 1970 +0000+  |  summary:     (36) buggy merge: identical parents+  |+  o  changeset:   35:9159c3644c5e+  |  user:        test+  |  date:        Thu Jan 01 00:00:00 1970 +0000+  |  summary:     0+  |+  o  changeset:   34:fea3ac5810e0+  |  parent:      32:d06dffa21a31+  |  user:        test+  |  date:        Thu Jan 01 00:00:34 1970 +0000+  |  summary:     (34) head+  |+  | o  changeset:   33:68608f5145f9+  | |  parent:      18:1aa84d96232a+  | |  user:        test+  | |  date:        Thu Jan 01 00:00:33 1970 +0000+  | |  summary:     (33) head+  | |+  o |    changeset:   32:d06dffa21a31+  |\ \   parent:      27:886ed638191b+  | | |  parent:      31:621d83e11f67+  | | |  user:        test+  | | |  date:        Thu Jan 01 00:00:32 1970 +0000+  | | |  summary:     (32) expand+  | | |