[PATCH 1 of 2] templatefilters: add slashpath() to convert path separator to slash
Yuya Nishihara
yuya at tcha.org
Tue Dec 12 15:03:37 UTC 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1508573942 -32400
# Sat Oct 21 17:19:02 2017 +0900
# Node ID c2ff7689990d5c163cff48c38880928ee98e4248
# Parent 6ef72e8546b2c86b7ca4ba190fe1affcaa3a440c
templatefilters: add slashpath() to convert path separator to slash
Prepares for deprecating the ui.slash option, which isn't always respected.
diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -349,6 +349,11 @@ def shortdate(text):
"""Date. Returns a date like "2006-09-18"."""
return util.shortdate(text)
+ at 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 --git a/tests/test-locate.t b/tests/test-locate.t
--- a/tests/test-locate.t
+++ b/tests/test-locate.t
@@ -151,4 +151,13 @@ Issue294: hg remove --after dir fails wh
$ 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 ../..
More information about the Mercurial-devel
mailing list