black and byteify-strings breaking your patches

Pierre-Yves David pierre-yves.david at
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/ 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 

However, getting past 687b865b95ad (byteifying everything) is a larger 
issue since `hg fix` and `` 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:

then run:
     hg rebase --dest "FORMAT-WORK-AROUND-DO-NOT-PUBLISH" --keepbranch 
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 --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+

Then add the following to your repository config::

     # run format-source more aggressively, might slow down merges
     # configure the various formatters
     byteify = python3 PATH/TO/contrib/ -i
     byteify:mode = file
     grey = ~/blackgnarock/bin/python3 PATH/TO/contrib/ --quiet 
--skip-string-normalization -
     grey:mode = pipe
     black:command = ~/blackgnarock/bin/python3 PATH/TO/contrib/ 
-S --quiet --skip-string-normalization -
     black:pattern = set:**.py - hgext/fsmonitor/pywatchman/** - 
mercurial/thirdparty/** - "contrib/python-zstandard/** - contrib/"

Enjoy your formatted source code,


Pierre-Yves David

More information about the Mercurial-devel mailing list