Show More
@@ -27,32 +27,42 b' beforepatch = afterheader + r"(?!\\n(?!@@' | |||
|
27 | 27 | |
|
28 | 28 | errors = [ |
|
29 | 29 | (beforepatch + r".*[(]bc[)]", "(BC) needs to be uppercase"), |
|
30 | (beforepatch + r".*[(]issue \d\d\d", | |
|
31 | "no space allowed between issue and number"), | |
|
30 | ( | |
|
31 | beforepatch + r".*[(]issue \d\d\d", | |
|
32 | "no space allowed between issue and number", | |
|
33 | ), | |
|
32 | 34 | (beforepatch + r".*[(]bug(\d|\s)", "use (issueDDDD) instead of bug"), |
|
33 | 35 | (commitheader + r"# User [^@\n]+\n", "username is not an email address"), |
|
34 | (commitheader + r"(?!merge with )[^#]\S+[^:] ", | |
|
35 | "summary line doesn't start with 'topic: '"), | |
|
36 | ( | |
|
37 | commitheader + r"(?!merge with )[^#]\S+[^:] ", | |
|
38 | "summary line doesn't start with 'topic: '", | |
|
39 | ), | |
|
36 | 40 | (afterheader + r"[A-Z][a-z]\S+", "don't capitalize summary lines"), |
|
37 | 41 | (afterheader + r"^\S+: *[A-Z][a-z]\S+", "don't capitalize summary lines"), |
|
38 | (afterheader + r"\S*[^A-Za-z0-9-_]\S*: ", | |
|
39 | "summary keyword should be most user-relevant one-word command or topic"), | |
|
42 | ( | |
|
43 | afterheader + r"\S*[^A-Za-z0-9-_]\S*: ", | |
|
44 | "summary keyword should be most user-relevant one-word command or topic", | |
|
45 | ), | |
|
40 | 46 | (afterheader + r".*\.\s*\n", "don't add trailing period on summary line"), |
|
41 | 47 | (afterheader + r".{79,}", "summary line too long (limit is 78)"), |
|
42 | 48 | ] |
|
43 | 49 | |
|
44 | 50 | word = re.compile(r'\S') |
|
51 | ||
|
52 | ||
|
45 | 53 | def nonempty(first, second): |
|
46 | 54 | if word.search(first): |
|
47 | 55 | return first |
|
48 | 56 | return second |
|
49 | 57 | |
|
58 | ||
|
50 | 59 | def checkcommit(commit, node=None): |
|
51 | 60 | exitcode = 0 |
|
52 | 61 | printed = node is None |
|
53 | 62 | hits = [] |
|
54 |
signtag = ( |
|
|
55 |
r'Added (tag [^ ]+|signature) for changeset [a-f0-9]{12}' |
|
|
63 | signtag = ( | |
|
64 | afterheader + r'Added (tag [^ ]+|signature) for changeset [a-f0-9]{12}' | |
|
65 | ) | |
|
56 | 66 | if re.search(signtag, commit): |
|
57 | 67 | return 0 |
|
58 | 68 | for exp, msg in errors: |
@@ -84,9 +94,11 b' def checkcommit(commit, node=None):' | |||
|
84 | 94 | |
|
85 | 95 | return exitcode |
|
86 | 96 | |
|
97 | ||
|
87 | 98 | def readcommit(node): |
|
88 | 99 | return os.popen("hg export %s" % node).read() |
|
89 | 100 | |
|
101 | ||
|
90 | 102 | if __name__ == "__main__": |
|
91 | 103 | exitcode = 0 |
|
92 | 104 | node = os.environ.get("HG_NODE") |
@@ -11,23 +11,26 b' from mercurial import (' | |||
|
11 | 11 | pycompat, |
|
12 | 12 | revlog, |
|
13 | 13 | ) |
|
14 |
from mercurial.utils import |
|
|
15 | procutil, | |
|
16 | ) | |
|
14 | from mercurial.utils import procutil | |
|
17 | 15 | |
|
18 | 16 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
19 | 17 | procutil.setbinary(fp) |
|
20 | 18 | |
|
19 | ||
|
21 | 20 | def binopen(path, mode=b'rb'): |
|
22 | 21 | if b'b' not in mode: |
|
23 | 22 | mode = mode + b'b' |
|
24 | 23 | return open(path, pycompat.sysstr(mode)) |
|
24 | ||
|
25 | ||
|
25 | 26 | binopen.options = {} |
|
26 | 27 | |
|
28 | ||
|
27 | 29 | def printb(data, end=b'\n'): |
|
28 | 30 | sys.stdout.flush() |
|
29 | 31 | pycompat.stdout.write(data + end) |
|
30 | 32 | |
|
33 | ||
|
31 | 34 | for f in sys.argv[1:]: |
|
32 | 35 | r = revlog.revlog(binopen, encoding.strtolocal(f)) |
|
33 | 36 | print("file:", f) |
@@ -35,7 +35,9 b' import shlex' | |||
|
35 | 35 | import sys |
|
36 | 36 | |
|
37 | 37 | # enable importing on demand to reduce startup time |
|
38 |
import hgdemandimport |
|
|
38 | import hgdemandimport | |
|
39 | ||
|
40 | hgdemandimport.enable() | |
|
39 | 41 | |
|
40 | 42 | from mercurial import ( |
|
41 | 43 | dispatch, |
@@ -43,6 +45,7 b' from mercurial import (' | |||
|
43 | 45 | ui as uimod, |
|
44 | 46 | ) |
|
45 | 47 | |
|
48 | ||
|
46 | 49 | def main(): |
|
47 | 50 | # Prevent insertion/deletion of CRs |
|
48 | 51 | dispatch.initstdio() |
@@ -56,9 +59,10 b' def main():' | |||
|
56 | 59 | args.pop(0) |
|
57 | 60 | else: |
|
58 | 61 | break |
|
59 | allowed_paths = [os.path.normpath(os.path.join(cwd, | |
|
60 | os.path.expanduser(path))) | |
|
61 |
|
|
|
62 | allowed_paths = [ | |
|
63 | os.path.normpath(os.path.join(cwd, os.path.expanduser(path))) | |
|
64 | for path in args | |
|
65 | ] | |
|
62 | 66 | orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?') |
|
63 | 67 | try: |
|
64 | 68 | cmdargv = shlex.split(orig_cmd) |
@@ -75,10 +79,18 b' def main():' | |||
|
75 | 79 | if readonly: |
|
76 | 80 | if not req.ui: |
|
77 | 81 | req.ui = uimod.ui.load() |
|
78 |
req.ui.setconfig( |
|
|
79 | b'python:__main__.rejectpush', b'hg-ssh') | |
|
80 |
|
|
|
81 |
|
|
|
82 | req.ui.setconfig( | |
|
83 | b'hooks', | |
|
84 | b'pretxnopen.hg-ssh', | |
|
85 | b'python:__main__.rejectpush', | |
|
86 | b'hg-ssh', | |
|
87 | ) | |
|
88 | req.ui.setconfig( | |
|
89 | b'hooks', | |
|
90 | b'prepushkey.hg-ssh', | |
|
91 | b'python:__main__.rejectpush', | |
|
92 | b'hg-ssh', | |
|
93 | ) | |
|
82 | 94 | dispatch.dispatch(req) |
|
83 | 95 | else: |
|
84 | 96 | sys.stderr.write('Illegal repository "%s"\n' % repo) |
@@ -87,11 +99,13 b' def main():' | |||
|
87 | 99 | sys.stderr.write('Illegal command "%s"\n' % orig_cmd) |
|
88 | 100 | sys.exit(255) |
|
89 | 101 | |
|
102 | ||
|
90 | 103 | def rejectpush(ui, **kwargs): |
|
91 | 104 | ui.warn((b"Permission denied\n")) |
|
92 | 105 | # mercurial hooks use unix process conventions for hook return values |
|
93 | 106 | # so a truthy return means failure |
|
94 | 107 | return True |
|
95 | 108 | |
|
109 | ||
|
96 | 110 | if __name__ == '__main__': |
|
97 | 111 | main() |
@@ -37,18 +37,24 b" libdir = '@LIBDIR@'" | |||
|
37 | 37 | |
|
38 | 38 | if libdir != '@' 'LIBDIR' '@': |
|
39 | 39 | if not os.path.isabs(libdir): |
|
40 | libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), | |
|
41 | libdir) | |
|
40 | libdir = os.path.join( | |
|
41 | os.path.dirname(os.path.realpath(__file__)), libdir | |
|
42 | ) | |
|
42 | 43 | libdir = os.path.abspath(libdir) |
|
43 | 44 | sys.path.insert(0, libdir) |
|
44 | 45 | |
|
45 | 46 | # enable importing on demand to reduce startup time |
|
46 | 47 | try: |
|
47 |
from mercurial import demandimport |
|
|
48 | from mercurial import demandimport | |
|
49 | ||
|
50 | demandimport.enable() | |
|
48 | 51 | except ImportError: |
|
49 | 52 | import sys |
|
50 | sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" % | |
|
51 | ' '.join(sys.path)) | |
|
53 | ||
|
54 | sys.stderr.write( | |
|
55 | "abort: couldn't find mercurial libraries in [%s]\n" | |
|
56 | % ' '.join(sys.path) | |
|
57 | ) | |
|
52 | 58 | sys.stderr.write("(check your install and PYTHONPATH)\n") |
|
53 | 59 | sys.exit(-1) |
|
54 | 60 | |
@@ -57,6 +63,7 b' from mercurial import (' | |||
|
57 | 63 | util, |
|
58 | 64 | ) |
|
59 | 65 | |
|
66 | ||
|
60 | 67 | def timer(func, title=None): |
|
61 | 68 | results = [] |
|
62 | 69 | begin = util.timer() |
@@ -69,7 +76,7 b' def timer(func, title=None):' | |||
|
69 | 76 | ostop = os.times() |
|
70 | 77 | count += 1 |
|
71 | 78 | a, b = ostart, ostop |
|
72 | results.append((cstop - cstart, b[0] - a[0], b[1]-a[1])) | |
|
79 | results.append((cstop - cstart, b[0] - a[0], b[1] - a[1])) | |
|
73 | 80 | if cstop - begin > 3 and count >= 100: |
|
74 | 81 | break |
|
75 | 82 | if cstop - begin > 10 and count >= 3: |
@@ -79,19 +86,27 b' def timer(func, title=None):' | |||
|
79 | 86 | if r: |
|
80 | 87 | sys.stderr.write("! result: %s\n" % r) |
|
81 | 88 | m = min(results) |
|
82 | sys.stderr.write("! wall %f comb %f user %f sys %f (best of %d)\n" | |
|
83 | % (m[0], m[1] + m[2], m[1], m[2], count)) | |
|
89 | sys.stderr.write( | |
|
90 | "! wall %f comb %f user %f sys %f (best of %d)\n" | |
|
91 | % (m[0], m[1] + m[2], m[1], m[2], count) | |
|
92 | ) | |
|
93 | ||
|
84 | 94 | |
|
85 | 95 | orgruncommand = dispatch.runcommand |
|
86 | 96 | |
|
97 | ||
|
87 | 98 | def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions): |
|
88 | 99 | ui.pushbuffer() |
|
89 | 100 | lui.pushbuffer() |
|
90 | timer(lambda : orgruncommand(lui, repo, cmd, fullargs, ui, | |
|
91 | options, d, cmdpats, cmdoptions)) | |
|
101 | timer( | |
|
102 | lambda: orgruncommand( | |
|
103 | lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions | |
|
104 | ) | |
|
105 | ) | |
|
92 | 106 | ui.popbuffer() |
|
93 | 107 | lui.popbuffer() |
|
94 | 108 | |
|
109 | ||
|
95 | 110 | dispatch.runcommand = runcommand |
|
96 | 111 | |
|
97 | 112 | dispatch.run() |
@@ -7,13 +7,16 b' config = "/path/to/repo/or/config"' | |||
|
7 | 7 | |
|
8 | 8 | # Uncomment and adjust if Mercurial is not installed system-wide |
|
9 | 9 | # (consult "installed modules" path from 'hg debuginstall'): |
|
10 | #import sys; sys.path.insert(0, "/path/to/python/lib") | |
|
10 | # import sys; sys.path.insert(0, "/path/to/python/lib") | |
|
11 | 11 | |
|
12 | 12 | # Uncomment to send python tracebacks to the browser if an error occurs: |
|
13 | #import cgitb; cgitb.enable() | |
|
13 | # import cgitb; cgitb.enable() | |
|
14 | 14 | |
|
15 |
from mercurial import demandimport |
|
|
15 | from mercurial import demandimport | |
|
16 | ||
|
17 | demandimport.enable() | |
|
16 | 18 | from mercurial.hgweb import hgweb |
|
17 | 19 | from flup.server.fcgi import WSGIServer |
|
20 | ||
|
18 | 21 | application = hgweb(config) |
|
19 | 22 | WSGIServer(application).run() |
@@ -11,6 +11,7 b' import shutil' | |||
|
11 | 11 | import subprocess |
|
12 | 12 | import sys |
|
13 | 13 | |
|
14 | ||
|
14 | 15 | def get_docker() -> str: |
|
15 | 16 | docker = shutil.which('docker.io') or shutil.which('docker') |
|
16 | 17 | if not docker: |
@@ -21,15 +22,16 b' def get_docker() -> str:' | |||
|
21 | 22 | out = subprocess.check_output([docker, '-h'], stderr=subprocess.STDOUT) |
|
22 | 23 | |
|
23 | 24 | if b'Jansens' in out: |
|
24 | print('%s is the Docking System Tray; try installing docker.io' % | |
|
25 | docker) | |
|
25 | print( | |
|
26 | '%s is the Docking System Tray; try installing docker.io' | |
|
27 | % docker | |
|
28 | ) | |
|
26 | 29 | sys.exit(1) |
|
27 | 30 | except subprocess.CalledProcessError as e: |
|
28 | 31 | print('error calling `%s -h`: %s' % (docker, e.output)) |
|
29 | 32 | sys.exit(1) |
|
30 | 33 | |
|
31 | out = subprocess.check_output([docker, 'version'], | |
|
32 | stderr=subprocess.STDOUT) | |
|
34 | out = subprocess.check_output([docker, 'version'], stderr=subprocess.STDOUT) | |
|
33 | 35 | |
|
34 | 36 | lines = out.splitlines() |
|
35 | 37 | if not any(l.startswith((b'Client:', b'Client version:')) for l in lines): |
@@ -42,6 +44,7 b' def get_docker() -> str:' | |||
|
42 | 44 | |
|
43 | 45 | return docker |
|
44 | 46 | |
|
47 | ||
|
45 | 48 | def get_dockerfile(path: pathlib.Path, args: list) -> bytes: |
|
46 | 49 | with path.open('rb') as fh: |
|
47 | 50 | df = fh.read() |
@@ -51,6 +54,7 b' def get_dockerfile(path: pathlib.Path, a' | |||
|
51 | 54 | |
|
52 | 55 | return df |
|
53 | 56 | |
|
57 | ||
|
54 | 58 | def build_docker_image(dockerfile: pathlib.Path, params: list, tag: str): |
|
55 | 59 | """Build a Docker image from a templatized Dockerfile.""" |
|
56 | 60 | docker = get_docker() |
@@ -65,9 +69,12 b' def build_docker_image(dockerfile: pathl' | |||
|
65 | 69 | args = [ |
|
66 | 70 | docker, |
|
67 | 71 | 'build', |
|
68 |
'--build-arg', |
|
|
69 |
' |
|
|
70 |
'-- |
|
|
72 | '--build-arg', | |
|
73 | 'http_proxy', | |
|
74 | '--build-arg', | |
|
75 | 'https_proxy', | |
|
76 | '--tag', | |
|
77 | tag, | |
|
71 | 78 | '-', |
|
72 | 79 | ] |
|
73 | 80 | |
@@ -76,8 +83,10 b' def build_docker_image(dockerfile: pathl' | |||
|
76 | 83 | p.communicate(input=dockerfile) |
|
77 | 84 | if p.returncode: |
|
78 | 85 | raise subprocess.CalledProcessException( |
|
79 | p.returncode, 'failed to build docker image: %s %s' | |
|
80 |
% (p.stdout, p.stderr) |
|
|
86 | p.returncode, | |
|
87 | 'failed to build docker image: %s %s' % (p.stdout, p.stderr), | |
|
88 | ) | |
|
89 | ||
|
81 | 90 | |
|
82 | 91 | def command_build(args): |
|
83 | 92 | build_args = [] |
@@ -85,13 +94,13 b' def command_build(args):' | |||
|
85 | 94 | k, v = arg.split('=', 1) |
|
86 | 95 | build_args.append((k.encode('utf-8'), v.encode('utf-8'))) |
|
87 | 96 | |
|
88 | build_docker_image(pathlib.Path(args.dockerfile), | |
|
89 | build_args, | |
|
90 | args.tag) | |
|
97 | build_docker_image(pathlib.Path(args.dockerfile), build_args, args.tag) | |
|
98 | ||
|
91 | 99 | |
|
92 | 100 | def command_docker(args): |
|
93 | 101 | print(get_docker()) |
|
94 | 102 | |
|
103 | ||
|
95 | 104 | def main() -> int: |
|
96 | 105 | parser = argparse.ArgumentParser() |
|
97 | 106 | |
@@ -99,9 +108,12 b' def main() -> int:' | |||
|
99 | 108 | |
|
100 | 109 | build = subparsers.add_parser('build', help='Build a Docker image') |
|
101 | 110 | build.set_defaults(func=command_build) |
|
102 | build.add_argument('--build-arg', action='append', default=[], | |
|
103 | help='Substitution to perform in Dockerfile; ' | |
|
104 | 'format: key=value') | |
|
111 | build.add_argument( | |
|
112 | '--build-arg', | |
|
113 | action='append', | |
|
114 | default=[], | |
|
115 | help='Substitution to perform in Dockerfile; ' 'format: key=value', | |
|
116 | ) | |
|
105 | 117 | build.add_argument('dockerfile', help='path to Dockerfile to use') |
|
106 | 118 | build.add_argument('tag', help='Tag to apply to created image') |
|
107 | 119 | |
@@ -112,5 +124,6 b' def main() -> int:' | |||
|
112 | 124 | |
|
113 | 125 | return args.func(args) |
|
114 | 126 | |
|
127 | ||
|
115 | 128 | if __name__ == '__main__': |
|
116 | 129 | sys.exit(main()) |
@@ -98,6 +98,7 b' groupings = [' | |||
|
98 | 98 | (r"shelve|unshelve", "extensions"), |
|
99 | 99 | ] |
|
100 | 100 | |
|
101 | ||
|
101 | 102 | def wikify(desc): |
|
102 | 103 | desc = desc.replace("(issue", "(Bts:issue") |
|
103 | 104 | desc = re.sub(r"\b([0-9a-f]{12})\b", r"Cset:\1", desc) |
@@ -107,6 +108,7 b' def wikify(desc):' | |||
|
107 | 108 | desc = re.sub(r"\b(\S*__\S*)\b", r"`\1`", desc) |
|
108 | 109 | return desc |
|
109 | 110 | |
|
111 | ||
|
110 | 112 | def main(): |
|
111 | 113 | desc = "example: %(prog)s 4.7.2 --stoprev 4.8rc0" |
|
112 | 114 | ap = argparse.ArgumentParser(description=desc) |
@@ -200,5 +202,6 b' def main():' | |||
|
200 | 202 | for d in sorted(apis): |
|
201 | 203 | print(" * %s" % d) |
|
202 | 204 | |
|
205 | ||
|
203 | 206 | if __name__ == "__main__": |
|
204 | 207 | main() |
@@ -5,6 +5,7 b' import getopt' | |||
|
5 | 5 | import sys |
|
6 | 6 | |
|
7 | 7 | import hgdemandimport |
|
8 | ||
|
8 | 9 | hgdemandimport.enable() |
|
9 | 10 | |
|
10 | 11 | from mercurial.i18n import _ |
@@ -16,44 +17,54 b' from mercurial import (' | |||
|
16 | 17 | simplemerge, |
|
17 | 18 | ui as uimod, |
|
18 | 19 | ) |
|
19 |
from mercurial.utils import |
|
|
20 | procutil, | |
|
21 | stringutil | |
|
22 | ) | |
|
20 | from mercurial.utils import procutil, stringutil | |
|
23 | 21 | |
|
24 | options = [(b'L', b'label', [], _(b'labels to use on conflict markers')), | |
|
25 | (b'a', b'text', None, _(b'treat all files as text')), | |
|
26 | (b'p', b'print', None, | |
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
22 | options = [ | |
|
23 | (b'L', b'label', [], _(b'labels to use on conflict markers')), | |
|
24 | (b'a', b'text', None, _(b'treat all files as text')), | |
|
25 | (b'p', b'print', None, _(b'print results instead of overwriting LOCAL')), | |
|
26 | (b'', b'no-minimal', None, _(b'no effect (DEPRECATED)')), | |
|
27 | (b'h', b'help', None, _(b'display help and exit')), | |
|
28 | (b'q', b'quiet', None, _(b'suppress output')), | |
|
29 | ] | |
|
31 | 30 | |
|
32 | usage = _(b'''simplemerge [OPTS] LOCAL BASE OTHER | |
|
31 | usage = _( | |
|
32 | b'''simplemerge [OPTS] LOCAL BASE OTHER | |
|
33 | 33 | |
|
34 | 34 | Simple three-way file merge utility with a minimal feature set. |
|
35 | 35 | |
|
36 | 36 | Apply to LOCAL the changes necessary to go from BASE to OTHER. |
|
37 | 37 | |
|
38 | 38 | By default, LOCAL is overwritten with the results of this operation. |
|
39 |
''' |
|
|
39 | ''' | |
|
40 | ) | |
|
41 | ||
|
40 | 42 | |
|
41 | 43 | class ParseError(Exception): |
|
42 | 44 | """Exception raised on errors in parsing the command line.""" |
|
43 | 45 | |
|
46 | ||
|
44 | 47 | def showhelp(): |
|
45 | 48 | pycompat.stdout.write(usage) |
|
46 | 49 | pycompat.stdout.write(b'\noptions:\n') |
|
47 | 50 | |
|
48 | 51 | out_opts = [] |
|
49 | 52 | for shortopt, longopt, default, desc in options: |
|
50 | out_opts.append((b'%2s%s' % (shortopt and b'-%s' % shortopt, | |
|
51 | longopt and b' --%s' % longopt), | |
|
52 |
|
|
|
53 | out_opts.append( | |
|
54 | ( | |
|
55 | b'%2s%s' | |
|
56 | % ( | |
|
57 | shortopt and b'-%s' % shortopt, | |
|
58 | longopt and b' --%s' % longopt, | |
|
59 | ), | |
|
60 | b'%s' % desc, | |
|
61 | ) | |
|
62 | ) | |
|
53 | 63 | opts_len = max([len(opt[0]) for opt in out_opts]) |
|
54 | 64 | for first, second in out_opts: |
|
55 | 65 | pycompat.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) |
|
56 | 66 | |
|
67 | ||
|
57 | 68 | try: |
|
58 | 69 | for fp in (sys.stdin, pycompat.stdout, sys.stderr): |
|
59 | 70 | procutil.setbinary(fp) |
@@ -68,13 +79,17 b' try:' | |||
|
68 | 79 | showhelp() |
|
69 | 80 | sys.exit(0) |
|
70 | 81 | if len(args) != 3: |
|
71 |
|
|
|
82 | raise ParseError(_(b'wrong number of arguments').decode('utf8')) | |
|
72 | 83 | local, base, other = args |
|
73 | sys.exit(simplemerge.simplemerge(uimod.ui.load(), | |
|
74 | context.arbitraryfilectx(local), | |
|
75 | context.arbitraryfilectx(base), | |
|
76 |
|
|
|
77 | **pycompat.strkwargs(opts))) | |
|
84 | sys.exit( | |
|
85 | simplemerge.simplemerge( | |
|
86 | uimod.ui.load(), | |
|
87 | context.arbitraryfilectx(local), | |
|
88 | context.arbitraryfilectx(base), | |
|
89 | context.arbitraryfilectx(other), | |
|
90 | **pycompat.strkwargs(opts) | |
|
91 | ) | |
|
92 | ) | |
|
78 | 93 | except ParseError as e: |
|
79 | 94 | e = stringutil.forcebytestr(e) |
|
80 | 95 | pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e)) |
@@ -14,16 +14,15 b' from mercurial import (' | |||
|
14 | 14 | transaction, |
|
15 | 15 | vfs as vfsmod, |
|
16 | 16 | ) |
|
17 |
from mercurial.utils import |
|
|
18 | procutil, | |
|
19 | ) | |
|
17 | from mercurial.utils import procutil | |
|
20 | 18 | |
|
21 | 19 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
22 | 20 | procutil.setbinary(fp) |
|
23 | 21 | |
|
24 | 22 | opener = vfsmod.vfs(b'.', False) |
|
25 | tr = transaction.transaction(sys.stderr.write, opener, {b'store': opener}, | |
|
26 | b"undump.journal") | |
|
23 | tr = transaction.transaction( | |
|
24 | sys.stderr.write, opener, {b'store': opener}, b"undump.journal" | |
|
25 | ) | |
|
27 | 26 | while True: |
|
28 | 27 | l = sys.stdin.readline() |
|
29 | 28 | if not l: |
@@ -42,9 +41,9 b' while True:' | |||
|
42 | 41 | p2 = node.bin(p[1]) |
|
43 | 42 | elif l.startswith("length:"): |
|
44 | 43 | length = int(l[8:-1]) |
|
45 | sys.stdin.readline() # start marker | |
|
44 | sys.stdin.readline() # start marker | |
|
46 | 45 | d = encoding.strtolocal(sys.stdin.read(length)) |
|
47 | sys.stdin.readline() # end marker | |
|
46 | sys.stdin.readline() # end marker | |
|
48 | 47 | r.addrevision(d, tr, lr, p1, p2) |
|
49 | 48 | |
|
50 | 49 | tr.close() |
@@ -15,22 +15,29 b" libdir = '@LIBDIR@'" | |||
|
15 | 15 | |
|
16 | 16 | if libdir != '@' 'LIBDIR' '@': |
|
17 | 17 | if not os.path.isabs(libdir): |
|
18 | libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), | |
|
19 | libdir) | |
|
18 | libdir = os.path.join( | |
|
19 | os.path.dirname(os.path.realpath(__file__)), libdir | |
|
20 | ) | |
|
20 | 21 | libdir = os.path.abspath(libdir) |
|
21 | 22 | sys.path.insert(0, libdir) |
|
22 | 23 | |
|
23 | 24 | from hgdemandimport import tracing |
|
25 | ||
|
24 | 26 | with tracing.log('hg script'): |
|
25 | 27 | # enable importing on demand to reduce startup time |
|
26 | 28 | try: |
|
27 | 29 | if sys.version_info[0] < 3 or sys.version_info >= (3, 6): |
|
28 |
import hgdemandimport |
|
|
30 | import hgdemandimport | |
|
31 | ||
|
32 | hgdemandimport.enable() | |
|
29 | 33 | except ImportError: |
|
30 | sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" % | |
|
31 | ' '.join(sys.path)) | |
|
34 | sys.stderr.write( | |
|
35 | "abort: couldn't find mercurial libraries in [%s]\n" | |
|
36 | % ' '.join(sys.path) | |
|
37 | ) | |
|
32 | 38 | sys.stderr.write("(check your install and PYTHONPATH)\n") |
|
33 | 39 | sys.exit(-1) |
|
34 | 40 | |
|
35 | 41 | from mercurial import dispatch |
|
42 | ||
|
36 | 43 | dispatch.run() |
General Comments 0
You need to be logged in to leave comments.
Login now