Patchwork D7065: examples: allow the fix configuration to work from any directory

login
register
mail settings
Submitter phabricator
Date Oct. 12, 2019, 4:55 a.m.
Message ID <differential-rev-PHID-DREV-axjcc47qgi777x5oyn6g-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42255/
State Superseded
Headers show

Comments

phabricator - Oct. 12, 2019, 4:55 a.m.
mharbison72 created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Generally my shell is in the tests directory, and there was no sign that `fix`
  wasn't doing anything, even with `--debug` and without `--quiet` on the grey
  invocation.  (Maybe it would be useful to state when no files were processed?)
  I only tested the `black` config, but the others are similar enough.
  
  The need for a different command based on the platform is a bit unfortunate.  I
  wonder if it's worth a `{python}` keyword for portability, since the python
  binary isn't in PATH by default on Windows (IIRC), and doesn't have the version
  number in any case.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7065

AFFECTED FILES
  contrib/clang-format-ignorelist
  contrib/examples/fix.hgrc

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mjpieters, mercurial-devel
phabricator - Oct. 12, 2019, 5:12 p.m.
martinvonz added a comment.


  It's unfortunate that this is necessary. I'll see if I can fix fix.py to always interpret patterns relative to the repo root.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7065/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7065

To: mharbison72, #hg-reviewers
Cc: martinvonz, mjpieters, mercurial-devel
phabricator - Oct. 12, 2019, 5:41 p.m.
mharbison72 added a comment.


  In D7065#103834 <https://phab.mercurial-scm.org/D7065#103834>, @martinvonz wrote:
  
  > It's unfortunate that this is necessary. I'll see if I can fix fix.py to always interpret patterns relative to the repo root.
  
  I think that's the most intuitive way to consume these patterns.  But won't that muddy the water with the documentation saying, for example, that `glob:` is relative to cwd?  Also, there's relative patterns in the file pattern to consider.  (I'm not against your proposal at all; I'm just wondering aloud because I always get tripped up by the slightly modified ignore rules.)
  
  I found `debugwalk` to be useful in figuring this out.  I wonder if it's worth a mention in `hg help patterns`.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7065/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7065

To: mharbison72, #hg-reviewers
Cc: martinvonz, mjpieters, mercurial-devel
phabricator - Oct. 14, 2019, 11:03 p.m.
martinvonz added a comment.
martinvonz added a subscriber: hooper.


  In D7065#103835 <https://phab.mercurial-scm.org/D7065#103835>, @mharbison72 wrote:
  
  > In D7065#103834 <https://phab.mercurial-scm.org/D7065#103834>, @martinvonz wrote:
  >
  >> It's unfortunate that this is necessary. I'll see if I can fix fix.py to always interpret patterns relative to the repo root.
  >
  > I think that's the most intuitive way to consume these patterns.  But won't that muddy the water with the documentation saying, for example, that `glob:` is relative to cwd?  Also, there's relative patterns in the file pattern to consider.  (I'm not against your proposal at all; I'm just wondering aloud because I always get tripped up by the slightly modified ignore rules.)
  
  I talked to @hooper about this and they agreed that using repo-relative paths is almost always what the user wants. I've sent D7101 <https://phab.mercurial-scm.org/D7101> for that.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7065/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7065

To: mharbison72, #hg-reviewers
Cc: hooper, martinvonz, mjpieters, mercurial-devel
phabricator - Oct. 15, 2019, 1:19 a.m.
mharbison72 added a comment.
mharbison72 abandoned this revision.


  In D7065#104119 <https://phab.mercurial-scm.org/D7065#104119>, @martinvonz wrote:
  
  > I talked to @hooper about this and they agreed that using repo-relative paths is almost always what the user wants. I've sent D7101 <https://phab.mercurial-scm.org/D7101> for that.
  
  Sounds good to me.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7065/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7065

To: mharbison72, #hg-reviewers
Cc: hooper, martinvonz, mjpieters, mercurial-devel

Patch

diff --git a/contrib/examples/fix.hgrc b/contrib/examples/fix.hgrc
--- a/contrib/examples/fix.hgrc
+++ b/contrib/examples/fix.hgrc
@@ -1,9 +1,9 @@ 
 [fix]
 clang-format:command = clang-format --style file -i
-clang-format:pattern = (**.c or **.cc or **.h) and not "listfile:contrib/clang-format-ignorelist"
+clang-format:pattern = (rootglob:**.c or rootglob:**.cc or rootglob:**.h) and not "listfile:contrib/clang-format-ignorelist"
 
 rustfmt:command = rustfmt {rootpath}
-rustfmt:pattern = set:**.rs
+rustfmt:pattern = rootglob:**.rs
 
 # We use black, but currently with
 # https://github.com/psf/black/pull/826 applied. For now
@@ -11,5 +11,7 @@ 
 # git+https://github.com/python/black/@d9e71a75ccfefa3d9156a64c03313a0d4ad981e5
 # to have the dependencies for grey.
 #
+# Note: For Windows, use `py -3` instead of `python3.7`
+#
 # black:command = python3.7 contrib/grey.py --quiet --skip-string-normalization -
-# black:pattern = set:**.py - hgext/fsmonitor/pywatchman/** - mercurial/thirdparty/** - "contrib/python-zstandard/**"
+# black:pattern = set:rootglob:**.py - rootglob:hgext/fsmonitor/pywatchman/** - rootglob:mercurial/thirdparty/** - rootglob:contrib/python-zstandard/**
diff --git a/contrib/clang-format-ignorelist b/contrib/clang-format-ignorelist
--- a/contrib/clang-format-ignorelist
+++ b/contrib/clang-format-ignorelist
@@ -1,103 +1,103 @@ 
 # Files that just need to be migrated to the formatter.
 # Do not add new files here!
-mercurial/cext/dirs.c
-mercurial/cext/manifest.c
-mercurial/cext/osutil.c
+path:mercurial/cext/dirs.c
+path:mercurial/cext/manifest.c
+path:mercurial/cext/osutil.c
 # Vendored code that we should never format:
-contrib/python-zstandard/c-ext/bufferutil.c
-contrib/python-zstandard/c-ext/compressionchunker.c
-contrib/python-zstandard/c-ext/compressiondict.c
-contrib/python-zstandard/c-ext/compressionparams.c
-contrib/python-zstandard/c-ext/compressionreader.c
-contrib/python-zstandard/c-ext/compressionwriter.c
-contrib/python-zstandard/c-ext/compressobj.c
-contrib/python-zstandard/c-ext/compressor.c
-contrib/python-zstandard/c-ext/compressoriterator.c
-contrib/python-zstandard/c-ext/constants.c
-contrib/python-zstandard/c-ext/decompressionreader.c
-contrib/python-zstandard/c-ext/decompressionwriter.c
-contrib/python-zstandard/c-ext/decompressobj.c
-contrib/python-zstandard/c-ext/decompressor.c
-contrib/python-zstandard/c-ext/decompressoriterator.c
-contrib/python-zstandard/c-ext/frameparams.c
-contrib/python-zstandard/c-ext/python-zstandard.h
-contrib/python-zstandard/zstd.c
-contrib/python-zstandard/zstd/common/bitstream.h
-contrib/python-zstandard/zstd/common/compiler.h
-contrib/python-zstandard/zstd/common/cpu.h
-contrib/python-zstandard/zstd/common/debug.c
-contrib/python-zstandard/zstd/common/debug.h
-contrib/python-zstandard/zstd/common/entropy_common.c
-contrib/python-zstandard/zstd/common/error_private.c
-contrib/python-zstandard/zstd/common/error_private.h
-contrib/python-zstandard/zstd/common/fse_decompress.c
-contrib/python-zstandard/zstd/common/fse.h
-contrib/python-zstandard/zstd/common/huf.h
-contrib/python-zstandard/zstd/common/mem.h
-contrib/python-zstandard/zstd/common/pool.c
-contrib/python-zstandard/zstd/common/pool.h
-contrib/python-zstandard/zstd/common/threading.c
-contrib/python-zstandard/zstd/common/threading.h
-contrib/python-zstandard/zstd/common/xxhash.c
-contrib/python-zstandard/zstd/common/xxhash.h
-contrib/python-zstandard/zstd/common/zstd_common.c
-contrib/python-zstandard/zstd/common/zstd_errors.h
-contrib/python-zstandard/zstd/common/zstd_internal.h
-contrib/python-zstandard/zstd/compress/fse_compress.c
-contrib/python-zstandard/zstd/compress/hist.c
-contrib/python-zstandard/zstd/compress/hist.h
-contrib/python-zstandard/zstd/compress/huf_compress.c
-contrib/python-zstandard/zstd/compress/zstd_compress.c
-contrib/python-zstandard/zstd/compress/zstd_compress_internal.h
-contrib/python-zstandard/zstd/compress/zstd_compress_literals.c
-contrib/python-zstandard/zstd/compress/zstd_compress_literals.h
-contrib/python-zstandard/zstd/compress/zstd_compress_sequences.c
-contrib/python-zstandard/zstd/compress/zstd_compress_sequences.h
-contrib/python-zstandard/zstd/compress/zstd_double_fast.c
-contrib/python-zstandard/zstd/compress/zstd_double_fast.h
-contrib/python-zstandard/zstd/compress/zstd_fast.c
-contrib/python-zstandard/zstd/compress/zstd_fast.h
-contrib/python-zstandard/zstd/compress/zstd_lazy.c
-contrib/python-zstandard/zstd/compress/zstd_lazy.h
-contrib/python-zstandard/zstd/compress/zstd_ldm.c
-contrib/python-zstandard/zstd/compress/zstd_ldm.h
-contrib/python-zstandard/zstd/compress/zstdmt_compress.c
-contrib/python-zstandard/zstd/compress/zstdmt_compress.h
-contrib/python-zstandard/zstd/compress/zstd_opt.c
-contrib/python-zstandard/zstd/compress/zstd_opt.h
-contrib/python-zstandard/zstd/decompress/huf_decompress.c
-contrib/python-zstandard/zstd/decompress/zstd_ddict.c
-contrib/python-zstandard/zstd/decompress/zstd_ddict.h
-contrib/python-zstandard/zstd/decompress/zstd_decompress_block.c
-contrib/python-zstandard/zstd/decompress/zstd_decompress_block.h
-contrib/python-zstandard/zstd/decompress/zstd_decompress_internal.h
-contrib/python-zstandard/zstd/decompress/zstd_decompress.c
-contrib/python-zstandard/zstd/deprecated/zbuff_common.c
-contrib/python-zstandard/zstd/deprecated/zbuff_compress.c
-contrib/python-zstandard/zstd/deprecated/zbuff_decompress.c
-contrib/python-zstandard/zstd/deprecated/zbuff.h
-contrib/python-zstandard/zstd/dictBuilder/cover.c
-contrib/python-zstandard/zstd/dictBuilder/cover.h
-contrib/python-zstandard/zstd/dictBuilder/divsufsort.c
-contrib/python-zstandard/zstd/dictBuilder/divsufsort.h
-contrib/python-zstandard/zstd/dictBuilder/fastcover.c
-contrib/python-zstandard/zstd/dictBuilder/zdict.c
-contrib/python-zstandard/zstd/dictBuilder/zdict.h
-contrib/python-zstandard/zstd/zstd.h
-hgext/fsmonitor/pywatchman/bser.c
-mercurial/thirdparty/xdiff/xdiff.h
-mercurial/thirdparty/xdiff/xdiffi.c
-mercurial/thirdparty/xdiff/xdiffi.h
-mercurial/thirdparty/xdiff/xemit.c
-mercurial/thirdparty/xdiff/xemit.h
-mercurial/thirdparty/xdiff/xhistogram.c
-mercurial/thirdparty/xdiff/xinclude.h
-mercurial/thirdparty/xdiff/xmacros.h
-mercurial/thirdparty/xdiff/xmerge.c
-mercurial/thirdparty/xdiff/xpatience.c
-mercurial/thirdparty/xdiff/xprepare.c
-mercurial/thirdparty/xdiff/xprepare.h
-mercurial/thirdparty/xdiff/xtypes.h
-mercurial/thirdparty/xdiff/xutils.c
-mercurial/thirdparty/xdiff/xutils.h
-mercurial/thirdparty/zope/interface/_zope_interface_coptimizations.c
+path:contrib/python-zstandard/c-ext/bufferutil.c
+path:contrib/python-zstandard/c-ext/compressionchunker.c
+path:contrib/python-zstandard/c-ext/compressiondict.c
+path:contrib/python-zstandard/c-ext/compressionparams.c
+path:contrib/python-zstandard/c-ext/compressionreader.c
+path:contrib/python-zstandard/c-ext/compressionwriter.c
+path:contrib/python-zstandard/c-ext/compressobj.c
+path:contrib/python-zstandard/c-ext/compressor.c
+path:contrib/python-zstandard/c-ext/compressoriterator.c
+path:contrib/python-zstandard/c-ext/constants.c
+path:contrib/python-zstandard/c-ext/decompressionreader.c
+path:contrib/python-zstandard/c-ext/decompressionwriter.c
+path:contrib/python-zstandard/c-ext/decompressobj.c
+path:contrib/python-zstandard/c-ext/decompressor.c
+path:contrib/python-zstandard/c-ext/decompressoriterator.c
+path:contrib/python-zstandard/c-ext/frameparams.c
+path:contrib/python-zstandard/c-ext/python-zstandard.h
+path:contrib/python-zstandard/zstd.c
+path:contrib/python-zstandard/zstd/common/bitstream.h
+path:contrib/python-zstandard/zstd/common/compiler.h
+path:contrib/python-zstandard/zstd/common/cpu.h
+path:contrib/python-zstandard/zstd/common/debug.c
+path:contrib/python-zstandard/zstd/common/debug.h
+path:contrib/python-zstandard/zstd/common/entropy_common.c
+path:contrib/python-zstandard/zstd/common/error_private.c
+path:contrib/python-zstandard/zstd/common/error_private.h
+path:contrib/python-zstandard/zstd/common/fse_decompress.c
+path:contrib/python-zstandard/zstd/common/fse.h
+path:contrib/python-zstandard/zstd/common/huf.h
+path:contrib/python-zstandard/zstd/common/mem.h
+path:contrib/python-zstandard/zstd/common/pool.c
+path:contrib/python-zstandard/zstd/common/pool.h
+path:contrib/python-zstandard/zstd/common/threading.c
+path:contrib/python-zstandard/zstd/common/threading.h
+path:contrib/python-zstandard/zstd/common/xxhash.c
+path:contrib/python-zstandard/zstd/common/xxhash.h
+path:contrib/python-zstandard/zstd/common/zstd_common.c
+path:contrib/python-zstandard/zstd/common/zstd_errors.h
+path:contrib/python-zstandard/zstd/common/zstd_internal.h
+path:contrib/python-zstandard/zstd/compress/fse_compress.c
+path:contrib/python-zstandard/zstd/compress/hist.c
+path:contrib/python-zstandard/zstd/compress/hist.h
+path:contrib/python-zstandard/zstd/compress/huf_compress.c
+path:contrib/python-zstandard/zstd/compress/zstd_compress.c
+path:contrib/python-zstandard/zstd/compress/zstd_compress_internal.h
+path:contrib/python-zstandard/zstd/compress/zstd_compress_literals.c
+path:contrib/python-zstandard/zstd/compress/zstd_compress_literals.h
+path:contrib/python-zstandard/zstd/compress/zstd_compress_sequences.c
+path:contrib/python-zstandard/zstd/compress/zstd_compress_sequences.h
+path:contrib/python-zstandard/zstd/compress/zstd_double_fast.c
+path:contrib/python-zstandard/zstd/compress/zstd_double_fast.h
+path:contrib/python-zstandard/zstd/compress/zstd_fast.c
+path:contrib/python-zstandard/zstd/compress/zstd_fast.h
+path:contrib/python-zstandard/zstd/compress/zstd_lazy.c
+path:contrib/python-zstandard/zstd/compress/zstd_lazy.h
+path:contrib/python-zstandard/zstd/compress/zstd_ldm.c
+path:contrib/python-zstandard/zstd/compress/zstd_ldm.h
+path:contrib/python-zstandard/zstd/compress/zstdmt_compress.c
+path:contrib/python-zstandard/zstd/compress/zstdmt_compress.h
+path:contrib/python-zstandard/zstd/compress/zstd_opt.c
+path:contrib/python-zstandard/zstd/compress/zstd_opt.h
+path:contrib/python-zstandard/zstd/decompress/huf_decompress.c
+path:contrib/python-zstandard/zstd/decompress/zstd_ddict.c
+path:contrib/python-zstandard/zstd/decompress/zstd_ddict.h
+path:contrib/python-zstandard/zstd/decompress/zstd_decompress_block.c
+path:contrib/python-zstandard/zstd/decompress/zstd_decompress_block.h
+path:contrib/python-zstandard/zstd/decompress/zstd_decompress_internal.h
+path:contrib/python-zstandard/zstd/decompress/zstd_decompress.c
+path:contrib/python-zstandard/zstd/deprecated/zbuff_common.c
+path:contrib/python-zstandard/zstd/deprecated/zbuff_compress.c
+path:contrib/python-zstandard/zstd/deprecated/zbuff_decompress.c
+path:contrib/python-zstandard/zstd/deprecated/zbuff.h
+path:contrib/python-zstandard/zstd/dictBuilder/cover.c
+path:contrib/python-zstandard/zstd/dictBuilder/cover.h
+path:contrib/python-zstandard/zstd/dictBuilder/divsufsort.c
+path:contrib/python-zstandard/zstd/dictBuilder/divsufsort.h
+path:contrib/python-zstandard/zstd/dictBuilder/fastcover.c
+path:contrib/python-zstandard/zstd/dictBuilder/zdict.c
+path:contrib/python-zstandard/zstd/dictBuilder/zdict.h
+path:contrib/python-zstandard/zstd/zstd.h
+path:hgext/fsmonitor/pywatchman/bser.c
+path:mercurial/thirdparty/xdiff/xdiff.h
+path:mercurial/thirdparty/xdiff/xdiffi.c
+path:mercurial/thirdparty/xdiff/xdiffi.h
+path:mercurial/thirdparty/xdiff/xemit.c
+path:mercurial/thirdparty/xdiff/xemit.h
+path:mercurial/thirdparty/xdiff/xhistogram.c
+path:mercurial/thirdparty/xdiff/xinclude.h
+path:mercurial/thirdparty/xdiff/xmacros.h
+path:mercurial/thirdparty/xdiff/xmerge.c
+path:mercurial/thirdparty/xdiff/xpatience.c
+path:mercurial/thirdparty/xdiff/xprepare.c
+path:mercurial/thirdparty/xdiff/xprepare.h
+path:mercurial/thirdparty/xdiff/xtypes.h
+path:mercurial/thirdparty/xdiff/xutils.c
+path:mercurial/thirdparty/xdiff/xutils.h
+path:mercurial/thirdparty/zope/interface/_zope_interface_coptimizations.c