[PATCH 1 of 2 hggit-ext] add progress to commit discovery phase

Ryan McElroy rm at fb.com
Mon Sep 5 06:35:28 EDT 2016


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1473069804 25200
#      Mon Sep 05 03:03:24 2016 -0700
# Node ID d292469f5ce939d91eea9020758d7d6e6f308e0f
# Parent  1fec6463922bba1193f3637b071bda88f2786cac
add progress to commit discovery phase

In large repositories, the commit discovery phase can take minutes. Let's give
the user feedback on how long it will take.

diff --git a/hggit/git_handler.py b/hggit/git_handler.py
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -411,13 +411,27 @@ class GitHandler(object):
     # CHANGESET CONVERSION METHODS
 
     def export_git_objects(self):
+        self.ui.note(_("finding hg commits to export\n"))
         repo = self.repo
         clnode = repo.changelog.node
+
         nodes = (clnode(n) for n in repo)
-        export = (repo[node] for node in nodes if not hex(node) in
+        to_export = (repo[node] for node in nodes if not hex(node) in
                   self._map_hg)
-        export = [ctx for ctx in export
-                  if ctx.extra().get('hg-git', None) != 'octopus']
+
+        todo_total = len(repo) - len(self._map_hg)
+        topic = 'find commits to export'
+        pos = 0
+        unit = 'commits'
+
+        export = []
+        for ctx in to_export:
+            item = hex(ctx.node())
+            pos += 1
+            repo.ui.progress(topic, pos, item, unit, todo_total)
+            if ctx.extra().get('hg-git', None) != 'octopus':
+                export.append(ctx)
+
         total = len(export)
         if not total:
             return


More information about the Mercurial-devel mailing list