# HG changeset patch # User Valentin Gatien-Baron # Date 2022-04-20 15:34:26 # Node ID 22fc694572ea1db489226b067bdebbe97bee1aba # Parent 90e564882f0727ea31aa14a8bdb720bb683ce38f chg: make `chg --cwd $anything -R $relativepath` behave better We're seeing this kind of issue: ``` $ (cd repo1; chg --cwd ../repo2 -R .) chg: abort: too many redirections. Please make sure $path/hg is not a wrapper which changes sensitive environment variables before executing hg. If you have to use a wrapper, wrap chg instead of hg. [255] ``` chgserver is interpreting -R as relative to its cwd, instead of relative to --cwd like regular hg does, which I think causes an inconsistency leading to the above. Differential Revision: https://phab.mercurial-scm.org/D12579 diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -991,6 +991,8 @@ def _getlocal(ui, rpath, wd=None): lui.readconfig(os.path.join(path, b".hg", b"hgrc-not-shared"), path) if rpath: + if wd is not None: + rpath = os.path.join(wd, rpath) path = urlutil.get_clone_path(lui, rpath)[0] lui = ui.copy() if rcutil.use_repo_hgrc(): diff --git a/tests/test-chg.t b/tests/test-chg.t --- a/tests/test-chg.t +++ b/tests/test-chg.t @@ -433,6 +433,15 @@ check server log: YYYY/MM/DD HH:MM:SS (PID)> log -R cached YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s) +-R is interpreted relative to --cwd + + $ hg init repo1 + $ hg init repo2 + $ printf "[alias]\nx=y\n" >> repo1/.hg/hgrc + $ printf "[alias]\nx=z\n" >> repo2/.hg/hgrc + $ (cd repo1; chg --cwd ../repo2 -R . show alias.x) + z + Test that chg works (sets to the user's actual LC_CTYPE) even when python "coerces" the locale (py3.7+) @@ -537,3 +546,4 @@ FIXME: Run 4 should not be >3x Run 1's n $ filteredchg log -r . --no-profile $ filteredchg log -r . Sample count: * (glob) + $ cd ../