Commit Graph

562 Commits

Author SHA1 Message Date
Lukasz Langa
408782f48a Update to 18.6b1
Summary:
Better handling of parentheses.

ignore-unit-failures

Reviewed By: carljm

Differential Revision: D8294476

fbshipit-source-id: d0bdfd14d1b39cf19ac8a8a3c6d74c9f4fea8b13
2018-06-05 22:19:55 -07:00
Lukasz Langa
dfda82e492 Upgrade to 18.5b1
Summary: Mostly empty lines removed and added.  A few bugfixes on excessive line splitting.

Reviewed By: quark-zju

Differential Revision: D8199128

fbshipit-source-id: 90c1616061bfd7cfbba0b75f03f89683340374d5
2018-05-30 02:23:58 -07:00
Phil Cohen
4728a64190 gendoc: fix Fedora build from auto-formatting
Summary: The ordering of the imports in this file is significant. Restore it and add `# isort:skip_file`.

Reviewed By: singhsrb

Differential Revision: D8190563

fbshipit-source-id: 5baddb0bd4fadd25772bb390c92f1b705847d352
2018-05-29 13:09:18 -07:00
Jun Wu
584656dff3 codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).

Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.

Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.

An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.

As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.

Reviewed By: wez, phillco, simpkins, pkaush, singhsrb

Differential Revision: D8173629

fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-25 22:17:29 -07:00
Jun Wu
f1c575a099 flake8: enable F821 check
Summary:
This check is useful and detects real errors (ex. fbconduit).  Unfortunately
`arc lint` will run it with both py2 and py3 so a lot of py2 builtins will
still be warned.

I didn't find a clean way to disable py3 check. So this diff tries to fix them.
For `xrange`, the change was done by a script:

```
import sys
import redbaron

headertypes = {'comment', 'endl', 'from_import', 'import', 'string',
               'assignment', 'atomtrailers'}

xrangefix = '''try:
    xrange(0)
except NameError:
    xrange = range

'''

def isxrange(x):
    try:
        return x[0].value == 'xrange'
    except Exception:
        return False

def main(argv):
    for i, path in enumerate(argv):
        print('(%d/%d) scanning %s' % (i + 1, len(argv), path))
        content = open(path).read()
        try:
            red = redbaron.RedBaron(content)
        except Exception:
            print('  warning: failed to parse')
            continue
        hasxrange = red.find('atomtrailersnode', value=isxrange)
        hasxrangefix = 'xrange = range' in content
        if hasxrangefix or not hasxrange:
            print('  no need to change')
            continue

        # find a place to insert the compatibility  statement
        changed = False
        for node in red:
            if node.type in headertypes:
                continue
            # node.insert_before is an easier API, but it has bugs changing
            # other "finally" and "except" positions. So do the insert
            # manually.
            # # node.insert_before(xrangefix)
            line = node.absolute_bounding_box.top_left.line - 1
            lines = content.splitlines(1)
            content = ''.join(lines[:line]) + xrangefix + ''.join(lines[line:])
            changed = True
            break

        if changed:
            # "content" is faster than "red.dumps()"
            open(path, 'w').write(content)
            print('  updated')

if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
```

For other py2 builtins that do not have a py3 equivalent, some `# noqa`
were added as a workaround for now.

Reviewed By: DurhamG

Differential Revision: D6934535

fbshipit-source-id: 546b62830af144bc8b46788d2e0fd00496838939
2018-04-13 21:51:09 -07:00
Mateusz Kwapich
ccdc9763be hgsuversion: move docs and tools
Summary: Moves various tools from hgsubversion/ to contrib/hgsubversion

Test Plan: N/A

Reviewers: quark, #mercurial

Reviewed By: quark

Differential Revision: https://phabricator.intern.facebook.com/D6698604

Signature: 6698604:1515628552:cfae17dcfdbc96d978a6af5c19dfa1032e8aa48c
2018-01-10 16:20:15 -08:00
Kostia Balytskyi
c2556d553e remotenames: drop the dir and do some cleanup
Summary: Depends on D6693417

Test Plan: - run tests

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6693427
2018-01-10 09:01:52 -08:00
Kostia Balytskyi
31b2bc4290 fb-hgext: move docs
Summary: Moving the docs over before dropping the dir.

Test Plan: - nope.

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6693238
2018-01-10 08:44:04 -08:00
Ryan McElroy
66bd74e558 hggit: internalize extension
Test Plan: run-tests-.py

Reviewers: mitrandir, #mercurial

Reviewed By: mitrandir

Subscribers: ps, terrelln

Differential Revision: https://phabricator.intern.facebook.com/D6675896

Tasks: T24908724

Signature: 6675896:1515448382:df8d80cd7356ae8f5fb04586dc4a0a651bc498fd
2018-01-09 06:08:01 -08:00
Ryan McElroy
9cf8ea29dd gendoc: fix doc generation to use extensions from repository
Summary:
Previously, we were loading extensions from the environment which
is not good for actually getting the right docs.

> It is just plain wrong. --ikostia

Test Plan: run-tets.py

Reviewers: ikostia, #mercurial

Reviewed By: ikostia

Differential Revision: https://phabricator.intern.facebook.com/D6682879

Signature: 6682879:1515500917:a0b79bdae32dfa300fcab83488012c77a5145e15
2018-01-09 04:29:10 -08:00
Kostia Balytskyi
0e4d95b67e fb-hgext: fix gendoc-related issues
Summary:
These fixes are related to documentation-related check-style tests.

Depends on D6675344

Test Plan: - more tests pass

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6675351
2018-01-09 03:44:33 -08:00
Jun Wu
9c14bace2f check-seclevel: skip checking extensions that cannot be imported
Summary:
check-seclevel will load disabled extensions including hgsql, which may fail
if its external dependency mysql.connector is not installed. That will break
test-help.t. The error is not fatal so let's just ignore it.

Test Plan:
Run test-help.t on a machine without mysql.connector installed and it now
passes.

Reviewers: durham, #mercurial

Reviewed By: durham

Differential Revision: https://phabricator.intern.facebook.com/D6678500

Signature: 6678500:1515454124:cdd59b644189da86f7d861e80ea3968d6c4b45b1
2018-01-08 14:34:05 -08:00
Mark Thomas
c423f614f2 gendoc: ignore extensions that can't be loaded while generating docs
Summary:
hgsql can't be loaded if you don't have mysql.connector installed on the build
machine.  That shouldn't stop documentation from being generated.

Test Plan:
Make hgsql fail to load on my devserver (add a syntax error) and then build the
documentation.  Make sure it builds anyway.

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6660865

Tasks: T24908724
2018-01-04 09:26:37 -08:00
Mark Thomas
742cd624f7 hgsql: integrate with hg-crew
Summary:
Move hgsql into the hgext directory, and the tests to tests/test-hgsql-*.

Update the tests to refer to the new places for things.

Test Plan: Run the hgsql tests and make sure they pass.

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6660499

Tasks: T24908724
2018-01-04 07:22:19 -08:00
muxator
0c29e9b194 build: make install in "/doc" failed if the destination dir contained spaces
This and the following commits try to add the necessary quoting in the build
scripts to make the process more robust.

The target for now is rendering "make deb" successful even when the base
directory contains spaces (eg. "/opt/mercu rial").
The build process should succeed without scattering files in spurious
directories (eg.: "/opt/mercu/usr/bin/hg").
2017-10-11 01:19:48 +02:00
Augie Fackler
4f9e357bf2 doc: port check-seclevel.py to be Python 2/3 portable 2017-05-28 15:51:26 -04:00
Yuya Nishihara
cf5160a016 gendoc: make sure locale path is set before loading any modules
Otherwise some messages wouldn't be translated depending on when the util
was loaded.
2017-05-13 17:53:55 +09:00
Yuya Nishihara
1d44bd2bbb ui: factor out ui.load() to create a ui without loading configs (API)
This allows us to write doctests depending on a ui object, but not on global
configs.

ui.load() is a class method so we can do wsgiui.load(). All ui() calls but
for doctests are replaced with ui.load(). Some of them could be changed to
not load configs later.
2016-10-22 14:35:10 +09:00
Augie Fackler
8facc4e910 hgmanpage: stop using raw-unicode strings
These don't exist in Python 3, and this ends up looking a little more
explicit to Martijn and me anyway.
2016-10-07 07:43:04 -04:00
Yuya Nishihara
e1051c310e doc: remove double imports of inspect from hgmanpage.py 2016-05-14 14:37:25 +09:00
FUJIWARA Katsunori
f46b49a0e3 check-code: detect "missing _() in ui message" more exactly
Before this patch, "missing _() in ui message" rule overlooks
translatable message, which starts with other than alphabet.

To detect "missing _() in ui message" more exactly, this patch
improves the regexp with assumptions below.

  - sequence consisting of below might precede "translatable message"
    in same string token

    - formatting string, which starts with '%'
    - escaped character, which starts with 'b' (as replacement of '\\'), or
    - characters other than '%', 'b' and 'x' (as replacement of alphabet)

  - any string tokens might precede a string token, which contains
    "translatable message"

This patch builds an input file, which is used to examine "missing _()
in ui message" detection, before '"$check_code" stringjoin.py' in
test-contrib-check-code.t, because this reduces amount of change churn
in subsequent patch.

This patch also applies "()" instead of "_()" on messages below to
hide false-positives:

  - messages for ui.debug() or debug commands/tools
    - contrib/debugshell.py
    - hgext/win32mbcs.py (ui.write() is used, though)
    - mercurial/commands.py
      - _debugchangegroup
      - debugindex
      - debuglocks
      - debugrevlog
      - debugrevspec
      - debugtemplate

  - untranslatable messages
    - doc/gendoc.py (ReST specific text)
    - hgext/hgk.py (permission string)
    - hgext/keyword.py (text written into configuration file)
    - mercurial/cmdutil.py (formatting strings for JSON)
2016-06-21 00:50:39 +09:00
timeless
a1cb3173a2 py3: convert to next() function
next(..) was introduced in py2.6 and .next() is not available in py3

https://docs.python.org/2/library/functions.html#next
2016-05-16 21:30:53 +00:00
Matt Mackall
a24591e84c merge with stable 2016-05-17 11:28:46 -05:00
Sean Farley
dc865d7f73 hg-ssh: copy doc string to man page
This corrects a warning from lintian that we're shipping an executable without
a man page. Since there is a doc string in the text, let's use that for the man
page.
2016-05-06 23:03:41 -07:00
Pulkit Goyal
8ceac3e1b6 py3: make doc/docchecker use print_function 2016-05-13 02:41:35 +05:30
Pulkit Goyal
5e47f5d746 py3: make doc/docchecker use absolute_import 2016-05-13 02:40:39 +05:30
Pulkit Goyal
4970ad7eb8 py3: make raise statement python3 compatible
In python3
	raise error, message
has been changed to
	raise error(message)

In additional to that nodes.SkipNode is changed to nodes.SkipNode() so that
it creates an instance directly.
2016-05-13 03:18:04 +05:30
Pulkit Goyal
16d6b10e69 py3: make hgmanpage use absolute_import 2016-04-17 00:23:05 +05:30
Pulkit Goyal
e736fa4f52 py3: make gendoc use absolute_import
Fixed direct imports even the tests were not complaining.
2016-04-17 00:20:44 +05:30
Pulkit Goyal
f869841929 py3: make check-seclevel use absolute_import
Also fixed direct symbol imports even the tests were not complaining.
2016-04-17 00:14:42 +05:30
timeless
6f6caafe41 docchecker: try to reject single quotes 2016-01-12 09:30:57 +00:00
timeless
052bc178fc docchecker: report context line at most once 2016-03-03 03:32:44 +00:00
FUJIWARA Katsunori
8e59a858bd doc: translate from :hg:help config.SECTION to a valid link to hgrc.5.html
Before this patch, ":hg:`help config.SECTION`" in online help text is
translated to a link to "hg.1.html#config.SECTION" in HTML
unintentionally.

This patch translates from :hg:`help config.SECTION` in online help
text to a valid link to "hgrc.5.html#SECTION" in HTML.

This patch ignores element(s) under "SECTION" (e.g. "ITEM" of
":hg:`help config.SECTION.ITEM`"), because there is no way to refer
directly to it in HTML, yet.
2016-02-11 23:15:34 +09:00
FUJIWARA Katsunori
4436dba238 doc: translate from :hg:help config to a valid link to hgrc.5.html
Before this patch, ":hg:`help config`" in online help text is
translated to a link to "hg.1.html#config" in HTML, even though actual
"hg help config" shows not help for "hg config" command but "config"
help topic, and all of current ":hg:`help config`" expects the latter.

This patch translates from ":hg:`help config`" in online help text to
a link to "hgrc.5.html" in HTML as expected.

This patch also allows ":hg:`help -c COMMAND`" style to link
"hg.1.html#COMMAND" for readability.
2016-02-11 23:15:34 +09:00
FUJIWARA Katsunori
357c04e06b docchecker: use indentation of 4 spaces
This is fixing for 'must indent 4 spaces' check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:29 +09:00
FUJIWARA Katsunori
c26e9ad792 docchecker: remove naked except clause
This is fixing for 'naked except clause' check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:29 +09:00
Bryan O'Sullivan
425505f93a check-seclevel: use a context manager for file I/O 2016-01-12 14:28:16 -08:00
timeless
81962ef57d docchecker: scan for missing space before :hg: 2016-01-06 20:05:18 +00:00
timeless
70bec9473a docchecker: introduce a way to check for poor markup
Specifically, :hg:`foo 'bar baz'` when rendered by `hg help`
results in:

  'hg foo 'bar baz''

... which is hard to read.

We encourage :hg:`foo "bar baz"` instead.
2016-01-06 19:47:14 +00:00
Jun Wu
ea41b32b83 mercurial: pass ui to extensions.load (issue5007)
extensions.load does need ui argument to print error if an extension
fails to load.
2015-12-17 10:30:17 +00:00
Bryan O'Sullivan
d7b0a811b8 check-seclevel: pass a ui to the extension loader
Without this, if an import error occurs (as with pypy), the attempt to
report it fails since ui is None.
2015-12-22 21:38:06 -08:00
Bryan O'Sullivan
b75f25ac1e check-seclevel: add a --debug option
This will make it possible to get semi-meaningful tracebacks if an import
error occurs.

Why care? Trying to run this script under pypy currently fails, but the
true error is obscured.
2015-12-22 21:38:05 -08:00
timeless
b7fa6a1a27 doc: add execute bit and fix shbang line for gendoc.py 2015-12-22 07:59:14 +00:00
Gregory Szorc
b6d0b58fa7 doc: make gendoc.py module import policy aware
Without this, running gendoc.py during an install without C modules
available (via `make local`) will result in an import failure because
the default module load policy insists on C modules.

We also remove the sys.path adjustment because it is no longer needed
since our magic importer handles things.
2015-12-12 13:23:29 -05:00
Gregory Szorc
ec18b44ca2 check-seclevel: set module load policy to Python only
If we don't change this, the upcoming change to make the module
loading policy only load C modules will cause this script to fail if
run with CPython against an unbuilt source checkout.
2015-11-24 22:53:55 -08:00
Mads Kiilerich
09567db49a spelling: trivial spell checking 2015-10-17 00:58:46 +02:00
Matt Mackall
5e1b4ad958 urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
Yuya Nishihara
2f746aa9d3 help: pass around ui to doc loader (API)
This is necessary to hide DEPRECATED items conditionally.

Flagged as API change because it will break "hg help git|subversion".
2015-09-26 12:06:30 +09:00
Yuya Nishihara
958a6389af gendoc: use real ui in place of stdout
ui attributes will be required by a help function, so a file object can't be
used as a fake ui.
2015-09-27 23:34:37 +09:00
Yuya Nishihara
f3df68f405 check-seclevel: use ui to show status and error messages
Future patches will require ui module to be passed to a help function, so
let's use it where appropriate.

Additional parens are necessary to silence a check-code warning.
2015-09-27 22:29:07 +09:00