mercurial/util.py
changeset 21857 86c2d792a4b7
parent 21813 c2262004c2e2
child 21907 7e5dfa00e3c2
--- a/mercurial/util.py	Sun Jul 06 02:56:41 2014 +0900
+++ b/mercurial/util.py	Sun Jul 06 02:56:41 2014 +0900
@@ -1318,23 +1318,9 @@
         r = None
     return author[author.find('<') + 1:r]
 
-def _ellipsis(text, maxlength):
-    if len(text) <= maxlength:
-        return text, False
-    else:
-        return "%s..." % (text[:maxlength - 3]), True
-
 def ellipsis(text, maxlength=400):
-    """Trim string to at most maxlength (default: 400) characters."""
-    try:
-        # use unicode not to split at intermediate multi-byte sequence
-        utext, truncated = _ellipsis(text.decode(encoding.encoding),
-                                     maxlength)
-        if not truncated:
-            return text
-        return utext.encode(encoding.encoding)
-    except (UnicodeDecodeError, UnicodeEncodeError):
-        return _ellipsis(text, maxlength)[0]
+    """Trim string to at most maxlength (default: 400) columns in display."""
+    return encoding.trim(text, maxlength, ellipsis='...')
 
 def unitcountfn(*unittable):
     '''return a function that renders a readable count of some quantity'''