~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: Martin Pool
  • Date: 2005-09-16 09:56:24 UTC
  • Revision ID: mbp@sourcefrog.net-20050916095623-ca0dff452934f21f
- make progress bar more tolerant of out-of-range values

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
    def update(self, msg, current_cnt=None, total_cnt=None):
192
192
        """Update and redraw progress bar."""
193
193
 
 
194
        if current_cnt < 0:
 
195
            current_cnt = 0
 
196
            
 
197
        if current_cnt > total_cnt:
 
198
            total_cnt = current_cnt
 
199
 
194
200
        # save these for the tick() function
195
201
        self.last_msg = msg
196
202
        self.last_cnt = current_cnt
199
205
        if self.throttle():
200
206
            return 
201
207
        
202
 
        if total_cnt:
203
 
            assert current_cnt <= total_cnt
204
 
        if current_cnt:
205
 
            assert current_cnt >= 0
206
 
        
207
208
        if self.show_eta and self.start_time and total_cnt:
208
209
            eta = get_eta(self.start_time, current_cnt, total_cnt)
209
210
            eta_str = " " + str_tdelta(eta)