Mercurial > hg
annotate doc/docchecker @ 42054:399ed3e86a49
py2exe: add workaround to allow bundling of hgext3rd.* extensions
py2exe doesn't know how to handle namespace packages *at all*, so it treats
them like normal packages. As a result, if we try and bundle hgext3rd.evolve
in a py2exe build, it won't work if we install evolve into the virtualenv. In
order to work around this, tortoisehg installs hgext3rd.evolve etc into its
staged hg directory, since it doesn't use a virtualenv. As a workaround for us,
we'll just allow any extra packages users want bundled are part of hg during
the pseudo-install phase that py2exe uses. I'm not happy about this, but it
*works*.
As a sample of how you'd make an MSI with evolve bundled:
import os
import shutil
import subprocess
import tempfile
def stage_evolve(version):
"""Stage evolve for inclusion in py2exe binary."""
with tempfile.TemporaryDirectory() as temp:
evolve = os.path.join(temp, "evolve")
subprocess.check_call([
"hg.exe",
"clone",
"https://www.mercurial-scm.org/repo/evolve/",
"--update",
version,
evolve,
])
dest = os.path.join('..', 'hgext3rd', 'evolve')
if os.path.exists(dest):
shutil.rmtree(dest)
shutil.copytree(os.path.join(evolve, "hgext3rd", "evolve"), dest)
def main():
stage_evolve('tip')
print("\0")
print("hgext3rd")
print("hgext3rd.evolve")
print("hgext3rd.evolve.hack")
print("hgext3rd.evolve.thirdparty")
if __name__ == "__main__":
main()
is a script you can pass to the wix/build.py as --extra-packages-script,
and the resulting .msi will have an hg binary with evolve baked in. users
will still need to enable evolve in their hgrc, so you'd probably also
want to bundle configs in your msi for an enterprise environment, but that's
already easy to do with the support for extra features and wxs files in the
wix build process.
Differential Revision: https://phab.mercurial-scm.org/D6189
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 03 Apr 2019 11:46:29 -0400 |
parents | 9bfbb9fc5871 |
children | 47ef023d0165 |
rev | line source |
---|---|
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
2 # |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
3 # docchecker - look for problematic markup |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
4 # |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
5 # Copyright 2016 timeless <timeless@mozdev.org> and others |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
6 # |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
8 # GNU General Public License version 2 or any later version. |
29168
8f2805ce93d9
py3: make doc/docchecker use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28811
diff
changeset
|
9 |
29169
c9ab5a0bc7c5
py3: make doc/docchecker use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29168
diff
changeset
|
10 from __future__ import absolute_import, print_function |
29168
8f2805ce93d9
py3: make doc/docchecker use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28811
diff
changeset
|
11 |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
12 import os |
29168
8f2805ce93d9
py3: make doc/docchecker use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28811
diff
changeset
|
13 import re |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
14 import sys |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
15 |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
16 try: |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
17 import msvcrt |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
18 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
19 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
20 except ImportError: |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
21 pass |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
22 |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
23 stdout = getattr(sys.stdout, 'buffer', sys.stdout) |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
24 |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
25 leadingline = re.compile(br'(^\s*)(\S.*)$') |
28810
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
26 |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
27 checks = [ |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
28 (br""":hg:`[^`]*'[^`]*`""", |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
29 b"""warning: please avoid nesting ' in :hg:`...`"""), |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
30 (br'\w:hg:`', |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
31 b'warning: please have a space before :hg:'), |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
32 (br"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""", |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
33 b'''warning: please use " instead of ' for hg ... "..."'''), |
28810
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
34 ] |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
35 |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
36 def check(line): |
28810
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
37 messages = [] |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
38 for match, msg in checks: |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
39 if re.search(match, line): |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
40 messages.append(msg) |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
41 if messages: |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
42 stdout.write(b'%s\n' % line) |
28810
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
43 for msg in messages: |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
44 stdout.write(b'%s\n' % msg) |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
45 |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
46 def work(file): |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
47 (llead, lline) = (b'', b'') |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
48 |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
49 for line in file: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
50 # this section unwraps lines |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
51 match = leadingline.match(line) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
52 if not match: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
53 check(lline) |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
54 (llead, lline) = (b'', b'') |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
55 continue |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
56 |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
57 lead, line = match.group(1), match.group(2) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
58 if (lead == llead): |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
59 if (lline != b''): |
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
60 lline += b' ' + line |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
61 else: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
62 lline = line |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
63 else: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
64 check(lline) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
65 (llead, lline) = (lead, line) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
66 check(lline) |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
67 |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
68 def main(): |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
69 for f in sys.argv[1:]: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
70 try: |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
71 with open(f, 'rb') as file: |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
72 work(file) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
73 except BaseException as e: |
41006
9bfbb9fc5871
py3: byteify docchecker
Matt Harbison <matt_harbison@yahoo.com>
parents:
29169
diff
changeset
|
74 sys.stdout.write(r"failed to process %s: %s\n" % (f, e)) |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
75 |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
76 main() |