##// END OF EJS Templates
rust-matchers: fix quadratic complexity in `FileMatcher`...
rust-matchers: fix quadratic complexity in `FileMatcher` Concretely, this command: ``` $ echo hg up -r <nodeid>; time hg revert dir1 dir2 -r <othernode> --debug hg up -r <nodeid> real 0m14.690s user 0m14.766s sys 0m5.430s ``` was much slower despite using 16 cores before this change. The approach taken here is the same one used in match.py, in exactmatcher. This changeset was originally written by Valentin Gatien-Baron in a private repository. I have redacted the commit message and did a minor clean up of the code.

File last commit:

r49952:04837f01 default
r52002:687e192d default
Show More
cli.py
154 lines | 4.0 KiB | text/x-python | PythonLexer
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913 # cli.py - Command line interface for automation
#
# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
# no-check-code because Python 3 native.
import argparse
import os
import pathlib
from . import (
inno,
wix,
)
HERE = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
SOURCE_DIR = HERE.parent.parent.parent
Gregory Szorc
packaging: remove py2exe / Python 2.7 support...
r49703 def build_inno(pyoxidizer_target, iscc=None, version=None):
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913 if iscc:
iscc = pathlib.Path(iscc)
else:
iscc = (
pathlib.Path(os.environ["ProgramFiles(x86)"])
/ "Inno Setup 5"
/ "ISCC.exe"
)
build_dir = SOURCE_DIR / "build"
Gregory Szorc
packaging: remove py2exe / Python 2.7 support...
r49703 inno.build_with_pyoxidizer(
SOURCE_DIR, build_dir, pyoxidizer_target, iscc, version=version
)
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913
def build_wix(
Gregory Szorc
packaging: remove py2exe / Python 2.7 support...
r49703 pyoxidizer_target,
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913 name=None,
version=None,
sign_sn=None,
sign_cert=None,
sign_password=None,
sign_timestamp_url=None,
extra_wxs=None,
extra_features=None,
Augie Fackler
packaging: add command line flag to add extra vars to pyoxidizer...
r48444 extra_pyoxidizer_vars=None,
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913 ):
kwargs = {
"source_dir": SOURCE_DIR,
"version": version,
Gregory Szorc
packaging: remove py2exe / Python 2.7 support...
r49703 "target_triple": pyoxidizer_target,
"extra_pyoxidizer_vars": extra_pyoxidizer_vars,
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913 }
if extra_wxs:
kwargs["extra_wxs"] = dict(
thing.split("=") for thing in extra_wxs.split(",")
)
if extra_features:
kwargs["extra_features"] = extra_features.split(",")
if sign_sn or sign_cert:
Gregory Szorc
packaging: integrate signing into run_wix_packaging()...
r45272 kwargs["signing_info"] = {
"name": name,
"subject_name": sign_sn,
"cert_path": sign_cert,
"cert_password": sign_password,
"timestamp_url": sign_timestamp_url,
}
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913
Gregory Szorc
packaging: remove py2exe / Python 2.7 support...
r49703 wix.build_installer_pyoxidizer(**kwargs)
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913
def get_parser():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
sp = subparsers.add_parser("inno", help="Build Inno Setup installer")
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 sp.add_argument(
"--pyoxidizer-target",
choices={"i686-pc-windows-msvc", "x86_64-pc-windows-msvc"},
Gregory Szorc
packaging: remove py2exe / Python 2.7 support...
r49703 required=True,
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 help="Build with PyOxidizer targeting this host triple",
)
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913 sp.add_argument("--iscc", help="path to iscc.exe to use")
sp.add_argument(
"--version",
help="Mercurial version string to use "
Matt Harbison
packaging: add a missing parenthesis to help text...
r49970 "(detected from __version__.py if not defined)",
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913 )
sp.set_defaults(func=build_inno)
sp = subparsers.add_parser(
"wix", help="Build Windows installer with WiX Toolset"
)
sp.add_argument("--name", help="Application name", default="Mercurial")
sp.add_argument(
Gregory Szorc
packaging: support building WiX installers with PyOxidizer...
r45274 "--pyoxidizer-target",
choices={"i686-pc-windows-msvc", "x86_64-pc-windows-msvc"},
Gregory Szorc
packaging: remove py2exe / Python 2.7 support...
r49703 required=True,
Gregory Szorc
packaging: support building WiX installers with PyOxidizer...
r45274 help="Build with PyOxidizer targeting this host triple",
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913 )
sp.add_argument(
"--sign-sn",
help="Subject name (or fragment thereof) of certificate "
"to use for signing",
)
sp.add_argument(
"--sign-cert", help="Path to certificate to use for signing"
)
sp.add_argument("--sign-password", help="Password for signing certificate")
sp.add_argument(
"--sign-timestamp-url",
help="URL of timestamp server to use for signing",
)
sp.add_argument("--version", help="Version string to use")
sp.add_argument(
"--extra-wxs", help="CSV of path_to_wxs_file=working_dir_for_wxs_file"
)
sp.add_argument(
"--extra-features",
help=(
"CSV of extra feature names to include "
"in the installer from the extra wxs files"
),
)
Augie Fackler
packaging: add command line flag to add extra vars to pyoxidizer...
r48444
sp.add_argument(
"--extra-pyoxidizer-vars",
help="json map of extra variables to pass to pyoxidizer",
)
Gregory Szorc
packaging: consolidate CLI functionality into packaging.py...
r43913 sp.set_defaults(func=build_wix)
return parser
def main():
parser = get_parser()
args = parser.parse_args()
if not hasattr(args, "func"):
parser.print_help()
return
kwargs = dict(vars(args))
del kwargs["func"]
args.func(**kwargs)