Patchwork [7,of,8] py3: apply byteskwargs to contrib/perf

login
register
mail settings
Submitter Matt Harbison
Date Sept. 22, 2018, 3:28 p.m.
Message ID <f6dbc0131f506de7f348.1537630123@Envy>
Download mbox | patch
Permalink /patch/34921/
State Accepted
Headers show

Comments

Matt Harbison - Sept. 22, 2018, 3:28 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1537578867 14400
#      Fri Sep 21 21:14:27 2018 -0400
# Node ID f6dbc0131f506de7f3484946b2e1d90c2a087d74
# Parent  716b949d413e7f714f9f5f3595ee462f0a3bb928
py3: apply byteskwargs to contrib/perf

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -430,6 +430,7 @@  def clearfilecache(repo, attrname):
 
 @command(b'perfwalk', formatteropts)
 def perfwalk(ui, repo, *pats, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     m = scmutil.match(repo[None], pats, {})
     timer(lambda: len(list(repo.dirstate.walk(m, subrepos=[], unknown=True,
@@ -438,6 +439,7 @@  def perfwalk(ui, repo, *pats, **opts):
 
 @command(b'perfannotate', formatteropts)
 def perfannotate(ui, repo, f, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     fc = repo[b'.'][f]
     timer(lambda: len(fc.annotate(True)))
@@ -447,6 +449,7 @@  def perfannotate(ui, repo, f, **opts):
          [(b'u', b'unknown', False,
            b'ask status to look for unknown files')] + formatteropts)
 def perfstatus(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     #m = match.always(repo.root, repo.getcwd())
     #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False,
     #                                                False))))
@@ -456,6 +459,7 @@  def perfstatus(ui, repo, **opts):
 
 @command(b'perfaddremove', formatteropts)
 def perfaddremove(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     try:
         oldquiet = repo.ui.quiet
@@ -478,6 +482,7 @@  def clearcaches(cl):
 
 @command(b'perfheads', formatteropts)
 def perfheads(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     cl = repo.changelog
     def d():
@@ -490,6 +495,8 @@  def perfheads(ui, repo, **opts):
 def perftags(ui, repo, **opts):
     import mercurial.changelog
     import mercurial.manifest
+
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     svfs = getsvfs(repo)
     repocleartagscache = repocleartagscachefunc(repo)
@@ -503,6 +510,7 @@  def perftags(ui, repo, **opts):
 
 @command(b'perfancestors', formatteropts)
 def perfancestors(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     heads = repo.changelog.headrevs()
     def d():
@@ -513,6 +521,7 @@  def perfancestors(ui, repo, **opts):
 
 @command(b'perfancestorset', formatteropts)
 def perfancestorset(ui, repo, revset, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     revs = repo.revs(revset)
     heads = repo.changelog.headrevs()
@@ -526,6 +535,7 @@  def perfancestorset(ui, repo, revset, **
 @command(b'perfbookmarks', formatteropts)
 def perfbookmarks(ui, repo, **opts):
     """benchmark parsing bookmarks from disk to memory"""
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     def d():
         clearfilecache(repo, b'_bookmarks')
@@ -546,6 +556,8 @@  def perfbundleread(ui, repo, bundlepath,
         streamclone,
     )
 
+    opts = pycompat.byteskwargs(opts)
+
     def makebench(fn):
         def run():
             with open(bundlepath, b'rb') as fh:
@@ -662,6 +674,7 @@  def perfchangegroupchangelog(ui, repo, v
 
     By default, all revisions are added to the changegroup.
     """
+    opts = pycompat.byteskwargs(opts)
     cl = repo.changelog
     nodes = [cl.lookup(r) for r in repo.revs(rev or b'all()')]
     bundler = changegroup.getbundler(version, repo)
@@ -681,6 +694,7 @@  def perfchangegroupchangelog(ui, repo, v
 
 @command(b'perfdirs', formatteropts)
 def perfdirs(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     dirstate = repo.dirstate
     b'a' in dirstate
@@ -692,6 +706,7 @@  def perfdirs(ui, repo, **opts):
 
 @command(b'perfdirstate', formatteropts)
 def perfdirstate(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     b"a" in repo.dirstate
     def d():
@@ -702,6 +717,7 @@  def perfdirstate(ui, repo, **opts):
 
 @command(b'perfdirstatedirs', formatteropts)
 def perfdirstatedirs(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     b"a" in repo.dirstate
     def d():
@@ -712,6 +728,7 @@  def perfdirstatedirs(ui, repo, **opts):
 
 @command(b'perfdirstatefoldmap', formatteropts)
 def perfdirstatefoldmap(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     dirstate = repo.dirstate
     b'a' in dirstate
@@ -723,6 +740,7 @@  def perfdirstatefoldmap(ui, repo, **opts
 
 @command(b'perfdirfoldmap', formatteropts)
 def perfdirfoldmap(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     dirstate = repo.dirstate
     b'a' in dirstate
@@ -735,6 +753,7 @@  def perfdirfoldmap(ui, repo, **opts):
 
 @command(b'perfdirstatewrite', formatteropts)
 def perfdirstatewrite(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     ds = repo.dirstate
     b"a" in ds
@@ -747,6 +766,7 @@  def perfdirstatewrite(ui, repo, **opts):
 @command(b'perfmergecalculate',
          [(b'r', b'rev', b'.', b'rev to merge against')] + formatteropts)
 def perfmergecalculate(ui, repo, rev, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     wctx = repo[None]
     rctx = scmutil.revsingle(repo, rev, rev)
@@ -764,6 +784,7 @@  def perfmergecalculate(ui, repo, rev, **
 
 @command(b'perfpathcopies', [], b"REV REV")
 def perfpathcopies(ui, repo, rev1, rev2, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     ctx1 = scmutil.revsingle(repo, rev1, rev1)
     ctx2 = scmutil.revsingle(repo, rev2, rev2)
@@ -777,6 +798,7 @@  def perfpathcopies(ui, repo, rev1, rev2,
           ], b"")
 def perfphases(ui, repo, **opts):
     """benchmark phasesets computation"""
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     _phases = repo._phasecache
     full = opts.get(b'full')
@@ -802,6 +824,7 @@  def perfphasesremote(ui, repo, dest=None
         hg,
         phases,
     )
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
 
     path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
@@ -856,6 +879,7 @@  def perfmanifest(ui, repo, rev, manifest
     dict-like object
 
     Manifest caches are cleared before retrieval."""
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     if not manifest_rev:
         ctx = scmutil.revsingle(repo, rev, rev)
@@ -884,6 +908,7 @@  def perfmanifest(ui, repo, rev, manifest
 
 @command(b'perfchangeset', formatteropts)
 def perfchangeset(ui, repo, rev, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     n = scmutil.revsingle(repo, rev).node()
     def d():
@@ -895,6 +920,7 @@  def perfchangeset(ui, repo, rev, **opts)
 @command(b'perfindex', formatteropts)
 def perfindex(ui, repo, **opts):
     import mercurial.revlog
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
     n = repo[b"tip"].node()
@@ -907,6 +933,7 @@  def perfindex(ui, repo, **opts):
 
 @command(b'perfstartup', formatteropts)
 def perfstartup(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     cmd = sys.argv[0]
     def d():
@@ -920,6 +947,7 @@  def perfstartup(ui, repo, **opts):
 
 @command(b'perfparents', formatteropts)
 def perfparents(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     # control the number of commits perfparents iterates over
     # experimental config: perf.parentscount
@@ -936,6 +964,7 @@  def perfparents(ui, repo, **opts):
 
 @command(b'perfctxfiles', formatteropts)
 def perfctxfiles(ui, repo, x, **opts):
+    opts = pycompat.byteskwargs(opts)
     x = int(x)
     timer, fm = gettimer(ui, opts)
     def d():
@@ -945,6 +974,7 @@  def perfctxfiles(ui, repo, x, **opts):
 
 @command(b'perfrawfiles', formatteropts)
 def perfrawfiles(ui, repo, x, **opts):
+    opts = pycompat.byteskwargs(opts)
     x = int(x)
     timer, fm = gettimer(ui, opts)
     cl = repo.changelog
@@ -955,6 +985,7 @@  def perfrawfiles(ui, repo, x, **opts):
 
 @command(b'perflookup', formatteropts)
 def perflookup(ui, repo, rev, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     timer(lambda: len(repo.lookup(rev)))
     fm.end()
@@ -966,6 +997,8 @@  def perflookup(ui, repo, rev, **opts):
 def perflinelogedits(ui, **opts):
     from mercurial import linelog
 
+    opts = pycompat.byteskwargs(opts)
+
     edits = opts[b'edits']
     maxhunklines = opts[b'max_hunk_lines']
 
@@ -993,6 +1026,7 @@  def perflinelogedits(ui, **opts):
 
 @command(b'perfrevrange', formatteropts)
 def perfrevrange(ui, repo, *specs, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     revrange = scmutil.revrange
     timer(lambda: len(revrange(repo, specs)))
@@ -1000,6 +1034,7 @@  def perfrevrange(ui, repo, *specs, **opt
 
 @command(b'perfnodelookup', formatteropts)
 def perfnodelookup(ui, repo, rev, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     import mercurial.revlog
     mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
@@ -1015,6 +1050,7 @@  def perfnodelookup(ui, repo, rev, **opts
          [(b'', b'rename', False, b'ask log to follow renames')
          ] + formatteropts)
 def perflog(ui, repo, rev=None, **opts):
+    opts = pycompat.byteskwargs(opts)
     if rev is None:
         rev=[]
     timer, fm = gettimer(ui, opts)
@@ -1030,6 +1066,7 @@  def perfmoonwalk(ui, repo, **opts):
 
     This also loads the changelog data for each revision in the changelog.
     """
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     def moonwalk():
         for i in repo.changelog.revs(start=(len(repo) - 1), stop=-1):
@@ -1047,6 +1084,8 @@  def perftemplating(ui, repo, testedtempl
         raise error.Abort((b"perftemplating not available with this Mercurial"),
                           hint=b"use 4.3 or later")
 
+    opts = pycompat.byteskwargs(opts)
+
     nullui = ui.copy()
     nullui.fout = open(os.devnull, r'wb')
     nullui.disablepager()
@@ -1072,12 +1111,14 @@  def perftemplating(ui, repo, testedtempl
 
 @command(b'perfcca', formatteropts)
 def perfcca(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     timer(lambda: scmutil.casecollisionauditor(ui, False, repo.dirstate))
     fm.end()
 
 @command(b'perffncacheload', formatteropts)
 def perffncacheload(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     s = repo.store
     def d():
@@ -1087,6 +1128,7 @@  def perffncacheload(ui, repo, **opts):
 
 @command(b'perffncachewrite', formatteropts)
 def perffncachewrite(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     s = repo.store
     lock = repo.lock()
@@ -1103,6 +1145,7 @@  def perffncachewrite(ui, repo, **opts):
 
 @command(b'perffncacheencode', formatteropts)
 def perffncacheencode(ui, repo, **opts):
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     s = repo.store
     s.fncache._load()
@@ -1258,6 +1301,7 @@  def perfunidiff(ui, repo, file_, rev=Non
     measure diffs for all changes related to that changeset (manifest
     and filelogs).
     """
+    opts = pycompat.byteskwargs(opts)
     if opts[b'alldata']:
         opts[b'changelog'] = True
 
@@ -1307,6 +1351,7 @@  def perfunidiff(ui, repo, file_, rev=Non
 @command(b'perfdiffwd', formatteropts)
 def perfdiffwd(ui, repo, **opts):
     """Profile diff of working directory changes"""
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     options = {
         b'w': b'ignore_all_space',
@@ -1334,6 +1379,8 @@  def perfrevlogindex(ui, repo, file_=None
     index data.
     """
 
+    opts = pycompat.byteskwargs(opts)
+
     rl = cmdutil.openrevlog(repo, b'perfrevlogindex', file_, opts)
 
     opener = getattr(rl, 'opener')  # trick linter
@@ -1454,6 +1501,8 @@  def perfrevlogrevisions(ui, repo, file_=
 
     The start revision can be defined via ``-s/--startrev``.
     """
+    opts = pycompat.byteskwargs(opts)
+
     rl = cmdutil.openrevlog(repo, b'perfrevlogrevisions', file_, opts)
     rllen = getlen(ui)(rl)
 
@@ -1493,6 +1542,8 @@  def perfrevlogchunks(ui, repo, file_=Non
     For measurements of higher-level operations like resolving revisions,
     see ``perfrevlogrevisions`` and ``perfrevlogrevision``.
     """
+    opts = pycompat.byteskwargs(opts)
+
     rl = cmdutil.openrevlog(repo, b'perfrevlogchunks', file_, opts)
 
     # _chunkraw was renamed to _getsegmentforrevs.
@@ -1609,6 +1660,8 @@  def perfrevlogrevision(ui, repo, file_, 
 
     This command measures the time spent in each of these phases.
     """
+    opts = pycompat.byteskwargs(opts)
+
     if opts.get(b'changelog') or opts.get(b'manifest'):
         file_, rev = None, file_
     elif rev is None:
@@ -1713,6 +1766,8 @@  def perfrevset(ui, repo, expr, clear=Fal
     Use the --clean option if need to evaluate the impact of build volatile
     revisions set cache on the revset execution. Volatile cache hold filtered
     and obsolete related cache."""
+    opts = pycompat.byteskwargs(opts)
+
     timer, fm = gettimer(ui, opts)
     def d():
         if clear:
@@ -1731,6 +1786,7 @@  def perfvolatilesets(ui, repo, *names, *
     """benchmark the computation of various volatile set
 
     Volatile set computes element related to filtering and obsolescence."""
+    opts = pycompat.byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     repo = repo.unfiltered()
 
@@ -1776,6 +1832,7 @@  def perfbranchmap(ui, repo, *filternames
 
     This benchmarks the full repo.branchmap() call with read and write disabled
     """
+    opts = pycompat.byteskwargs(opts)
     full = opts.get(b"full", False)
     clear_revbranch = opts.get(b"clear_revbranch", False)
     timer, fm = gettimer(ui, opts)
@@ -1839,6 +1896,8 @@  def perfbranchmap(ui, repo, *filternames
     ] + formatteropts)
 def perfbranchmapread(ui, repo, filter=b'', list=False, **opts):
     """benchmark reading the branchmap"""
+    opts = pycompat.byteskwargs(opts)
+
     if list:
         for name, kind, st in repo.cachevfs.readdir(stat=True):
             if name.startswith(b'branch2'):
@@ -1880,6 +1939,8 @@  def perfloadmarkers(ui, repo):
     norepo=True)
 def perflrucache(ui, mincost=0, maxcost=100, costlimit=0, size=4,
                  gets=10000, sets=10000, mixed=10000, mixedgetfreq=50, **opts):
+    opts = pycompat.byteskwargs(opts)
+
     def doinit():
         for i in pycompat.xrange(10000):
             util.lrucachedict(size)
@@ -2001,6 +2062,8 @@  def perflrucache(ui, mincost=0, maxcost=
 def perfwrite(ui, repo, **opts):
     """microbenchmark ui.write
     """
+    opts = pycompat.byteskwargs(opts)
+
     timer, fm = gettimer(ui, opts)
     def write():
         for i in range(100000):