black and byteify-strings breaking your patches
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Mon Oct 7 15:23:05 EDT 2019
SPOILER WARNING: do not use the "old" example for fix configuration, it
eats your data. Use the version currently in `hg-committed` (with the
trailing `-` for the command).
On 10/6/19 6:13 PM, Augie Fackler wrote:
> Folks, we just landed my mass-reformatting patches that start unwinding the source mangler in mercurial/__init__.py. As a result, your patches are probably all unable to apply right now. To fix up your code, you'll probably want to do something like this:
>
> 1) rebase your changes to 9cc55b743713 (the last change before the formatting)
> 2) rebase again to 687b865b95ad (the second of the two changes that rewrote everything)
> 3) When you get merge conflicts in (2), resolve them all with your edits, and follow the instructions in 687b865b95ad's commit message on how the change was generated. Look before you leap on accepting edits to make sure things are reasonable.
This solution worked fairly okay, for getting over the black formatting.
I "just" needed to run `hg fix` on full my series after rebasing on
687b865b95ad.
However, getting past 687b865b95ad (byteifying everything) is a larger
issue since `hg fix` and `byteify-strings.py` cannot work together (pipe
input/ouput vs file input/output).
To work around this, I created a temporary draft changeset in my
repository for format-source to deal with the conflict (format-source
has support for file input/output).
You can get this changeset using:
hg pull --rev "FORMAT-WORK-AROUND-DO-NOT-PUBLISH"
https://www.mercurial-scm.org/repo/users/marmoute/blackgnarock/
then run:
hg up "FORMAT-WORK-AROUND-DO-NOT-PUBLISH"
hg rebase --dest "FORMAT-WORK-AROUND-DO-NOT-PUBLISH" --keepbranch
--rev YOURREVS
This will rebase your changes past both the blackgnarock and the
bytemageddon. Once this is done, you can rebase your changes back to the
hg-committed content (to remove the format source thing)
hg rebase --config format-source.run-mode=off --dest 9002f4a3dde6
--keepbranch --rev 'children("FORMAT-WORK-AROUND-DO-NOT-PUBLISH")::'
install format source from PyPI::
pip install --user hg-format-source
You need to have a python install with a development version of black::
virtualenv --python python3 ~/blackgnarock/
~/blackgnarock/bin/pip install git+https://github.com/psf/black/
Then add the following to your repository config::
[extensions]
formatsource=
[format-source]
# run format-source more aggressively, might slow down merges
run-mode=on
# configure the various formatters
byteify = python3 PATH/TO/contrib/byteify-strings.py -i
byteify:mode = file
grey = ~/blackgnarock/bin/python3 PATH/TO/contrib/grey.py --quiet
--skip-string-normalization -
grey:mode = pipe
[fix]
black:command = ~/blackgnarock/bin/python3 PATH/TO/contrib/grey.py
-S --quiet --skip-string-normalization -
black:pattern = set:**.py - hgext/fsmonitor/pywatchman/** -
mercurial/thirdparty/** - "contrib/python-zstandard/** - contrib/grey.py"
Enjoy your formatted source code,
Cheers.
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list