Patchwork [2,of,3,V2] addchangegroup: accept an expected total number of changesets as argument

login
register
mail settings
Submitter Pierre-Yves David
Date June 10, 2015, 6:53 p.m.
Message ID <469c882dc9b84a5bc6c7.1433962417@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9585/
State Accepted
Headers show

Comments

Pierre-Yves David - June 10, 2015, 6:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1433717860 25200
#      Sun Jun 07 15:57:40 2015 -0700
# Node ID 469c882dc9b84a5bc6c7edbf768fd634cd43bc4c
# Parent  cf92b2231b86fe348fcce33d6554df7330384eef
addchangegroup: accept an expected total number of changesets as argument

Caller can optionally informs how much changesets are expected to be added. This
will be used for a more useful progress bar output.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -693,11 +693,11 @@  def addchangegroupfiles(repo, source, re
                     (f, hex(n)))
 
     return revisions, files
 
 def addchangegroup(repo, source, srctype, url, emptyok=False,
-                   targetphase=phases.draft):
+                   targetphase=phases.draft, expectedtotal=None):
     """Add the changegroup returned by source.read() to this repo.
     srctype is a string like 'push', 'pull', or 'unbundle'.  url is
     the URL of the repo where this changegroup is coming from.
 
     Return an integer summarizing the change to this repo:
@@ -742,11 +742,11 @@  def addchangegroup(repo, source, srctype
         clstart = len(cl)
         class prog(object):
             step = _('changesets')
             count = 1
             ui = repo.ui
-            total = None
+            total = expectedtotal
             def __call__(repo):
                 repo.ui.progress(repo.step, repo.count, unit=_('chunks'),
                                  total=repo.total)
                 repo.count += 1
         pr = prog()