##// END OF EJS Templates
Move ellipsis code to util.ellipsis() and improve maxlength handling.
Thomas Arendsen Hein -
r3767:1861fa38 default
parent child Browse files
Show More
@@ -3031,8 +3031,7 b' def dispatch(args):'
3031 elif not inst[1]:
3031 elif not inst[1]:
3032 u.warn(_(" empty string\n"))
3032 u.warn(_(" empty string\n"))
3033 else:
3033 else:
3034 u.warn("\n%r%s\n" %
3034 u.warn("\n%r\n" % util.ellipsis(inst[1]))
3035 (inst[1][:400], len(inst[1]) > 400 and '...' or ''))
3036 except util.Abort, inst:
3035 except util.Abort, inst:
3037 u.warn(_("abort: %s\n") % inst)
3036 u.warn(_("abort: %s\n") % inst)
3038 except TypeError, inst:
3037 except TypeError, inst:
@@ -1032,6 +1032,13 b' def shortuser(user):'
1032 user = user[:f]
1032 user = user[:f]
1033 return user
1033 return user
1034
1034
1035 def ellipsis(text, maxlength=400):
1036 """Trim string to at most maxlength (default: 400) characters."""
1037 if len(text) <= maxlength:
1038 return text
1039 else:
1040 return "%s..." % (text[:maxlength-3])
1041
1035 def walkrepos(path):
1042 def walkrepos(path):
1036 '''yield every hg repository under path, recursively.'''
1043 '''yield every hg repository under path, recursively.'''
1037 def errhandler(err):
1044 def errhandler(err):
General Comments 0
You need to be logged in to leave comments. Login now