[PATCH 6 of 6 V2] perf: make perf command import newer module locally for earlier Mercurial

Yuya Nishihara yuya at tcha.org
Sat Jul 9 08:02:28 EDT 2016


On Tue, 05 Jul 2016 07:37:07 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1467671151 -32400
> #      Tue Jul 05 07:25:51 2016 +0900
> # Node ID 92b86498070cd8be6320da214203a67c0b257bde
> # Parent  c19962592bbce7ffd5e82450d2e6cb40ceed90f9
> perf: make perf command import newer module locally for earlier Mercurial

> +# modules, which are available both at 1.2 and 3.8
> +_modwhitelist = '''
> +ancestor
> +archival
> +base85
> +bdiff
> +bundlerepo
> +byterange
> +changegroup
> +changelog
> +cmdutil
> +commands
> +context
> +copies
> +demandimport
> +diffhelpers
> +dirstate
> +dispatch
> +error
> +extensions
> +fancyopts
> +filelog
> +filemerge
> +graphmod
> +hbisect
> +help
> +hg
> +hook
> +i18n
> +keepalive
> +localrepo
> +lock
> +lsprof
> +mail
> +manifest
> +match
> +mdiff
> +merge
> +mpatch
> +node
> +osutil
> +parsers
> +patch
> +repair
> +revlog
> +simplemerge
> +sshserver
> +statichttprepo
> +store
> +streamclone
> +strutil
> +templatefilters
> +templater
> +transaction
> +ui
> +url
> +util
> +verify
> +'''.split()

Can't be a separate test-check-pref.t and generate the list by hg commands?

> diff --git a/contrib/perf.py b/contrib/perf.py
> --- a/contrib/perf.py
> +++ b/contrib/perf.py
> @@ -25,7 +25,6 @@ import random
>  import sys
>  import time
>  from mercurial import (
> -    branchmap,
>      cmdutil,
>      commands,
>      copies,
> @@ -33,10 +32,7 @@ from mercurial import (
>      extensions,
>      mdiff,
>      merge,
> -    obsolete,
> -    repoview,
>      revlog,
> -    scmutil,
>      util,
>  )
>  
> @@ -167,6 +163,11 @@ def _timer(fm, func, title=None):
>  
>  @command('perfwalk', formatteropts)
>  def perfwalk(ui, repo, *pats, **opts):
> +    # for "historical portability":
> +    # import locally, because:
> +    # - scmutil has been available since 1.9 (or 8b252e826c68)
> +    from mercurial import scmutil

I prefer conditional import at top rather than copying portability comment
to every place where scmutil is used. Optionally, @command decorator could
be extended to omit unsupported commands from cmdtable, e.g.

  @command('prefwalk', formatteropts, requiremods='scmutil')


More information about the Mercurial-devel mailing list