templatefilters: add slashpath() to convert path separator to slash

Prepares for deprecating the ui.slash option, which isn't always respected.
This commit is contained in:
Yuya Nishihara 2017-10-21 17:19:02 +09:00
parent 3a0cd26f9a
commit e9a3f998f1
2 changed files with 14 additions and 0 deletions

View File

@ -349,6 +349,11 @@ def shortdate(text):
"""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."""

View File

@ -151,4 +151,13 @@ Issue294: hg remove --after dir fails when dir.* also exists
$ 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 ../..