Mercurial > public > mercurial-scm > hg
comparison mercurial/upgrade.py @ 38399:185588cb0c4b
upgrade: use progress helper
A minor side-effect is that we no longer print the progress at 0 (and
that we don't re-print it at its current value when starting the next
manifest/file).
Differential Revision: https://phab.mercurial-scm.org/D3800
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sun, 17 Jun 2018 23:48:23 -0700 |
parents | f273b768b60f |
children | 4ad2a1ff0404 |
comparison
equal
deleted
inserted
replaced
38398:f273b768b60f | 38399:185588cb0c4b |
---|---|
496 (revcount, frevcount, mrevcount, crevcount)) | 496 (revcount, frevcount, mrevcount, crevcount)) |
497 ui.write(_('migrating %s in store; %s tracked data\n') % ( | 497 ui.write(_('migrating %s in store; %s tracked data\n') % ( |
498 (util.bytecount(srcsize), util.bytecount(srcrawsize)))) | 498 (util.bytecount(srcsize), util.bytecount(srcrawsize)))) |
499 | 499 |
500 # Used to keep track of progress. | 500 # Used to keep track of progress. |
501 progress = [] | 501 progress = None |
502 def oncopiedrevision(rl, rev, node): | 502 def oncopiedrevision(rl, rev, node): |
503 progress[1] += 1 | 503 progress.increment() |
504 srcrepo.ui.progress(progress[0], progress[1], total=progress[2]) | |
505 | 504 |
506 # Do the actual copying. | 505 # Do the actual copying. |
507 # FUTURE this operation can be farmed off to worker processes. | 506 # FUTURE this operation can be farmed off to worker processes. |
508 seen = set() | 507 seen = set() |
509 for unencoded, encoded, size in srcrepo.store.walk(): | 508 for unencoded, encoded, size in srcrepo.store.walk(): |
521 ui.write(_('migrating changelog containing %d revisions ' | 520 ui.write(_('migrating changelog containing %d revisions ' |
522 '(%s in store; %s tracked data)\n') % | 521 '(%s in store; %s tracked data)\n') % |
523 (crevcount, util.bytecount(csrcsize), | 522 (crevcount, util.bytecount(csrcsize), |
524 util.bytecount(crawsize))) | 523 util.bytecount(crawsize))) |
525 seen.add('c') | 524 seen.add('c') |
526 progress[:] = [_('changelog revisions'), 0, crevcount] | 525 progress = srcrepo.ui.makeprogress(_('changelog revisions'), |
526 total=crevcount) | |
527 elif isinstance(oldrl, manifest.manifestrevlog) and 'm' not in seen: | 527 elif isinstance(oldrl, manifest.manifestrevlog) and 'm' not in seen: |
528 ui.write(_('finished migrating %d filelog revisions across %d ' | 528 ui.write(_('finished migrating %d filelog revisions across %d ' |
529 'filelogs; change in size: %s\n') % | 529 'filelogs; change in size: %s\n') % |
530 (frevcount, fcount, util.bytecount(fdstsize - fsrcsize))) | 530 (frevcount, fcount, util.bytecount(fdstsize - fsrcsize))) |
531 | 531 |
533 '(%s in store; %s tracked data)\n') % | 533 '(%s in store; %s tracked data)\n') % |
534 (mcount, mrevcount, util.bytecount(msrcsize), | 534 (mcount, mrevcount, util.bytecount(msrcsize), |
535 util.bytecount(mrawsize))) | 535 util.bytecount(mrawsize))) |
536 seen.add('m') | 536 seen.add('m') |
537 if progress: | 537 if progress: |
538 ui.progress(progress[0], None) | 538 progress.complete() |
539 progress[:] = [_('manifest revisions'), 0, mrevcount] | 539 progress = srcrepo.ui.makeprogress(_('manifest revisions'), |
540 total=mrevcount) | |
540 elif 'f' not in seen: | 541 elif 'f' not in seen: |
541 ui.write(_('migrating %d filelogs containing %d revisions ' | 542 ui.write(_('migrating %d filelogs containing %d revisions ' |
542 '(%s in store; %s tracked data)\n') % | 543 '(%s in store; %s tracked data)\n') % |
543 (fcount, frevcount, util.bytecount(fsrcsize), | 544 (fcount, frevcount, util.bytecount(fsrcsize), |
544 util.bytecount(frawsize))) | 545 util.bytecount(frawsize))) |
545 seen.add('f') | 546 seen.add('f') |
546 if progress: | 547 if progress: |
547 ui.progress(progress[0], None) | 548 progress.complete() |
548 progress[:] = [_('file revisions'), 0, frevcount] | 549 progress = srcrepo.ui.makeprogress(_('file revisions'), |
549 | 550 total=frevcount) |
550 ui.progress(progress[0], progress[1], total=progress[2]) | 551 |
551 | 552 |
552 ui.note(_('cloning %d revisions from %s\n') % (len(oldrl), unencoded)) | 553 ui.note(_('cloning %d revisions from %s\n') % (len(oldrl), unencoded)) |
553 oldrl.clone(tr, newrl, addrevisioncb=oncopiedrevision, | 554 oldrl.clone(tr, newrl, addrevisioncb=oncopiedrevision, |
554 deltareuse=deltareuse, | 555 deltareuse=deltareuse, |
555 aggressivemergedeltas=aggressivemergedeltas) | 556 aggressivemergedeltas=aggressivemergedeltas) |
566 elif isinstance(newrl, manifest.manifestrevlog): | 567 elif isinstance(newrl, manifest.manifestrevlog): |
567 mdstsize += datasize | 568 mdstsize += datasize |
568 else: | 569 else: |
569 fdstsize += datasize | 570 fdstsize += datasize |
570 | 571 |
571 ui.progress(progress[0], None) | 572 progress.complete() |
572 | 573 |
573 ui.write(_('finished migrating %d changelog revisions; change in size: ' | 574 ui.write(_('finished migrating %d changelog revisions; change in size: ' |
574 '%s\n') % (crevcount, util.bytecount(cdstsize - csrcsize))) | 575 '%s\n') % (crevcount, util.bytecount(cdstsize - csrcsize))) |
575 | 576 |
576 ui.write(_('finished migrating %d total revisions; total change in store ' | 577 ui.write(_('finished migrating %d total revisions; total change in store ' |