[PATCH] progress: add config knob to control delay before showing nested topics
Augie Fackler
durin42 at gmail.com
Tue Mar 1 01:16:56 UTC 2011
# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1292012724 21600
# Branch stable
# Node ID b0ff5859952bf537dfc91dd352bdd2cbf09cd412
# Parent 117990768fe0a2ed80e5c90505e31ce92e6172a5
progress: add config knob to control delay before showing nested topics
diff --git a/hgext/progress.py b/hgext/progress.py
--- a/hgext/progress.py
+++ b/hgext/progress.py
@@ -27,6 +27,7 @@
[progress]
delay = 3 # number of seconds (float) before showing the progress bar
+ nestdelay = 0.5 # time to wait before showing a nested progress topic
refresh = 0.1 # time in seconds between refreshes of the progress bar
format = topic bar number estimate # format of the progress bar
width = <none> # if set, the maximum width of the progress information
@@ -232,6 +233,14 @@
if topic in self.topics:
self.topics = self.topics[:self.topics.index(topic)]
else:
+ if self.topics:
+ if topic in self.pendingtopics:
+ if self.pendingtopics[topic] > time.time():
+ return
+ else:
+ self.pendingtopics[topic] = time.time() + float(
+ self.ui.config('progress', 'nestdelay', default=0.5))
+ return
if topic not in self.topics:
self.starttimes[topic] = now
self.startvals[topic] = pos
diff --git a/tests/test-convert-svn-move.t b/tests/test-convert-svn-move.t
--- a/tests/test-convert-svn-move.t
+++ b/tests/test-convert-svn-move.t
@@ -166,6 +166,7 @@
> progress =
> [progress]
> assume-tty = 1
+ > nestdelay = 0
> delay = 0
> format = topic bar number
> refresh = 0
diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -158,8 +158,9 @@
$ hg email -m test.mbox -f quux -t foo -c bar -s test 0:tip \
> --config extensions.progress= --config progress.assume-tty=1 \
- > --config progress.delay=0 --config progress.refresh=0
- This patch series consists of 2 patches.
+ > --config progress.delay=0 --config progress.refresh=0 \
+ > --config progress.nestdelay=0
+ \rwriting [ ] 0/3\rwriting [ ] 0/3\r \r\r \r\rwriting [====================> ] 1/3\rwriting [====================> ] 1/3\r \r\r \r\rwriting [==========================================> ] 2/3\rwriting [==========================================> ] 2/3\r \rThis patch series consists of 2 patches. (esc)
Write the introductory message for the patch series.
diff --git a/tests/test-progress.t b/tests/test-progress.t
--- a/tests/test-progress.t
+++ b/tests/test-progress.t
@@ -9,16 +9,24 @@
> total = loops
> if opts.get('total', None):
> total = int(opts.get('total'))
+ > nested = False
+ > if opts.get('nested', None):
+ > nested = True
> loops = abs(loops)
>
> for i in range(loops):
> ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total)
+ > if nested:
+ > for j in range(2):
+ > ui.progress('nested', j, 'nested.%d' % j, 'nestnum', 2)
+ > ui.progress('nested', None, 'nested.done', 'nestnum', 2)
> ui.progress('loop', None, 'loop.done', 'loopnum', total)
>
> commands.norepo += " loop"
>
> cmdtable = {
- > "loop": (loop, [('', 'total', '', 'override for total')],
+ > "loop": (loop, [('', 'total', '', 'override for total'),
+ > ('', 'nested', False, 'show nested results')],
> 'hg loop LOOPS'),
> }
> EOF
@@ -42,6 +50,16 @@
$ hg -y loop 3 2>&1 | $TESTDIR/filtercr.py
+ loop [ ] 0/3
+ loop [=====================> ] 1/3
+ loop [============================================> ] 2/3
+ \r (esc)
+
+
+test nested short-lived topics (which shouldn't display):
+
+ $ hg --config progress.nestdelay=100 -y loop 3 --nested 2>&1 | python filtercr.py
+
loop [ ] 0/3
loop [===============> ] 1/3
loop [===============================> ] 2/3
More information about the Mercurial-devel
mailing list