pyproject: lock in the major version of `black` that's required
The `hghave` checks already look for an exact this minor version of this, but
according to their Stability Policy[1], we can use any version with the same
major number. The reason for adding this here is we don't want someone to
blindly run the tool and get a different format because they were running a
different major version locally. It also makes it easier to discover when the
required version has changed, because that's included in the error message.
If there's concern about duplication and forgetting to update one place or the
other, we can pipe a trivial python statement to it, and see if it exits with a
failure. FWIW, having it in the project file here is also enforced when running
`test-check-format.t`. It's not enforced by the `hghave` version check, so if
it gets out of sync, the test will run and print:
Oh no! \xf0\x9f\x92\xa5 \xf0\x9f\x92\x94 \xf0\x9f\x92\xa5 The required version `24` does not match the running version `23.3.0`!
[1] https://github.com/psf/black/blob/30759ca782429221cfb329f335e2074cb359decb/docs/the_black_code_style/index.md?plain=1#L24
# stack.py - Mercurial functions for stack definition
#
# Copyright Olivia Mackall <olivia@selenic.com> and other
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import annotations
def getstack(repo, rev=None):
"""return a sorted smartrev of the stack containing either rev if it is
not None or the current working directory parent.
The stack will always contain all drafts changesets which are ancestors to
the revision and are not merges.
"""
if rev is None:
rev = b'.'
revspec = b'only(%s) and not public() and not ::merge()'
revisions = repo.revs(revspec, rev)
revisions.sort()
return revisions