status: if ui.relative-paths=no, don't use relative paths even with patterns
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 01 Feb 2019 22:52:09 -0800
changeset 41577 5f827e9ce870
parent 41576 15f63ac122ea
child 41578 8d1dc380b026
status: if ui.relative-paths=no, don't use relative paths even with patterns Without ui.relative-paths or command.status.relative set, you get this behavior: hgext$ hg st M hgext/narrow/narrowrepo.py hgext$ hg st . M narrow/narrowrepo.py hgext$ hg st narrow M narrow/narrowrepo.py I think it's surprising that some of those produce relative paths. I suspect it works that way because "hg st ." was an easy way of getting relative paths. Perhaps not much thought was given to how it should behave when the pattern was not ".". It also feels wrong to conflate the request for relative patterns with matching of of patterns. Since we can now start fresh and define the behavior of ui.relative-paths as we want, I suggest we make ui.relative-paths=no consistently not give relative paths. So that's what this paths starts doing for `hg status`. Differential Revision: https://phab.mercurial-scm.org/D5802
mercurial/commands.py
tests/test-status.t
--- a/mercurial/commands.py	Tue Jan 29 15:49:20 2019 -0800
+++ b/mercurial/commands.py	Fri Feb 01 22:52:09 2019 -0800
@@ -5416,12 +5416,11 @@
         repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn')
         ctx1, ctx2 = scmutil.revpair(repo, revs)
 
-    relative = None
-    if pats:
-        relative = True
-    elif ui.hasconfig('commands', 'status.relative'):
-        relative = ui.configbool('commands', 'status.relative')
-    uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=relative)
+    forcerelativevalue = None
+    if ui.hasconfig('commands', 'status.relative'):
+        forcerelativevalue = ui.configbool('commands', 'status.relative')
+    uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=bool(pats),
+                                   forcerelativevalue=forcerelativevalue)
 
     if opts.get('print0'):
         end = '\0'
--- a/tests/test-status.t	Tue Jan 29 15:49:20 2019 -0800
+++ b/tests/test-status.t	Fri Feb 01 22:52:09 2019 -0800
@@ -132,11 +132,7 @@
 
 relative paths can be requested
 
-  $ cat >> $HGRCPATH <<EOF
-  > [ui]
-  > relative-paths = True
-  > EOF
-  $ hg status --cwd a
+  $ hg status --cwd a --config ui.relative-paths=yes
   ? 1/in_a_1
   ? in_a
   ? ../b/1/in_b_1
@@ -144,6 +140,13 @@
   ? ../b/in_b
   ? ../in_root
 
+  $ hg status --cwd a . --config ui.relative-paths=legacy
+  ? 1/in_a_1
+  ? in_a
+  $ hg status --cwd a . --config ui.relative-paths=no
+  ? a/1/in_a_1
+  ? a/in_a
+
 commands.status.relative overrides ui.relative-paths
 
   $ cat >> $HGRCPATH <<EOF