##// END OF EJS Templates
Also find correct column width of wide characters....
Shun-ichi GOTO -
r7695:deec6628 default
parent child Browse files
Show More
@@ -448,7 +448,7 b' def branches(ui, repo, active=False):'
448 notice = ' (closed)'
448 notice = ' (closed)'
449 else:
449 else:
450 notice = ' (inactive)'
450 notice = ' (inactive)'
451 rev = str(node).rjust(31 - util.locallen(tag))
451 rev = str(node).rjust(31 - util.colwidth(tag))
452 data = tag, rev, hexfunc(hn), notice
452 data = tag, rev, hexfunc(hn), notice
453 ui.write("%s %s:%s%s\n" % data)
453 ui.write("%s %s:%s%s\n" % data)
454
454
@@ -2833,7 +2833,7 b' def tags(ui, repo):'
2833 except error.LookupError:
2833 except error.LookupError:
2834 r = " ?:%s" % hn
2834 r = " ?:%s" % hn
2835 else:
2835 else:
2836 spaces = " " * (30 - util.locallen(t))
2836 spaces = " " * (30 - util.colwidth(t))
2837 if ui.verbose:
2837 if ui.verbose:
2838 if repo.tagtype(t) == 'local':
2838 if repo.tagtype(t) == 'local':
2839 tagtype = " local"
2839 tagtype = " local"
@@ -15,7 +15,7 b' platform-specific details from the core.'
15 from i18n import _
15 from i18n import _
16 import cStringIO, errno, getpass, re, shutil, sys, tempfile, traceback, error
16 import cStringIO, errno, getpass, re, shutil, sys, tempfile, traceback, error
17 import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil
17 import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil
18 import imp
18 import imp, unicodedata
19
19
20 # Python compatibility
20 # Python compatibility
21
21
@@ -138,9 +138,17 b' def fromlocal(s):'
138 except LookupError, k:
138 except LookupError, k:
139 raise Abort(_("%s, please check your locale settings") % k)
139 raise Abort(_("%s, please check your locale settings") % k)
140
140
141 def locallen(s):
141 _colwidth = None
142 """Find the length in characters of a local string"""
142 def colwidth(s):
143 return len(s.decode(_encoding, "replace"))
143 """Find the column width of string to display."""
144 global _colwidth
145 if _colwidth is None:
146 if hasattr(unicodedata, 'east_asian_width'):
147 _colwidth = lambda s: sum([unicodedata.east_asian_width(c) in 'WF'
148 and 2 or 1 for c in s])
149 else:
150 _colwidth = len
151 return _colwidth(s.decode(_encoding, "replace"))
144
152
145 def version():
153 def version():
146 """Return version information if available."""
154 """Return version information if available."""
General Comments 0
You need to be logged in to leave comments. Login now