Patchwork [2,of,5] convert: add support for deterministic progress bar on scanning phase

login
register
mail settings
Submitter Augie Fackler
Date Sept. 10, 2014, 3:20 p.m.
Message ID <29cd01c8094fae8b6527.1410362458@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/5765/
State Accepted
Headers show

Comments

Augie Fackler - Sept. 10, 2014, 3:20 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1401119592 14400
#      Mon May 26 11:53:12 2014 -0400
# Node ID 29cd01c8094fae8b6527e840f2ac5ed403948e5f
# Parent  784621fa05df9872c27bc2ff589a24622afab800
convert: add support for deterministic progress bar on scanning phase

This makes it possible to estimate how long the "scanning source"
phase will take, if the specified source repo type supports a quick
"how many changes" check.

Patch

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -109,6 +109,13 @@ 
         """Return the commit object for version"""
         raise NotImplementedError
 
+    def numcommits(self):
+        """Return the number of commits in this source.
+
+        If unknown, return None.
+        """
+        return None
+
     def gettags(self):
         """Return the tags as a dictionary of name: revision
 
diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -171,6 +171,7 @@ 
         visit = heads
         known = set()
         parents = {}
+        numcommits = self.source.numcommits()
         while visit:
             n = visit.pop(0)
             if n in known:
@@ -180,7 +181,8 @@ 
                 if m == SKIPREV or self.dest.hascommitfrommap(m):
                     continue
             known.add(n)
-            self.ui.progress(_('scanning'), len(known), unit=_('revisions'))
+            self.ui.progress(_('scanning'), len(known), unit=_('revisions'),
+                             total=numcommits)
             commit = self.cachecommit(n)
             parents[n] = []
             for p in commit.parents: