mercurial/templater.py
changeset 31520 6f150bb19317
parent 31519 3725986b151a
child 31521 44c591f63458
equal deleted inserted replaced
31519:3725986b151a 31520:6f150bb19317
    12 import types
    12 import types
    13 
    13 
    14 from .i18n import _
    14 from .i18n import _
    15 from . import (
    15 from . import (
    16     config,
    16     config,
       
    17     encoding,
    17     error,
    18     error,
    18     minirst,
    19     minirst,
    19     parser,
    20     parser,
    20     pycompat,
    21     pycompat,
    21     registrar,
    22     registrar,
   579             # i18n: "pad" is a keyword
   580             # i18n: "pad" is a keyword
   580             raise error.ParseError(_("pad() expects a single fill character"))
   581             raise error.ParseError(_("pad() expects a single fill character"))
   581     if len(args) > 3:
   582     if len(args) > 3:
   582         left = evalboolean(context, mapping, args[3])
   583         left = evalboolean(context, mapping, args[3])
   583 
   584 
       
   585     fillwidth = width - encoding.colwidth(text)
       
   586     if fillwidth <= 0:
       
   587         return text
   584     if left:
   588     if left:
   585         return text.rjust(width, fillchar)
   589         return fillchar * fillwidth + text
   586     else:
   590     else:
   587         return text.ljust(width, fillchar)
   591         return text + fillchar * fillwidth
   588 
   592 
   589 @templatefunc('indent(text, indentchars[, firstline])')
   593 @templatefunc('indent(text, indentchars[, firstline])')
   590 def indent(context, mapping, args):
   594 def indent(context, mapping, args):
   591     """Indents all non-empty lines
   595     """Indents all non-empty lines
   592     with the characters given in the indentchars string. An optional
   596     with the characters given in the indentchars string. An optional