# HG changeset patch # User Martin von Zweigbergk # Date 1548805055 28800 # Node ID 02186c6871ac3de228d440b96dda63f59919a125 # Parent e6ec0737b706712d63cdc9b8e9f917bb0a10e2ad status: introduce higher-level ui.relative-paths The existing commands.status.relative trumps the new config. We need to keep the existing config around for compatibility. However, I don't think we need to introduce similar command-specific options for other commands when they learn to respec ui.relative-paths. Differential Revision: https://phab.mercurial-scm.org/D5746 diff -r e6ec0737b706 -r 02186c6871ac mercurial/commands.py --- a/mercurial/commands.py Tue Jan 29 15:37:14 2019 -0800 +++ b/mercurial/commands.py Tue Jan 29 15:37:35 2019 -0800 @@ -5414,7 +5414,11 @@ repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn') ctx1, ctx2 = scmutil.revpair(repo, revs) - relative = pats or ui.configbool('commands', 'status.relative') + relative = None + if pats: + relative = True + elif ui.hasconfig('commands', 'status.relative'): + relative = ui.configbool('commands', 'status.relative') uipathfn = scmutil.getuipathfn(repo, relative) if opts.get('print0'): diff -r e6ec0737b706 -r 02186c6871ac mercurial/configitems.py --- a/mercurial/configitems.py Tue Jan 29 15:37:14 2019 -0800 +++ b/mercurial/configitems.py Tue Jan 29 15:37:35 2019 -0800 @@ -1233,6 +1233,9 @@ coreconfigitem('ui', 'quietbookmarkmove', default=False, ) +coreconfigitem('ui', 'relative-paths', + default=False, +) coreconfigitem('ui', 'remotecmd', default='hg', ) diff -r e6ec0737b706 -r 02186c6871ac mercurial/help/config.txt --- a/mercurial/help/config.txt Tue Jan 29 15:37:14 2019 -0800 +++ b/mercurial/help/config.txt Tue Jan 29 15:37:35 2019 -0800 @@ -2331,6 +2331,9 @@ Reduce the amount of output printed. (default: False) +``relative-paths`` + Prefer relative paths in the UI. + ``remotecmd`` Remote command to use for clone/push/pull operations. (default: ``hg``) diff -r e6ec0737b706 -r 02186c6871ac mercurial/scmutil.py --- a/mercurial/scmutil.py Tue Jan 29 15:37:14 2019 -0800 +++ b/mercurial/scmutil.py Tue Jan 29 15:37:35 2019 -0800 @@ -725,7 +725,9 @@ return [] return parents -def getuipathfn(repo, relative): +def getuipathfn(repo, relative=None): + if relative is None: + relative = repo.ui.configbool('ui', 'relative-paths') if relative: cwd = repo.getcwd() pathto = repo.pathto diff -r e6ec0737b706 -r 02186c6871ac tests/test-status.t --- a/tests/test-status.t Tue Jan 29 15:37:14 2019 -0800 +++ b/tests/test-status.t Tue Jan 29 15:37:35 2019 -0800 @@ -133,6 +133,22 @@ relative paths can be requested $ cat >> $HGRCPATH < [ui] + > relative-paths = True + > EOF + $ hg status --cwd a + ? 1/in_a_1 + ? in_a + ? ../b/1/in_b_1 + ? ../b/2/in_b_2 + ? ../b/in_b + ? ../in_root + +commands.status.relative overrides ui.relative-paths + + $ cat >> $HGRCPATH < [ui] + > relative-paths = False > [commands] > status.relative = True > EOF