Mercurial > hg
annotate mercurial/progress.py @ 25563:69e8384a436c
fancyopts: allow all callable as default parameter value
The current fancyopts allows function as default parameter value
but not other callables.
By supporting other callables, we can have the benefits of e.g.,
custom __str__ method, which will be printed by 'hg help' as
the default value.
author | introom <i@introo.me> |
---|---|
date | Thu, 11 Jun 2015 08:54:24 -0400 |
parents | 93b8b0049932 |
children | 79c75459321e |
rev | line source |
---|---|
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 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
8 import sys |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
9 import time |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
10 import threading |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
11 from mercurial import encoding |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
12 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
13 from mercurial.i18n import _ |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
14 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
15 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
16 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
|
17 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
|
18 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
19 def shouldprint(ui): |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
20 return not ui.plain() and (ui._isatty(sys.stderr) or |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
21 ui.configbool('progress', 'assume-tty')) |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
22 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
23 def fmtremaining(seconds): |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
24 """format a number of remaining seconds in humain readable way |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
25 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
26 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
|
27 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
|
28 # 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 # 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
|
34 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
|
35 # 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
|
36 minutes += 1 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 # 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
|
41 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
|
42 # 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
|
43 hours += 1 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
44 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
|
45 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
|
46 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
|
47 # 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
|
48 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
|
49 # 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
|
50 days += 1 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 # 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
|
55 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
|
56 # 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
|
57 weeks += 1 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
58 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
|
59 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
|
60 # 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
|
61 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
|
62 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 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
|
67 self.resetstate() |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
68 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
69 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
|
70 self.topics = [] |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
71 self.topicstates = {} |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
72 self.starttimes = {} |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
73 self.startvals = {} |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
74 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
|
75 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
|
76 '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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 '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
|
82 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
|
83 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
|
84 '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
|
85 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
|
86 'progress', 'format', |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
87 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
|
88 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
89 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
|
90 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
|
91 return |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
92 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
|
93 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
|
94 head = '' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
95 needprogress = False |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
96 tail = '' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
97 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
|
98 add = '' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
99 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
|
100 add = topic |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
101 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
|
102 if total: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
103 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
|
104 '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
|
105 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
106 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
|
107 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
|
108 slice = 'end' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
109 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
|
110 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
|
111 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
|
112 slice = 'beginning' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
113 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
|
114 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
115 wid = 20 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
116 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
|
117 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
|
118 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 add = '' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
123 needprogress = True |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
124 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
|
125 add = unit |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
133 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
|
134 if needprogress: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
135 used = 0 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
136 if head: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
137 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
|
138 if tail: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
139 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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 bar += '>' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
146 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
|
147 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
148 progwidth -= 3 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
149 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
|
150 # 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
|
151 # 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
|
152 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
|
153 amt -= progwidth |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
154 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
|
155 ' ' * 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
|
156 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
|
157 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
|
158 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
159 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
|
160 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
|
161 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
|
162 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
|
163 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
164 def clear(self): |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
165 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
|
166 return |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
167 sys.stderr.write('\r%s\r' % (' ' * self.width())) |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
168 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
169 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
|
170 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
|
171 return |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
172 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
|
173 self.clear() |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
174 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
175 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
|
176 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
|
177 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
178 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
|
179 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
|
180 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
|
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 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
|
183 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
|
184 return '' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 return '' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
195 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 return '' |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
204 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
205 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
|
206 '''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
|
207 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
|
208 # 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
|
209 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
|
210 # 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
|
211 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
|
212 return True |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
213 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
214 return False |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
215 |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
216 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
|
217 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
|
218 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
|
219 try: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 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
|
224 # 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
|
225 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
|
226 self.complete() |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
227 self.resetstate() |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
228 # 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
|
229 # 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
|
230 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
|
231 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
|
232 # 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
|
233 # 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
|
234 # 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
|
235 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
|
236 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
|
237 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
238 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
|
239 else: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 finally: |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
251 self._refreshlock.release() |
93b8b0049932
progress: move most extension code into a 'mercurial.progress' module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
252 |