diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -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 --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -1233,6 +1233,9 @@ coreconfigitem('ui', 'quietbookmarkmove', default=False, ) +coreconfigitem('ui', 'relative-paths', + default=False, +) coreconfigitem('ui', 'remotecmd', default='hg', ) diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -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 --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -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 --git a/tests/test-status.t b/tests/test-status.t --- a/tests/test-status.t +++ b/tests/test-status.t @@ -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