contrib/examples/fix.hgrc
author Manuel Jacob <me@manueljacob.de>
Mon, 11 Jul 2022 01:51:20 +0200
branchstable
changeset 49378 094a5fa3cf52
parent 46893 3d32b9759047
permissions -rw-r--r--
procutil: make stream detection in make_line_buffered more correct and strict In make_line_buffered(), we don’t want to wrap the stream if we know that lines get flushed to the underlying raw stream already. Previously, the heuristic was too optimistic. It assumed that any stream which is not an instance of io.BufferedIOBase doesn’t need wrapping. However, there are buffered streams that aren’t instances of io.BufferedIOBase, like Mercurial’s own winstdout. The new logic is different in two ways: First, only for the check, if unwraps any combination of WriteAllWrapper and winstdout. Second, it skips wrapping the stream only if it is an instance of io.RawIOBase (or already wrapped). If it is an instance of io.BufferedIOBase, it gets wrapped. In any other case, the function raises an exception. This ensures that, if an unknown stream is passed or we add another wrapper in the future, we don’t wrap the stream if it’s already line buffered or not wrap the stream if it’s not line buffered. In fact, this was already helpful during development of this change. Without it, I possibly would have forgot that WriteAllWrapper needs to be ignored for the check, leading to unnecessary wrapping if stdout is unbuffered. The alternative would have been to always wrap unknown streams. However, I don’t think that anyone would benefit from being less strict. We can expect streams from the standard library to be subclassing either io.RawIOBase or io.BufferedIOBase, so running Mercurial in the standard way should not regress by this change. Py2exe might replace sys.stdout and sys.stderr, but that currently breaks Mercurial anyway and also these streams don’t claim to be interactive, so this function is not called for them.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42965
5dfb57af1148 contrib: add new examples area and start it out with a config for `hg fix`
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
[fix]
44008
ac72e17457e5 fix: correct the clang-format example hgrc so that it actually works
Kyle Lippincott <spectral@google.com>
parents: 43921
diff changeset
     2
clang-format:command = clang-format --style file
ac72e17457e5 fix: correct the clang-format example hgrc so that it actually works
Kyle Lippincott <spectral@google.com>
parents: 43921
diff changeset
     3
clang-format:pattern = set:(**.c or **.cc or **.h) and not "include:contrib/clang-format-ignorelist"
42966
f5ad85dd5f7e examples: add sample fix integration for `rustfmt`
Augie Fackler <augie@google.com>
parents: 42965
diff changeset
     4
44103
2077ffede71f examples: refer to nightly rustfmt in Windows-compatible way
Martin von Zweigbergk <martinvonz@google.com>
parents: 44069
diff changeset
     5
rustfmt:command = rustfmt +nightly
45620
426294d06ddc rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents: 44147
diff changeset
     6
rustfmt:pattern = set:"**.rs" - "mercurial/thirdparty/**"
43065
31c1a5376745 examples: include a sample of how to use black with fix
Augie Fackler <augie@google.com>
parents: 42966
diff changeset
     7
46893
3d32b9759047 contrib: restore the `hg fix` configuration in the examples
Matt Harbison <matt_harbison@yahoo.com>
parents: 46774
diff changeset
     8
black:command = black --config=pyproject.toml -
44147
5e84a96d865b python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44103
diff changeset
     9
black:pattern = set:**.py - mercurial/thirdparty/**
43921
b78795c2a294 examples: add an example configuration for go source files
Augie Fackler <augie@google.com>
parents: 43502
diff changeset
    10
b78795c2a294 examples: add an example configuration for go source files
Augie Fackler <augie@google.com>
parents: 43502
diff changeset
    11
# Mercurial doesn't have any Go code, but if we did this is how we
b78795c2a294 examples: add an example configuration for go source files
Augie Fackler <augie@google.com>
parents: 43502
diff changeset
    12
# would configure `hg fix` for Go:
b78795c2a294 examples: add an example configuration for go source files
Augie Fackler <augie@google.com>
parents: 43502
diff changeset
    13
go:command = gofmt
b78795c2a294 examples: add an example configuration for go source files
Augie Fackler <augie@google.com>
parents: 43502
diff changeset
    14
go:pattern = set:**.go