comparison hgext/progress.py @ 21862:ba7f75e7f4e5

progress: use 'encoding.trim' to trim items in output line correctly Before this patch, 'progress' extension trims items in output line by directly slicing byte sequence, but it may split at intermediate multi-byte sequence. This patch uses 'encoding.trim' to trim items in output line correctly, even if it contains multi-byte characters.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sun, 06 Jul 2014 02:56:41 +0900
parents e382cf9ec30b
children f9c91c638378
comparison
equal deleted inserted replaced
21861:b515c3a63e96 21862:ba7f75e7f4e5
137 slice = 'beginning' 137 slice = 'beginning'
138 wid = int(indicator.split('+')[1]) 138 wid = int(indicator.split('+')[1])
139 else: 139 else:
140 wid = 20 140 wid = 20
141 if slice == 'end': 141 if slice == 'end':
142 add = item[-wid:] 142 add = encoding.trim(item, wid, leftside=True)
143 else: 143 else:
144 add = item[:wid] 144 add = encoding.trim(item, wid)
145 add += (wid - len(add)) * ' ' 145 add += (wid - len(add)) * ' '
146 elif indicator == 'bar': 146 elif indicator == 'bar':
147 add = '' 147 add = ''
148 needprogress = True 148 needprogress = True
149 elif indicator == 'unit' and unit: 149 elif indicator == 'unit' and unit: