[PATCH 1 of 4] contrib/synthrepo: only generate 2 parents if model contains merges
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Wed Sep 17 19:52:56 CDT 2014
On 09/13/2014 09:55 AM, adgar at google.com wrote:
> # 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
This one is pushed to the clowncopter. (with a small style fixes)
>
> 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
I killed the ugly oneliner this way:
- if p2distance[0] and (
- 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):
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list