Skip to content

Commit 4cba60d

Browse files
committed
_run_cmd: override user aliases in run()
If a user aliased "hg log" to "hg log --graph" [^1] (apparently this is widespread, see [^2]), mercurial based setups do not work, because "hg log" output needs to be reset to a canonical form. This is done setting the environment variable HGRCPATH= to an empty value. A previous attempt at normalizing hg output was done on 2010-08-29, when e0954e3 ("inline getoutput, set HGPLAIN to disable hg i18n"), introduced HGPLAIN=1, but this change is not sufficient for protecting against `hg log` aliasing. An example of command that is fixed with this change is the compilation of mercurial itself in local mode (here shown for 7.2.1): ``` $ make local ... File "<HOME>/.cache/uv/builds-v0/.tmpcFxMQB/lib64/python3.14/site-packages/vcs_versioning/_run_cmd.py", line 173, in run res.check_returncode() ~~~~~~~~~~~~~~~~~~~~^^ File "/usr/lib64/python3.14/subprocess.py", line 508, in check_returncode raise CalledProcessError(self.returncode, self.args, self.stdout, self.stderr) subprocess.CalledProcessError: Command '['hg', 'log', '-r', '.', '-T', '{node}\n{tag}\n{date|shortdate}']' returned non-zero exit status 255. ``` [^1]: `hg log` can be aliased editing the contents of `hgrc`: ``` [alias] log = log --graph ``` [^2]: https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/604c086ddde6f40309c03ae7e5050c7c8d87e75a
1 parent ae0b4dd commit 4cba60d

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

vcs-versioning/src/vcs_versioning/_run_cmd.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def run(
155155
LC_ALL="C.UTF-8",
156156
LANGUAGE="",
157157
HGPLAIN="1",
158+
HGRCPATH="",
158159
),
159160
text=True,
160161
encoding="utf-8",

0 commit comments

Comments
 (0)