comparison mercurial/changegroup.py @ 25574:88a17ccf0196

changegroup: simplify by not reusing 'prog(ress)' instance Just create a new instance of the 'prog' class for each step instead of replacing its fields and resetting the counter.
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 12 Jun 2015 11:00:50 -0700
parents 3e89e67f17e8
children f0745da75056
comparison
equal deleted inserted replaced
25573:3e89e67f17e8 25574:88a17ccf0196
739 trp = weakref.proxy(tr) 739 trp = weakref.proxy(tr)
740 # pull off the changeset group 740 # pull off the changeset group
741 repo.ui.status(_("adding changesets\n")) 741 repo.ui.status(_("adding changesets\n"))
742 clstart = len(cl) 742 clstart = len(cl)
743 class prog(object): 743 class prog(object):
744 step = _('changesets') 744 def __init__(self, step, total):
745 count = 1 745 self._step = step
746 total = expectedtotal 746 self._total = total
747 self._count = 1
747 def __call__(self): 748 def __call__(self):
748 repo.ui.progress(self.step, self.count, unit=_('chunks'), 749 repo.ui.progress(self._step, self._count, unit=_('chunks'),
749 total=self.total) 750 total=self._total)
750 self.count += 1 751 self._count += 1
751 pr = prog() 752 source.callback = prog(_('changesets'), expectedtotal)
752 source.callback = pr
753 753
754 source.changelogheader() 754 source.changelogheader()
755 srccontent = cl.addgroup(source, csmap, trp) 755 srccontent = cl.addgroup(source, csmap, trp)
756 if not (srccontent or emptyok): 756 if not (srccontent or emptyok):
757 raise util.Abort(_("received changelog group is empty")) 757 raise util.Abort(_("received changelog group is empty"))
762 efiles = len(efiles) 762 efiles = len(efiles)
763 repo.ui.progress(_('changesets'), None) 763 repo.ui.progress(_('changesets'), None)
764 764
765 # pull off the manifest group 765 # pull off the manifest group
766 repo.ui.status(_("adding manifests\n")) 766 repo.ui.status(_("adding manifests\n"))
767 pr.step = _('manifests') 767 # manifests <= changesets
768 pr.count = 1 768 source.callback = prog(_('manifests'), changesets)
769 pr.total = changesets # manifests <= changesets
770 # no need to check for empty manifest group here: 769 # no need to check for empty manifest group here:
771 # if the result of the merge of 1 and 2 is the same in 3 and 4, 770 # if the result of the merge of 1 and 2 is the same in 3 and 4,
772 # no new manifest will be created and the manifest group will 771 # no new manifest will be created and the manifest group will
773 # be empty during the pull 772 # be empty during the pull
774 source.manifestheader() 773 source.manifestheader()
785 for f, n in mfest.iteritems(): 784 for f, n in mfest.iteritems():
786 needfiles.setdefault(f, set()).add(n) 785 needfiles.setdefault(f, set()).add(n)
787 786
788 # process the files 787 # process the files
789 repo.ui.status(_("adding file changes\n")) 788 repo.ui.status(_("adding file changes\n"))
790 pr.step = _('files')
791 pr.count = 1
792 pr.total = efiles
793 source.callback = None 789 source.callback = None
794 790 pr = prog(_('files'), efiles)
795 newrevs, newfiles = addchangegroupfiles(repo, source, revmap, trp, pr, 791 newrevs, newfiles = addchangegroupfiles(repo, source, revmap, trp, pr,
796 needfiles) 792 needfiles)
797 revisions += newrevs 793 revisions += newrevs
798 files += newfiles 794 files += newfiles
799 795