mercurial/templater.py
changeset 30083 bd1f043d1ea3
parent 30049 f18cc848b48e
child 30115 8e42dfde93d1
--- a/mercurial/templater.py	Sat Oct 08 19:11:19 2016 +0200
+++ b/mercurial/templater.py	Sat Oct 08 15:24:26 2016 +0200
@@ -713,6 +713,18 @@
         tzoffset = util.makedate()[1]
     return (date[0], tzoffset)
 
+@templatefunc('relpath(path)')
+def relpath(context, mapping, args):
+    """Convert a repository-absolute path into a filesystem path relative to
+    the current working directory."""
+    if len(args) != 1:
+        # i18n: "relpath" is a keyword
+        raise error.ParseError(_("relpath expects one argument"))
+
+    repo = mapping['ctx'].repo()
+    path = evalstring(context, mapping, args[0])
+    return repo.pathto(path)
+
 @templatefunc('revset(query[, formatargs...])')
 def revset(context, mapping, args):
     """Execute a revision set query. See