[PATCH 1 of 4] contrib/synthrepo: only generate 2 parents if model contains merges

adgar at google.com adgar at google.com
Sat Sep 13 16:55:41 UTC 2014


# HG changeset patch
# User Mike Edgar <adgar at google.com>
# Date 1410558217 14400
#      Fri Sep 12 17:43:37 2014 -0400
# Node ID 1b1aeb594ac261750ebf95c1f92257d9c1f7d3ac
# Parent  f08b657130b9ac7cd2ad27afea6895dfde7d7722
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.

diff -r f08b657130b9 -r 1b1aeb594ac2 contrib/synthrepo.py
--- a/contrib/synthrepo.py	Fri Sep 05 11:37:44 2014 -0700
+++ b/contrib/synthrepo.py	Fri Sep 12 17:43:37 2014 -0400
@@ -307,7 +307,8 @@
 
         # 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):
+        if p2distance[0] and (
+            pick(parents) == 2 or len(heads) > random.randint(1, 20)):
             r2, p2 = pickhead(heads.difference([r1]), p2distance)
         else:
             r2, p2 = nullrev, nullid


More information about the Mercurial-devel mailing list