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

login
register
mail settings
Submitter Ryan McElroy
Date Sept. 5, 2016, 10:35 a.m.
Message ID <d292469f5ce939d91eea.1473071728@devbig314.prn1.facebook.com>
Download mbox | patch
Permalink /patch/16551/
State Accepted
Headers show

Comments

Ryan McElroy - Sept. 5, 2016, 10:35 a.m.
# HG changeset patch
# User Ryan McElroy <rmcelroy@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.

Patch

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