changeset 41576:15f63ac122ea

files: respect ui.relative-paths Differential Revision: https://phab.mercurial-scm.org/D5801
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 29 Jan 2019 15:49:20 -0800
parents aec185af621e
children 5f827e9ce870
files mercurial/cmdutil.py tests/test-locate.t
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Feb 01 22:28:55 2019 -0800
+++ b/mercurial/cmdutil.py	Tue Jan 29 15:49:20 2019 -0800
@@ -2164,6 +2164,7 @@
     ret = 1
 
     needsfctx = ui.verbose or {'size', 'flags'} & fm.datahint()
+    uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
     for f in ctx.matches(m):
         fm.startitem()
         fm.context(ctx=ctx)
@@ -2171,7 +2172,7 @@
             fc = ctx[f]
             fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
         fm.data(path=f)
-        fm.plain(fmt % m.rel(f))
+        fm.plain(fmt % uipathfn(f))
         ret = 0
 
     for subpath in sorted(ctx.substate):
--- a/tests/test-locate.t	Fri Feb 01 22:28:55 2019 -0800
+++ b/tests/test-locate.t	Tue Jan 29 15:49:20 2019 -0800
@@ -123,6 +123,24 @@
   ../t.h
   ../t/e.h
   ../t/x
+  $ hg files --config ui.relative-paths=yes
+  ../b
+  ../dir.h/foo
+  ../t.h
+  ../t/e.h
+  ../t/x
+  $ hg files --config ui.relative-paths=no
+  b
+  dir.h/foo
+  t.h
+  t/e.h
+  t/x
+  $ hg files --config ui.relative-paths=legacy
+  ../b
+  ../dir.h/foo
+  ../t.h
+  ../t/e.h
+  ../t/x
 
   $ hg locate b
   ../b