# HG changeset patch # User Yuya Nishihara # Date 1508573942 -32400 # Node ID dad8a5071b0a9616f8fea713e8a0dcd222415610 # Parent a8478b808f17b76b0531d2bb5374ffc46f978c2a templatefilters: add slashpath() to convert path separator to slash Prepares for deprecating the ui.slash option, which isn't always respected. diff -r a8478b808f17 -r dad8a5071b0a mercurial/templatefilters.py --- a/mercurial/templatefilters.py Thu Dec 14 22:26:46 2017 +0900 +++ b/mercurial/templatefilters.py Sat Oct 21 17:19:02 2017 +0900 @@ -349,6 +349,11 @@ """Date. Returns a date like "2006-09-18".""" return util.shortdate(text) +@templatefilter('slashpath') +def slashpath(path): + """Any text. Replaces the native path separator with slash.""" + return util.pconvert(path) + @templatefilter('splitlines') def splitlines(text): """Any text. Split text into a list of lines.""" diff -r a8478b808f17 -r dad8a5071b0a tests/test-locate.t --- a/tests/test-locate.t Thu Dec 14 22:26:46 2017 +0900 +++ b/tests/test-locate.t Sat Oct 21 17:19:02 2017 +0900 @@ -151,4 +151,13 @@ $ hg files . [1] +Convert native path separator to slash (issue5572) + + $ hg files -T '{path|slashpath}\n' + ../b + ../dir.h/foo + ../t.h + ../t/e.h + ../t/x + $ cd ../..