comparison contrib/synthrepo.py @ 22472:2e2577b0ccbe

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.
author Mike Edgar <adgar@google.com>
date Fri, 12 Sep 2014 17:43:37 -0400
parents 054ec0212718
children ca85306b3eb2
comparison
equal deleted inserted replaced
22471:cc5f94db672b 22472:2e2577b0ccbe
305 r1 = revs - min(pick(p1distance), revs) 305 r1 = revs - min(pick(p1distance), revs)
306 p1 = node(r1) 306 p1 = node(r1)
307 307
308 # the number of heads will grow without bound if we use a pure 308 # the number of heads will grow without bound if we use a pure
309 # model, so artificially constrain their proliferation 309 # model, so artificially constrain their proliferation
310 if pick(parents) == 2 or len(heads) > random.randint(1, 20): 310 toomanyheads = len(heads) > random.randint(1, 20)
311 if p2distance[0] and (pick(parents) == 2 or toomanyheads):
311 r2, p2 = pickhead(heads.difference([r1]), p2distance) 312 r2, p2 = pickhead(heads.difference([r1]), p2distance)
312 else: 313 else:
313 r2, p2 = nullrev, nullid 314 r2, p2 = nullrev, nullid
314 315
315 pl = [p1, p2] 316 pl = [p1, p2]