Gregory Szorc <gregory.szorc@gmail.com> [Sun, 06 Oct 2019 14:58:42 -0400] rev 43087
py3: manually import pycompat.setattr where it is needed
Continuing to eliminate the implicit import of symbols in the
Python 3 source transformer so we can eliminate it.
Differential Revision: https://phab.mercurial-scm.org/D7007
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 06 Oct 2019 14:51:45 -0400] rev 43086
py3: stop implicitly importing unicode
We should be pycompat.unicode everywhere. It turns out we were doing this
everywhere except for one place in templatefilters!
Differential Revision: https://phab.mercurial-scm.org/D7006
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 06 Oct 2019 13:28:56 -0400] rev 43085
py3: manually import pycompat.open into files that need it
We want to eliminate the source transformer. Currently it inserts
a `from mercurial.pycompat import ...` at the top of files to alias
some builtins.
This commit replaces the implicit import of `open` with an explicit
import on files that need it and changes the source transformer to
no longer import `open`.
As part of this, we needed to store an explicit local for `open` in
the Python 2 code path in `pycompat` so the import works. (Builtins
that are automatically in scope cannot be imported.)
Differential Revision: https://phab.mercurial-scm.org/D7005
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 06 Oct 2019 13:17:19 -0400] rev 43084
import-checker: allow symbol imports from mercurial.pycompat
Currently, the source transformer inserts
`from mercurial.pycompat import delattr, getattr, hasattr, setattr, open, unicode`
to the top of every file. As part of getting rid of the source transformer,
we'll need to have source code call these wrappers directly. Rather than
rewrite all call sites to call pycompat.*, I think it makes sense to import
needed symbols via explicit imports. That requires loosening the import checker
to allow this.
Differential Revision: https://phab.mercurial-scm.org/D7004
Augie Fackler <augie@google.com> [Sun, 06 Oct 2019 14:13:03 -0700] rev 43083
contrib: add a fork of black (as "grey") that includes my changes
This is black with https://github.com/psf/black/pull/826 applied as of
today. The current git hash of black master is
d9e71a75ccfefa3d9156a64c03313a0d4ad981e5, and the hash of my commit is
dc1add6e94e212eff37bb3619e1422fb3c6d8dc8. In order to use this, you
need to install `black` (from github master) and `typed-ast` using
pip, preferably into python3, and then you can run `grey.py` with that
Python and you'll have my patched version of black, which is how we've
been formatting the codebase.
Once my PR is merged, I'll follow up by removing this fork and
updating instructions in the example config.
# no-check-commit bad style
Differential Revision: https://phab.mercurial-scm.org/D7002
Yuya Nishihara <yuya@tcha.org> [Sat, 05 Oct 2019 09:58:21 -0400] rev 43082
rust-cpython: change license of ref_sharing.rs to MIT
Since we plan to upstream this feature, it's better to continue further
refactoring under the same license as rust-cpython crate.
According to the file history, copyright holders are:
- Raphaël Gomès <rgomes@octobus.net>
- Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
- Yuya Nishihara <yuya@tcha.org>
Augie Fackler <augie@google.com> [Sun, 06 Oct 2019 10:20:17 -0400] rev 43081
contrib: fix check-code to be able to detect missing _() with bytestrings
Differential Revision: https://phab.mercurial-scm.org/D6997
Augie Fackler <augie@google.com> [Sun, 06 Oct 2019 10:51:16 -0400] rev 43080
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
These used to be marked with no-op parens, but black removes those now
and this is more explicit.
# skip-blame: fallout from mass reformatting
Differential Revision: https://phab.mercurial-scm.org/D6996
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 06 Oct 2019 10:10:14 -0400] rev 43079
ui: define (write|status|warn|note)noi18n aliases
We currently use `write(('...'))` to suppress check-code warnings
about not using translated strings. However, when we run black, it
will strip the `((...))`. In order to placate black, we'll need to use
a different mechanism to pass untranslatable strings. This commit
introduces a `writenoi18n` alias (and friends) to `write` for that
purpose.
Differential Revision: https://phab.mercurial-scm.org/D6994
Augie Fackler <augie@google.com> [Sat, 04 May 2019 11:25:40 -0400] rev 43078
mangler: stop rewriting string constants to be bytes literals
We've rewritten everything, so we no longer require this step.
Differential Revision: https://phab.mercurial-scm.org/D6973
Augie Fackler <augie@google.com> [Sun, 06 Oct 2019 09:48:39 -0400] rev 43077
formatting: byteify all mercurial/ and hgext/ string literals
Done with
python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py')
black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**')
# skip-blame mass-reformatting only
Differential Revision: https://phab.mercurial-scm.org/D6972
Augie Fackler <augie@google.com> [Sun, 06 Oct 2019 09:45:02 -0400] rev 43076
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
Augie Fackler <augie@google.com> [Sat, 05 Oct 2019 10:29:34 -0400] rev 43075
style: run a patched black on a subset of mercurial
This applied black to the 20 smallest files in mercurial/:
ls -S1 mercurial/*.py | tail -n20 | xargs black --skip-string-normalization
Note that a few files failed to format, presumably due to a bug in my
patch. The intent is to be able to compare results to D5064 with
https://github.com/python/black/pull/826 applied to black.
I skipped string normalization on this patch for clarity - in reality
I think we'd want one pass without string normalization, followed by
another to normalize strings (which is basically replacing ' with "
globally.)
# skip-blame mass-reformatting only
Differential Revision: https://phab.mercurial-scm.org/D6342
Gregory Szorc <gregory.szorc@gmail.com> [Fri, 04 Oct 2019 15:53:45 -0400] rev 43074
tests: conditionalize output for Python 3
It appears that the random.randint() behavior is different between Python 2
and Python 3. So make the test conditional on that.
This makes the test pass on Python 3.7 (and presumably other Python 3 versions).
Differential Revision: https://phab.mercurial-scm.org/D6964
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 05 Oct 2019 17:01:02 -0400] rev 43073
hg: remove HGUNICODEPEDANTRY and RTUNICODEPEDANTRY
This was added in
73e4a02e6d23 and
89822d7a9d5f as a preliminary
way to better support Python 3. With the Python 3 port nearly done
and better procedures in place, we shouldn't need it.
Differential Revision: https://phab.mercurial-scm.org/D6991
Gregory Szorc <gregory.szorc@gmail.com> [Fri, 04 Oct 2019 16:07:32 -0400] rev 43072
convert: use pycompat.fsencode()
This avoids a
`TypeError: Can't mix strings and bytes in path components`.
Differential Revision: https://phab.mercurial-scm.org/D6965
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 05 Oct 2019 15:28:52 -0400] rev 43071
tests: make tarball output conditional on Python version
Python 3.8 changed the default tar file archive format:
https://docs.python.org/3.8/whatsnew/3.8.html#tarfile.
This commit teaches our tests about the new behavior.
Differential Revision: https://phab.mercurial-scm.org/D6986
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 05 Oct 2019 16:23:00 -0400] rev 43070
tests: conditionalize test-run-tests.t for Python 3.8
It looks like Python 3.8 changed the pretty XML formatting slightly
to strip some whitespace. Let's teach our tests about that.
Differential Revision: https://phab.mercurial-scm.org/D6988
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 05 Oct 2019 17:44:54 -0400] rev 43069
hgweb: use importlib.reload() if available
reload() was nuked in Python 3. We need to use importlib.reload()
instead.
But pyflakes isn't smart enough to detect our conditional usage, so
we allow this error.
Differential Revision: https://phab.mercurial-scm.org/D6992
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 05 Oct 2019 16:57:45 -0400] rev 43068
tests: allow xrange warning from perf.py
The use of xrange in this file is acceptable.
We need to make the output optional - and not conditional on
the Python version - because `pyflakes` could be executed by any
Python version and pyflakes behaves differently depending on the
Python version.
Differential Revision: https://phab.mercurial-scm.org/D6990
Pierre-Yves David <pierre-yves.david@octobus.net> [Sun, 06 Oct 2019 09:27:10 -0400] rev 43067
debugsidedata: fix verbose mode on python3
We need to be gently with python3 for it to display this binary data.
Differential Revision: https://phab.mercurial-scm.org/D6995
Denis Laxalde <denis@laxalde.org> [Sun, 06 Oct 2019 12:59:47 +0200] rev 43066
import: add debug messages when parsing data from patch header
Augie Fackler <augie@google.com> [Sun, 06 Oct 2019 06:55:49 -0700] rev 43065
examples: include a sample of how to use black with fix
It's commented out for now since my patch hasn't landed, but we can
uncomment it when that lands.
Differential Revision: https://phab.mercurial-scm.org/D6974
Augie Fackler <augie@google.com> [Sun, 06 Oct 2019 09:35:14 -0400] rev 43064
black: add a pyproject.toml that contains our black settings
Differential Revision: https://phab.mercurial-scm.org/D6993
Augie Fackler <augie@google.com> [Sat, 05 Oct 2019 10:49:24 -0400] rev 43063
contrib: stop whining about whitespace around =
This was conflicting with black, so dump it.
Differential Revision: https://phab.mercurial-scm.org/D6979
Augie Fackler <augie@google.com> [Sat, 05 Oct 2019 10:48:10 -0400] rev 43062
contrib: black manages whitespace after Python keywords now
Differential Revision: https://phab.mercurial-scm.org/D6978
Augie Fackler <augie@google.com> [Sat, 05 Oct 2019 10:47:28 -0400] rev 43061
contrib: allow trailing commas in lists
black manages this for us, so we don't need to worry about this anymore.
Differential Revision: https://phab.mercurial-scm.org/D6977
Augie Fackler <augie@google.com> [Sat, 05 Oct 2019 10:46:46 -0400] rev 43060
contrib: remove check-code line length limit
Both Python and C code are managed by formatters now, so relax this.
Differential Revision: https://phab.mercurial-scm.org/D6976
Pierre-Yves David <pierre-yves.david@octobus.net> [Mon, 30 Sep 2019 14:21:05 -0400] rev 43059
changegroup: use positive logic for treemanifest changegroup3 logic
We are about to add more cases, in that context, it is simpler to avoid double
negative.
En addition, We document the situation for the next soul.
Differential Revision: https://phab.mercurial-scm.org/D6938
Danny Hooper <hooper@google.com> [Sat, 05 Oct 2019 07:10:34 -0700] rev 43058
fix: add :enabled sub-config for fixer tools
This allows distributing opt-in fixer tool configurations in .hgrc
files. This may be useful for adding default configs in core, or for
orgranizations that want to provide configs to their users.
Tools are still enabled by default because it would be confusing to add a
config and find that it has no effect until you add enabled=true.
Differential Revision: https://phab.mercurial-scm.org/D6975