status: introduce higher-level ui.relative-paths
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 29 Jan 2019 15:37:35 -0800
changeset 41492 02186c6871ac
parent 41491 e6ec0737b706
child 41493 97ab4cbb342e
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
mercurial/commands.py
mercurial/configitems.py
mercurial/help/config.txt
mercurial/scmutil.py
tests/test-status.t
--- 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'):
--- 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',
 )
--- 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``)
--- 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
--- 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 <<EOF
+  > [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 <<EOF
+  > [ui]
+  > relative-paths = False
   > [commands]
   > status.relative = True
   > EOF