D5802: status: if ui.relative-paths=no, don't use relative paths even with patterns

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sat Feb 2 07:12:56 UTC 2019


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5802

AFFECTED FILES
  mercurial/commands.py
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -132,18 +132,21 @@
 
 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
   ? ../b/2/in_b_2
   ? ../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
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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, forcevalue=relative)
+    forcerelative = None
+    if ui.hasconfig('commands', 'status.relative'):
+        forcerelative = ui.configbool('commands', 'status.relative')
+    uipathfn = scmutil.getuipathfn(repo, legacyvalue=bool(pats),
+                                   forcevalue=forcerelative)
 
     if opts.get('print0'):
         end = '\0'



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list