mercurial/templater.py
changeset 31520 6f150bb19317
parent 31519 3725986b151a
child 31521 44c591f63458
--- a/mercurial/templater.py	Sat Mar 18 20:38:44 2017 +0900
+++ b/mercurial/templater.py	Sat Mar 18 20:50:15 2017 +0900
@@ -14,6 +14,7 @@
 from .i18n import _
 from . import (
     config,
+    encoding,
     error,
     minirst,
     parser,
@@ -581,10 +582,13 @@
     if len(args) > 3:
         left = evalboolean(context, mapping, args[3])
 
+    fillwidth = width - encoding.colwidth(text)
+    if fillwidth <= 0:
+        return text
     if left:
-        return text.rjust(width, fillchar)
+        return fillchar * fillwidth + text
     else:
-        return text.ljust(width, fillchar)
+        return text + fillchar * fillwidth
 
 @templatefunc('indent(text, indentchars[, firstline])')
 def indent(context, mapping, args):