The changes module now also outputs the progress when in text mode.

Furthermore, the output also shows the pass currently running. This is
important, as the progress goes from 0 to 100%, twice.
This commit is contained in:
Adam Waldenberg 2015-10-29 03:36:04 +01:00
parent ce91c4176a
commit d30715cc84
3 changed files with 12 additions and 2 deletions

View File

@ -119,7 +119,7 @@ class BlameThread(threading.Thread):
__thread_lock__.release() # Lock controlling the number of threads running
PROGRESS_TEXT = N_("Checking how many rows belong to each author (Progress): {0:.0f}%")
PROGRESS_TEXT = N_("Checking how many rows belong to each author (2 of 2): {0:.0f}%")
class Blame(object):
def __init__(self, hard, useweeks, changes):

View File

@ -23,7 +23,8 @@ import multiprocessing
import os
import subprocess
import threading
from . import extensions, filtering, interval
from .localization import N_
from . import extensions, filtering, format, interval, terminal
CHANGES_PER_THREAD = 200
NUM_THREADS = multiprocessing.cpu_count()
@ -167,6 +168,8 @@ class ChangesThread(threading.Thread):
__changes_lock__.release() # ...to here.
__thread_lock__.release() # Lock controlling the number of threads running
PROGRESS_TEXT = N_("Fetching and calculating primary statistics (1 of 2): {0:.0f}%")
class Changes(object):
authors = {}
authors_dateinfo = {}
@ -191,6 +194,9 @@ class Changes(object):
second_hash = entry
ChangesThread.create(hard, self, first_hash, second_hash, i)
first_hash = entry + ".."
if format.is_interactive_format():
terminal.output_progress(_(PROGRESS_TEXT), i, len(lines))
else:
entry = entry.decode("utf-8", "replace").strip()
second_hash = entry

View File

@ -20,6 +20,7 @@
from __future__ import print_function
from __future__ import unicode_literals
import json
import sys
import textwrap
from ..localization import N_
from .. import format, gravatar, terminal
@ -128,6 +129,9 @@ class ChangesOutput(Outputable):
print("\t\t\"exception\": \"" + _(NO_COMMITED_FILES_TEXT) + "\"")
def output_text(self):
if sys.stdout.isatty() and format.is_interactive_format():
terminal.clear_row()
authorinfo_list = self.changes.get_authorinfo_list()
total_changes = 0.0