Commit Graph

974 Commits

Author SHA1 Message Date
Jun Wu
ad0942500c flake8: enable some E checks
Summary: They look useful.

Reviewed By: DurhamG

Differential Revision: D6934534

fbshipit-source-id: 4179a50c073909a8139dfdd91885f729e7d0a4b3
2018-04-13 21:51:09 -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
Jun Wu
0daed9e7f6 flake8: resolve some F checks
Summary:
Solves issues below:
```
hgext/backups.py:18:1: F811 redefinition of unused 'registrar' from line 17
hgext/catnotate.py:1:1: F811 redefinition of unused 'util' from line 1
hgext/remotenames.py:57:5: F811 redefinition of unused 'registrar' from line 34
hgsubversion/setup.py:103:5: F401 'mercurial' imported but unused
hgsubversion/setup.py:109:5: F401 'hgsubversion.svnwrap.svn_swig_wrapper' imported but unused
i18n/polib.py:1281:29: F841 local variable 'exc' is assigned to but never used (Python 2)
i18n/polib.py:1427:13: F841 local variable 'typ' is assigned to but never used
i18n/polib.py:28:1: F401 'sys' imported but unused
mercurial/manifest.py:411:5: F811 redefinition of unused '_lazymanifest' from line 168
mercurial/posix.py:419:5: F811 redefinition of unused 'normcasefallback' from line 362
mercurial/posix.py:425:5: F811 redefinition of unused 'checkexec' from line 167
mercurial/posix.py:431:5: F811 redefinition of unused 'checklink' from line 234
mercurial/pycompat.py:29:5: F401 'http.cookiejar as cookielib' imported but unused
mercurial/pycompat.py:30:5: F401 'http.client as httplib' imported but unused
mercurial/pycompat.py:31:5: F401 'pickle' imported but unused
mercurial/pycompat.py:33:5: F401 'socketserver' imported but unused
mercurial/pycompat.py:34:5: F401 'xmlrpc.client as xmlrpclib' imported but unused
mercurial/statprof.py:573:36: F812 list comprehension redefines 'parent' from line 562 (Python 2)
mercurial/util.py:1076:5: F811 redefinition of unused 'nogc' from line 1051
mercurial/util.py:3221:5: F811 redefinition of unused 'dirs' from line 3184
tests/silenttestrunner.py:24:5: F811 redefinition of unused 'main' from line 6
tests/test-context.py:90:1: F811 redefinition of unused 'scmutil' from line 4
tests/test-fb-hgext-cstore-treemanifest.py:146:5: F811 redefinition of unused 'testDeeplyNested' from line 134
tests/test-fb-hgext-extutil.py:46:5: F811 redefinition of unused 'testbgcommandfailure' from line 37
tests/test_hgsubversion_util.py:47:1: F811 redefinition of unused 'svnwrap' from line 31 (Python 2)
tests/test_hgsubversion_util.py:49:1: F811 redefinition of unused 'svnwrap' from line 47 (Python 2)
```

Reviewed By: ryanmce

Differential Revision: D6934533

fbshipit-source-id: 8b51851a76fec88bb59107ed05a901d42c7326f8
2018-04-13 21:51:09 -07:00
Yuya Nishihara
2c811cd701 log: translate column labels at once (issue5750)
This makes sure that all columns are aligned. getlogcolumns() is hosted by
templatekw so the namespaces module can see it.

i18n/de.po is updated so test-log.t passes with no error. "obsolete:" and
"instability:" are kept untranslated.
2017-12-02 16:29:49 +09:00
Wagner Bruna
9766674d68 i18n-pt_BR: synchronized with f1d5a55d6a57 2017-11-21 13:50:25 -02:00
Augie Fackler
69ce54473a merge with i18n 2017-11-01 16:07:33 -04:00
Wagner Bruna
27cee4a057 i18n-pt_BR: synchronized with cb9be6b29e0b 2017-11-01 08:31:16 -02:00
muxator
aaf12eb558 commands: be more uniform in an "hg update" error message
"can only specify one of -C/--clean, -c/--check, or -m/merge"
becomes
"can only specify one of -C/--clean, -c/--check, or -m/--merge"
2017-10-23 22:45:24 +02:00
Yuya Nishihara
b009eae820 scmutil: extract helper functions that returns human-readable change id
We do "'%d:%s' % (ctx...)" at several places, so let's formalize it. A low-
level function, formatrevnode(ui, rev, node), is extracted so we can pass
a manifest rev/node pair.

Note that hex() for manifest output can be replaced with hexfunc() because
it is printed only when debugflag is set.

i18n/de.po is updated so test-log.t passes with no error.
2017-09-24 12:43:57 +09:00
Kevin Bullock
f0dbcd6ad0 merge with stable 2017-09-18 14:12:20 -05:00
Augie Fackler
5363193f8d merge with i18n 2017-09-18 11:51:41 -04:00
Wagner Bruna
8e84af047a i18n-pt_BR: synchronized with 9a68e2267bd0 2017-07-31 12:18:42 -03:00
FUJIWARA Katsunori
cfbdc0a924 i18n: use actual filename, in which function is defined, for hg.pot
Before this patch, source filename for msgid in hg.pot file becomes
incorrect, if a function is defined in file A, but detected in dict in
file B,

For example, almost all debug* commands are defined in
debugcommands.py, but hggettext detects them in "table" of
commands.py. Therefore, docstring fragments of debug* commands are
marked as "defined in commands.py" in hg.pot file.

This is serious problem for translation, because the cost to find out
original location of texts increases very much.
2017-08-02 00:02:11 +09:00
Augie Fackler
beda3d5545 i18n: update check-translation script to pass import checker 2017-08-22 14:14:52 -04:00
FUJIWARA Katsunori
3880aa6258 i18n: ignore docstring for modules under mercurial
Docstring of modules is needed only for "hg help -e EXTNAME".

This is a preparation for applying hggettext on util.py, which has
module docstring, but it isn't needed for translation.
2017-08-15 21:06:26 +09:00
FUJIWARA Katsunori
cabc81b3e9 i18n: use saved object to get actual function information if available
To list up available compression types instead of
".. bundlecompressionmarker" in "hg help bundlespec" output, proxy
object "docobject" is used, because:

- current online help system requires that __doc__ of registered
  object (maybe, function) is already well formatted in reST syntax

- bundletype() method of compressionengine classes is used to list up
  available compression types, but

- __doc__ of bundletype() object (= "instancemethod") is read-only

On the other hand, hggettext requires original function object, in
order to get document location in source code.

Therefore, description of each compression types isn't yet
translatable. Even if translatable, translators should make much
effort to determine location of original texts in source code.

To get actual function information, this patch makes hggettext use
function object saved as "_origfunc", if it is available. This patch
also changes bundlecompressiontopics() side, in order to explain how
these changes work easily.

This patch is a part of preparations for making description of each
compression types translatable.
2017-08-15 19:27:24 +09:00
FUJIWARA Katsunori
c9b96a17fc i18n: ignore doctest part to avoid warning at "make update-pot"
hggettext assumes that backslashes in docstring are always doubled in
original source code, in order to find the location of original
docstring out certainly.

This assumption almost always works as expected. But doctest easily
breaks it, because many of backslashes in doctests aren't doubled.
This mismatching causes "unknown offset in ..." warning at "make
update-pot".

To avoid such warning, this patch ignores doctest part of docstring
before finding the location of original docstring out.

BTW, at this patch, only person() in templatefilters.py has doctest
part, which causes "unknown offset ..." warning.

Therefore, just making backslashes in that doctest doubled can avoid
such warning, too. But forcing doctest writers to double backslashes
in doctest isn't reasonable, IMHO.
2017-08-13 15:20:16 +09:00
FUJIWARA Katsunori
e62afbdb39 i18n: make hggettext use original docstring to compute offset
Before this patch, hggettext uses __doc__ of each functions to compute
offset of document text.

But __doc__ of many functions is already modified by decorators in
registrar (e.g. @templatekeyword adds ":NAME: " prefix to it), and
hggettext can not find it out in original source.

This causes many "unknown offset in ..." warning at "make update-pot",
and leaving them might cause overlooking serious problems.

This patch makes hggettext use original docstring, which decorators in
registrar save into _origdoc, to compute offset.

Even after this patch, there are still a few "unknown offset in ..."
warning at "make update-pot" for specific reasons. These will be fixed
later one by one.
2017-08-02 01:03:20 +09:00
Augie Fackler
9a0febea27 merge with stable 2017-08-10 14:23:41 -04:00
Augie Fackler
1f0dfd2543 i18n: fix check-translation.py to be less broken on Python 3
These are all simple one-argument print statements, so this syntax
works the same way in 2 and 3.

Differential Revision: https://phab.mercurial-scm.org/D276
2017-06-15 13:31:33 -04:00
Augie Fackler
1248f98f98 merge with stable 2017-07-05 11:55:26 -04:00
Wagner Bruna
4dab97608c i18n-pt_BR: synchronized with bfeb75461255 2017-06-29 12:07:54 -03:00
Wagner Bruna
66a53a8e31 i18n-pt_BR: fix syntax error on translation 2017-06-02 20:50:46 -03:00
Wagner Bruna
2d3ddc9080 i18n-pt_BR: synchronized with 98315436ecec 2017-06-01 20:06:02 -03:00
Wagner Bruna
6d75e48bdf i18n-pt_BR: synchronized with b0ea8556414f 2017-05-31 20:42:58 -03:00
FUJIWARA Katsunori
dc9b825bd4 i18n-ja: synchronized with 878ab1a44c7e 2017-05-01 07:23:29 +09:00
Wagner Bruna
c77d653cee i18n-pt_BR: synchronized with 11b8e606c473 2017-03-02 11:08:20 -03:00
FUJIWARA Katsunori
7f697ba8f8 i18n-ja: synchronized with 11b8e606c473 2017-03-01 16:43:22 +09:00
FUJIWARA Katsunori
4f46584dea i18n: update Report-Msgid-Bugs-To property of *.po files
This patch replaces domain of mercurial-devel ML address by
mercurial-scm.org for "Report-Msgid-Bugs-To" property of each *.po
files.

This avoids releasing 4.1.1 with invalid "Report-Msgid-Bugs-To"
in *.mo file, if corresponded *.po file isn't msgmerge-ed with recent
hg.pot by translator.

These *.po files aren't covered by check-code.py pattern newly added
in subsequent patch, because it ignores them.
2017-02-11 00:23:55 +09:00
Wagner Bruna
7bddc427a8 i18n-pt_BR: synchronized with 9495fca182d9 2017-02-01 08:47:11 -02:00
Matt Harbison
55b2ad69f6 i18n: drop a py25 conditional
I'm not sure how to test this one.  `make update-pot` spews all kinds of
warnings, though it did before this change too.
2017-06-16 20:55:34 -04:00
Augie Fackler
067ebafd12 merge with stable 2017-01-04 14:52:59 -05:00
FUJIWARA Katsunori
09901b0e62 i18n-ja: synchronized with ba32670f6070 2016-12-31 17:19:09 +09:00
Wagner Bruna
8125fda43a i18n-pt_BR: synchronized with bb96c28331a8 2016-11-25 07:39:02 -02:00
Mads Kiilerich
9c5f48e630 shelve: add missing space in help text
The change is trivial and unlikely to have been translated so we update
translation files too.
2016-11-14 22:43:25 +01:00
FUJIWARA Katsunori
01dbfe3b9d i18n-ja: synchronized with 7b9e11755707 2016-11-01 04:27:41 +09:00
Wagner Bruna
9782d338af i18n-pt_BR: synchronized with e12e65f5ea1f 2016-10-22 23:18:43 -02:00
Kevin Bullock
734a4f1625 merge default into stable for 4.0 code freeze 2016-10-18 14:15:15 -05:00
Wagner Bruna
d1300184e4 i18n-pt_BR: synchronized with 6c105ed84c14 2016-10-11 20:39:47 -03:00
Wagner Bruna
511ad6839c i18n-pt_BR: synchronized with 9c29cf2af0ce 2016-08-31 13:58:33 -03:00
FUJIWARA Katsunori
8d71526776 i18n-ja: synchronized with 9b5b7cc2faf0 2016-08-01 08:27:22 +09:00
Wagner Bruna
dc05ec8bba i18n-pt_BR: synchronized with ec63fb038fbc 2016-07-19 19:01:11 -03:00
Pulkit Goyal
aef2bdd39a py3: make files use absolute_import and print_function
This patch includes addition of absolute_import and print_function to the
 files where they are missing. The modern importing conventions are also followed.
2016-07-03 22:28:24 +05:30
Matt Mackall
c0d551e8ec merge with stable 2016-07-01 16:02:56 -05:00
Wagner Bruna
ddd16592d2 i18n-pt_BR: synchronized with fe2fb19f4279 2016-07-01 07:41:37 -03:00
Pierre-Yves David
5bcff70a60 merge with stable 2016-09-14 17:12:39 +02:00
Wagner Bruna
9fe82bf618 i18n-pt_BR: synchronized with 2ae54831e766 2016-05-01 00:12:56 -03:00
Pulkit Goyal
ce56f5973f py3: make i18n/hggettext use print_function 2016-05-13 02:58:15 +05:30
Pulkit Goyal
f24edb8c72 py3: make i18n/hggettext use absolute_import 2016-05-13 02:56:13 +05:30
Pulkit Goyal
6499112aa6 py3: make i18n/posplit use print_function 2016-05-13 03:09:30 +05:30