comparison hgext/fastannotate/context.py @ 40839:dd1006874a5a

fastannotate: use progress helper Differential Revision: https://phab.mercurial-scm.org/D5374
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 04 Dec 2018 15:59:47 -0800
parents 9fcf8084ada8
children 1198c86beb73
comparison
equal deleted inserted replaced
40838:901f6ef670ca 40839:dd1006874a5a
396 # prepare annotateresult so we can update linelog incrementally 396 # prepare annotateresult so we can update linelog incrementally
397 self.linelog.annotate(self.linelog.maxrev) 397 self.linelog.annotate(self.linelog.maxrev)
398 398
399 # 3rd DFS does the actual annotate 399 # 3rd DFS does the actual annotate
400 visit = initvisit[:] 400 visit = initvisit[:]
401 progress = 0 401 progress = self.ui.makeprogress(('building cache'),
402 total=len(newmainbranch))
402 while visit: 403 while visit:
403 f = visit[-1] 404 f = visit[-1]
404 if f in hist: 405 if f in hist:
405 visit.pop() 406 visit.pop()
406 continue 407 continue
435 436
436 hist[f] = curr 437 hist[f] = curr
437 del pcache[f] 438 del pcache[f]
438 439
439 if ismainbranch: # need to write to linelog 440 if ismainbranch: # need to write to linelog
440 if not self.ui.quiet: 441 progress.increment()
441 progress += 1
442 self.ui.progress(_('building cache'), progress,
443 total=len(newmainbranch))
444 bannotated = None 442 bannotated = None
445 if len(pl) == 2 and self.opts.followmerge: # merge 443 if len(pl) == 2 and self.opts.followmerge: # merge
446 bannotated = curr[0] 444 bannotated = curr[0]
447 if blocks is None: # no parents, add an empty one 445 if blocks is None: # no parents, add an empty one
448 blocks = list(self._diffblocks('', curr[1])) 446 blocks = list(self._diffblocks('', curr[1]))
449 self._appendrev(f, blocks, bannotated) 447 self._appendrev(f, blocks, bannotated)
450 elif showpath: # not append linelog, but we need to record path 448 elif showpath: # not append linelog, but we need to record path
451 self._node2path[f.node()] = f.path() 449 self._node2path[f.node()] = f.path()
452 450
453 if progress: # clean progress bar 451 progress.complete()
454 self.ui.write()
455 452
456 result = [ 453 result = [
457 ((self.revmap.rev2hsh(fr) if isinstance(fr, int) else fr.node()), l) 454 ((self.revmap.rev2hsh(fr) if isinstance(fr, int) else fr.node()), l)
458 for fr, l in hist[revfctx][0]] # [(node, linenumber)] 455 for fr, l in hist[revfctx][0]] # [(node, linenumber)]
459 return self._refineannotateresult(result, revfctx, showpath, showlines) 456 return self._refineannotateresult(result, revfctx, showpath, showlines)