##// END OF EJS Templates
templater: add relpath() to convert repo path to relative path (issue5394)...
Yuya Nishihara -
r30083:bd1f043d default
parent child Browse files
Show More
@@ -713,6 +713,18 b' def localdate(context, mapping, args):'
713 tzoffset = util.makedate()[1]
713 tzoffset = util.makedate()[1]
714 return (date[0], tzoffset)
714 return (date[0], tzoffset)
715
715
716 @templatefunc('relpath(path)')
717 def relpath(context, mapping, args):
718 """Convert a repository-absolute path into a filesystem path relative to
719 the current working directory."""
720 if len(args) != 1:
721 # i18n: "relpath" is a keyword
722 raise error.ParseError(_("relpath expects one argument"))
723
724 repo = mapping['ctx'].repo()
725 path = evalstring(context, mapping, args[0])
726 return repo.pathto(path)
727
716 @templatefunc('revset(query[, formatargs...])')
728 @templatefunc('revset(query[, formatargs...])')
717 def revset(context, mapping, args):
729 def revset(context, mapping, args):
718 """Execute a revision set query. See
730 """Execute a revision set query. See
@@ -3521,6 +3521,15 b' Test files function'
3521 0
3521 0
3522
3522
3523
3523
3524 Test relpath function
3525
3526 $ hg log -r0 -T '{files % "{file|relpath}\n"}'
3527 a
3528 $ cd ..
3529 $ hg log -R r -r0 -T '{files % "{file|relpath}\n"}'
3530 r/a (glob)
3531 $ cd r
3532
3524 Test active bookmark templating
3533 Test active bookmark templating
3525
3534
3526 $ hg book foo
3535 $ hg book foo
General Comments 0
You need to be logged in to leave comments. Login now