Patchwork D3766: changegroup: use progress helper in apply() (API)

login
register
mail settings
Submitter phabricator
Date June 17, 2018, 6:07 p.m.
Message ID <3cbe826d3819e98f9f3c55df9afea2cf@localhost.localdomain>
Download mbox | patch
Permalink /patch/32224/
State Not Applicable
Headers show

Comments

phabricator - June 17, 2018, 6:07 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG83534c4ec58b: changegroup: use progress helper in apply() (API) (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3766?vs=9129&id=9135

REVISION DETAIL
  https://phab.mercurial-scm.org/D3766

AFFECTED FILES
  mercurial/changegroup.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -237,18 +237,16 @@ 
                     pos = next
             yield closechunk()
 
-    def _unpackmanifests(self, repo, revmap, trp, prog, numchanges):
-        # We know that we'll never have more manifests than we had
-        # changesets.
-        self.callback = prog(_('manifests'), numchanges)
+    def _unpackmanifests(self, repo, revmap, trp, prog):
+        self.callback = prog.increment
         # no need to check for empty manifest group here:
         # if the result of the merge of 1 and 2 is the same in 3 and 4,
         # no new manifest will be created and the manifest group will
         # be empty during the pull
         self.manifestheader()
         deltas = self.deltaiter()
         repo.manifestlog._revlog.addgroup(deltas, revmap, trp)
-        repo.ui.progress(_('manifests'), None)
+        prog.update(None)
         self.callback = None
 
     def apply(self, repo, tr, srctype, url, targetphase=phases.draft,
@@ -293,16 +291,9 @@ 
             # pull off the changeset group
             repo.ui.status(_("adding changesets\n"))
             clstart = len(cl)
-            class prog(object):
-                def __init__(self, step, total):
-                    self._step = step
-                    self._total = total
-                    self._count = 1
-                def __call__(self):
-                    repo.ui.progress(self._step, self._count, unit=_('chunks'),
-                                     total=self._total)
-                    self._count += 1
-            self.callback = prog(_('changesets'), expectedtotal)
+            progress = repo.ui.makeprogress(_('changesets'), unit=_('chunks'),
+                                            total=expectedtotal)
+            self.callback = progress.increment
 
             efiles = set()
             def onchangelog(cl, node):
@@ -318,12 +309,16 @@ 
                                   config='warn-empty-changegroup')
             clend = len(cl)
             changesets = clend - clstart
-            repo.ui.progress(_('changesets'), None)
+            progress.update(None)
             self.callback = None
 
             # pull off the manifest group
             repo.ui.status(_("adding manifests\n"))
-            self._unpackmanifests(repo, revmap, trp, prog, changesets)
+            # We know that we'll never have more manifests than we had
+            # changesets.
+            progress = repo.ui.makeprogress(_('manifests'), unit=_('chunks'),
+                                            total=changesets)
+            self._unpackmanifests(repo, revmap, trp, progress)
 
             needfiles = {}
             if repo.ui.configbool('server', 'validate'):
@@ -475,9 +470,8 @@ 
         node, p1, p2, deltabase, cs, flags = headertuple
         return node, p1, p2, deltabase, cs, flags
 
-    def _unpackmanifests(self, repo, revmap, trp, prog, numchanges):
-        super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog,
-                                                  numchanges)
+    def _unpackmanifests(self, repo, revmap, trp, prog):
+        super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog)
         for chunkdata in iter(self.filelogheader, {}):
             # If we get here, there are directory manifests in the changegroup
             d = chunkdata["filename"]