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