From 6431a1d631012014aaeb814b1cd53da1e80e6169 Mon Sep 17 00:00:00 2001 From: Mike Edgar Date: Fri, 12 Sep 2014 17:43:37 -0400 Subject: [PATCH] contrib/synthrepo: only generate 2 parents if model contains merges If `hg analyze` is run on a revision set which contains no merges, then `hg synthesize` will raise IndexError trying to select from p2distance, which will be empty. --- contrib/synthrepo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/synthrepo.py b/contrib/synthrepo.py index ebf2b38dad..ebe59ac8e0 100644 --- a/contrib/synthrepo.py +++ b/contrib/synthrepo.py @@ -307,7 +307,8 @@ def synthesize(ui, repo, descpath, **opts): # the number of heads will grow without bound if we use a pure # model, so artificially constrain their proliferation - if pick(parents) == 2 or len(heads) > random.randint(1, 20): + toomanyheads = len(heads) > random.randint(1, 20) + if p2distance[0] and (pick(parents) == 2 or toomanyheads): r2, p2 = pickhead(heads.difference([r1]), p2distance) else: r2, p2 = nullrev, nullid