mercurial/progress.py
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 15 Oct 2016 17:10:53 -0700
changeset 30177 9626022feaa4
parent 29089 222b8170d69e
child 30324 cb1ea3cc44b5
permissions -rw-r--r--
bundle2: only emit compressed chunks if they have data This is similar to 58467204cac0. Not all calls into the compressor return compressed data, as the compressor may buffer compressed output internally. It is cheaper to check for empty chunks than to send empty chunks through the generator. When generating a gzip-v2 bundle of the mozilla-unified repo, this change results in 50,093 empty chunks not being sent through the generator (out of 1,902,996 total input chunks).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25497
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     1
# progress.py progress bars related code
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     2
#
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     3
# Copyright (C) 2010 Augie Fackler <durin42@gmail.com>
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     4
#
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     7
25968
1139d7cf9405 progress: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25847
diff changeset
     8
from __future__ import absolute_import
1139d7cf9405 progress: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25847
diff changeset
     9
25497
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    10
import sys
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    11
import threading
25968
1139d7cf9405 progress: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25847
diff changeset
    12
import time
25497
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    13
25968
1139d7cf9405 progress: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25847
diff changeset
    14
from .i18n import _
1139d7cf9405 progress: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25847
diff changeset
    15
from . import encoding
25497
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    16
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    17
def spacejoin(*args):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    18
    return ' '.join(s for s in args if s)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    19
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    20
def shouldprint(ui):
28171
2d20d1d2ea76 progress: display progress bar when HGPLAINEXCEPT contains "progress"
Matt Anderson <andersonmat@fb.com>
parents: 26781
diff changeset
    21
    return not (ui.quiet or ui.plain('progress')) and (
25581
79c75459321e progress: respect ui.quiet (issue4726)
Augie Fackler <augie@google.com>
parents: 25497
diff changeset
    22
        ui._isatty(sys.stderr) or ui.configbool('progress', 'assume-tty'))
25497
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    23
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    24
def fmtremaining(seconds):
26781
1aee2ab0f902 spelling: trivial spell checking
Mads Kiilerich <madski@unity3d.com>
parents: 26407
diff changeset
    25
    """format a number of remaining seconds in human readable way
25497
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    26
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    27
    This will properly display seconds, minutes, hours, days if needed"""
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    28
    if seconds < 60:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    29
        # i18n: format XX seconds as "XXs"
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    30
        return _("%02ds") % (seconds)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    31
    minutes = seconds // 60
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    32
    if minutes < 60:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    33
        seconds -= minutes * 60
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    34
        # i18n: format X minutes and YY seconds as "XmYYs"
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    35
        return _("%dm%02ds") % (minutes, seconds)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    36
    # we're going to ignore seconds in this case
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    37
    minutes += 1
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    38
    hours = minutes // 60
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    39
    minutes -= hours * 60
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    40
    if hours < 30:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    41
        # i18n: format X hours and YY minutes as "XhYYm"
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    42
        return _("%dh%02dm") % (hours, minutes)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    43
    # we're going to ignore minutes in this case
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    44
    hours += 1
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    45
    days = hours // 24
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    46
    hours -= days * 24
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    47
    if days < 15:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    48
        # i18n: format X days and YY hours as "XdYYh"
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    49
        return _("%dd%02dh") % (days, hours)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    50
    # we're going to ignore hours in this case
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    51
    days += 1
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    52
    weeks = days // 7
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    53
    days -= weeks * 7
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    54
    if weeks < 55:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    55
        # i18n: format X weeks and YY days as "XwYYd"
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    56
        return _("%dw%02dd") % (weeks, days)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    57
    # we're going to ignore days and treat a year as 52 weeks
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    58
    weeks += 1
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    59
    years = weeks // 52
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    60
    weeks -= years * 52
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    61
    # i18n: format X years and YY weeks as "XyYYw"
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    62
    return _("%dy%02dw") % (years, weeks)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    63
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    64
class progbar(object):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    65
    def __init__(self, ui):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    66
        self.ui = ui
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    67
        self._refreshlock = threading.Lock()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    68
        self.resetstate()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    69
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    70
    def resetstate(self):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    71
        self.topics = []
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    72
        self.topicstates = {}
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    73
        self.starttimes = {}
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    74
        self.startvals = {}
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    75
        self.printed = False
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    76
        self.lastprint = time.time() + float(self.ui.config(
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    77
            'progress', 'delay', default=3))
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    78
        self.curtopic = None
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    79
        self.lasttopic = None
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    80
        self.indetcount = 0
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    81
        self.refresh = float(self.ui.config(
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    82
            'progress', 'refresh', default=0.1))
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    83
        self.changedelay = max(3 * self.refresh,
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    84
                               float(self.ui.config(
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    85
                                   'progress', 'changedelay', default=1)))
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    86
        self.order = self.ui.configlist(
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    87
            'progress', 'format',
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    88
            default=['topic', 'bar', 'number', 'estimate'])
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    89
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    90
    def show(self, now, topic, pos, item, unit, total):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    91
        if not shouldprint(self.ui):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    92
            return
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    93
        termwidth = self.width()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    94
        self.printed = True
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    95
        head = ''
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    96
        needprogress = False
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    97
        tail = ''
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    98
        for indicator in self.order:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    99
            add = ''
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   100
            if indicator == 'topic':
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   101
                add = topic
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   102
            elif indicator == 'number':
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   103
                if total:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   104
                    add = ('% ' + str(len(str(total))) +
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   105
                           's/%s') % (pos, total)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   106
                else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   107
                    add = str(pos)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   108
            elif indicator.startswith('item') and item:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   109
                slice = 'end'
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   110
                if '-' in indicator:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   111
                    wid = int(indicator.split('-')[1])
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   112
                elif '+' in indicator:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   113
                    slice = 'beginning'
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   114
                    wid = int(indicator.split('+')[1])
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   115
                else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   116
                    wid = 20
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   117
                if slice == 'end':
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   118
                    add = encoding.trim(item, wid, leftside=True)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   119
                else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   120
                    add = encoding.trim(item, wid)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   121
                add += (wid - encoding.colwidth(add)) * ' '
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   122
            elif indicator == 'bar':
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   123
                add = ''
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   124
                needprogress = True
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   125
            elif indicator == 'unit' and unit:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   126
                add = unit
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   127
            elif indicator == 'estimate':
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   128
                add = self.estimate(topic, pos, total, now)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   129
            elif indicator == 'speed':
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   130
                add = self.speed(topic, pos, unit, now)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   131
            if not needprogress:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   132
                head = spacejoin(head, add)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   133
            else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   134
                tail = spacejoin(tail, add)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   135
        if needprogress:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   136
            used = 0
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   137
            if head:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   138
                used += encoding.colwidth(head) + 1
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   139
            if tail:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   140
                used += encoding.colwidth(tail) + 1
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   141
            progwidth = termwidth - used - 3
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   142
            if total and pos <= total:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   143
                amt = pos * progwidth // total
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   144
                bar = '=' * (amt - 1)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   145
                if amt > 0:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   146
                    bar += '>'
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   147
                bar += ' ' * (progwidth - amt)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   148
            else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   149
                progwidth -= 3
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   150
                self.indetcount += 1
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   151
                # mod the count by twice the width so we can make the
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   152
                # cursor bounce between the right and left sides
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   153
                amt = self.indetcount % (2 * progwidth)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   154
                amt -= progwidth
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   155
                bar = (' ' * int(progwidth - abs(amt)) + '<=>' +
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   156
                       ' ' * int(abs(amt)))
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   157
            prog = ''.join(('[', bar , ']'))
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   158
            out = spacejoin(head, prog, tail)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   159
        else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   160
            out = spacejoin(head, tail)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   161
        sys.stderr.write('\r' + encoding.trim(out, termwidth))
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   162
        self.lasttopic = topic
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   163
        sys.stderr.flush()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   164
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   165
    def clear(self):
29089
222b8170d69e progress: stop excessive clearing (issue4801)
Matt Mackall <mpm@selenic.com>
parents: 28171
diff changeset
   166
        if not self.printed or not self.lastprint or not shouldprint(self.ui):
25497
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   167
            return
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   168
        sys.stderr.write('\r%s\r' % (' ' * self.width()))
26407
72bccc1f26b1 progress: force a repaint of a printed progress bar after a clear()
Augie Fackler <augie@google.com>
parents: 25968
diff changeset
   169
        if self.printed:
72bccc1f26b1 progress: force a repaint of a printed progress bar after a clear()
Augie Fackler <augie@google.com>
parents: 25968
diff changeset
   170
            # force immediate re-paint of progress bar
72bccc1f26b1 progress: force a repaint of a printed progress bar after a clear()
Augie Fackler <augie@google.com>
parents: 25968
diff changeset
   171
            self.lastprint = 0
25497
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   172
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   173
    def complete(self):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   174
        if not shouldprint(self.ui):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   175
            return
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   176
        if self.ui.configbool('progress', 'clear-complete', default=True):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   177
            self.clear()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   178
        else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   179
            sys.stderr.write('\n')
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   180
        sys.stderr.flush()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   181
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   182
    def width(self):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   183
        tw = self.ui.termwidth()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   184
        return min(int(self.ui.config('progress', 'width', default=tw)), tw)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   185
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   186
    def estimate(self, topic, pos, total, now):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   187
        if total is None:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   188
            return ''
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   189
        initialpos = self.startvals[topic]
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   190
        target = total - initialpos
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   191
        delta = pos - initialpos
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   192
        if delta > 0:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   193
            elapsed = now - self.starttimes[topic]
25847
56674fd6dabc progress: mark experimental option
Matt Mackall <mpm@selenic.com>
parents: 25581
diff changeset
   194
            # experimental config: progress.estimate
25497
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   195
            if elapsed > float(
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   196
                self.ui.config('progress', 'estimate', default=2)):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   197
                seconds = (elapsed * (target - delta)) // delta + 1
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   198
                return fmtremaining(seconds)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   199
        return ''
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   200
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   201
    def speed(self, topic, pos, unit, now):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   202
        initialpos = self.startvals[topic]
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   203
        delta = pos - initialpos
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   204
        elapsed = now - self.starttimes[topic]
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   205
        if elapsed > float(
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   206
            self.ui.config('progress', 'estimate', default=2)):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   207
            return _('%d %s/sec') % (delta / elapsed, unit)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   208
        return ''
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   209
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   210
    def _oktoprint(self, now):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   211
        '''Check if conditions are met to print - e.g. changedelay elapsed'''
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   212
        if (self.lasttopic is None # first time we printed
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   213
            # not a topic change
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   214
            or self.curtopic == self.lasttopic
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   215
            # it's been long enough we should print anyway
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   216
            or now - self.lastprint >= self.changedelay):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   217
            return True
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   218
        else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   219
            return False
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   220
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   221
    def progress(self, topic, pos, item='', unit='', total=None):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   222
        now = time.time()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   223
        self._refreshlock.acquire()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   224
        try:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   225
            if pos is None:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   226
                self.starttimes.pop(topic, None)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   227
                self.startvals.pop(topic, None)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   228
                self.topicstates.pop(topic, None)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   229
                # reset the progress bar if this is the outermost topic
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   230
                if self.topics and self.topics[0] == topic and self.printed:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   231
                    self.complete()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   232
                    self.resetstate()
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   233
                # truncate the list of topics assuming all topics within
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   234
                # this one are also closed
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   235
                if topic in self.topics:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   236
                    self.topics = self.topics[:self.topics.index(topic)]
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   237
                    # reset the last topic to the one we just unwound to,
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   238
                    # so that higher-level topics will be stickier than
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   239
                    # lower-level topics
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   240
                    if self.topics:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   241
                        self.lasttopic = self.topics[-1]
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   242
                    else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   243
                        self.lasttopic = None
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   244
            else:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   245
                if topic not in self.topics:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   246
                    self.starttimes[topic] = now
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   247
                    self.startvals[topic] = pos
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   248
                    self.topics.append(topic)
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   249
                self.topicstates[topic] = pos, item, unit, total
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   250
                self.curtopic = topic
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   251
                if now - self.lastprint >= self.refresh and self.topics:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   252
                    if self._oktoprint(now):
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   253
                        self.lastprint = now
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   254
                        self.show(now, topic, *self.topicstates[topic])
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   255
        finally:
93b8b0049932 progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
   256
            self._refreshlock.release()