hgext/progress.py
changeset 21859 be4270d27a7e
parent 19619 4694ccd5d994
child 21860 e382cf9ec30b
equal deleted inserted replaced
21858:50fd3a36d166 21859:be4270d27a7e
    38 import sys
    38 import sys
    39 import time
    39 import time
    40 
    40 
    41 from mercurial.i18n import _
    41 from mercurial.i18n import _
    42 testedwith = 'internal'
    42 testedwith = 'internal'
       
    43 
       
    44 from mercurial import encoding
    43 
    45 
    44 def spacejoin(*args):
    46 def spacejoin(*args):
    45     return ' '.join(s for s in args if s)
    47     return ' '.join(s for s in args if s)
    46 
    48 
    47 def shouldprint(ui):
    49 def shouldprint(ui):
   178                        ' ' * int(abs(amt)))
   180                        ' ' * int(abs(amt)))
   179             prog = ''.join(('[', bar , ']'))
   181             prog = ''.join(('[', bar , ']'))
   180             out = spacejoin(head, prog, tail)
   182             out = spacejoin(head, prog, tail)
   181         else:
   183         else:
   182             out = spacejoin(head, tail)
   184             out = spacejoin(head, tail)
   183         sys.stderr.write('\r' + out[:termwidth])
   185         sys.stderr.write('\r' + encoding.trim(out, termwidth))
   184         self.lasttopic = topic
   186         self.lasttopic = topic
   185         sys.stderr.flush()
   187         sys.stderr.flush()
   186 
   188 
   187     def clear(self):
   189     def clear(self):
   188         if not shouldprint(self.ui):
   190         if not shouldprint(self.ui):