Patchwork [5,of,7] contrib/perf: perfparents handle tiny repos

login
register
mail settings
Submitter timeless@mozdev.org
Date Nov. 24, 2015, 10:36 p.m.
Message ID <3cf447f1d3a7d7796933.1448404588@waste.org>
Download mbox | patch
Permalink /patch/11624/
State Accepted
Headers show

Comments

timeless@mozdev.org - Nov. 24, 2015, 10:36 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1448398454 0
#      Tue Nov 24 20:54:14 2015 +0000
# Node ID 3cf447f1d3a7d77969331a93c8cd003b1dbcbaf7
# Parent  8fe942905e529e04e6d0e19e5b62ee6458eb1266
contrib/perf: perfparents handle tiny repos

refuse to run if there are not enough commits

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -2,7 +2,7 @@ 
 '''helper extension to measure performance'''
 
 from mercurial import cmdutil, scmutil, util, commands, obsolete
-from mercurial import repoview, branchmap, merge, copies
+from mercurial import repoview, branchmap, merge, copies, error
 import time, os, sys
 import functools
 
@@ -300,6 +300,8 @@ 
 @command('perfparents', formatteropts)
 def perfparents(ui, repo, **opts):
     timer, fm = gettimer(ui, opts)
+    if len(repo.changelog) < 1000:
+        raise error.Abort("repo needs 1000 commits for this test")
     nl = [repo.changelog.node(i) for i in xrange(1000)]
     def d():
         for n in nl: