Commit Graph

30 Commits

Author SHA1 Message Date
timeless
1df4cf63b6 progress: handle days, weeks and years
using hg clone svn://anonsvn.kde.org/home/kde/trunk kde ... with progress
yields 3008/1210830 1314h56m, which is unusable.

Add code to switch to days at 30 hours, to weeks at 15 days, and to years
at 55 weeks. A day has 24 hours, a week has 7 days, and a year has 52 weeks.
Months are intentionally omitted because they do not have a fixed length. The
Use of 52 weeks is a known and understandable estimate for a year.

It might make sense to spell our year to alert people when progress is
impractical, but...
2011-01-02 18:51:59 +02:00
Augie Fackler
fe6b4b14cf progress: don't compute estimate without a total
Without this, computing an estimate crashes. Test included.
2010-12-16 07:45:22 -06:00
Augie Fackler
718b098522 progress: include time estimate as part of the default progress format 2010-12-15 10:22:54 -06:00
Augie Fackler
1e552d096f progress: only show time estimate when progress format contains 'estimate' 2010-12-15 10:22:06 -06:00
Augie Fackler
5d0aeb403a progress: fix adding format elements after the progress bar
Prior to this change, format elements after the progress bar would
show up in the wrong order.
2010-12-15 10:20:36 -06:00
Martin Geisler
14b25d1759 progress: explain format strings to translators 2010-12-15 09:35:32 +01:00
Augie Fackler
765100989d progress: refactor for readability and show XXs instead of 0mXXs. 2010-12-09 17:33:40 -06:00
timeless
103026042f progress: Add estimated time remaining for long tasks
Output looks roughly like this:
updating [======================>                       ] 1547/4842 0m13s

output will either show h:m or m:s
2010-10-26 14:41:58 +03:00
Augie Fackler
caa25014d3 progress: react more reasonably to nested progress topics
Previously, we'd reset the entire progress bar state when a topic was
completed, even if it wasn't the outermost progress topic. Now we
print the state of the next progress topic on the stack if one is left
rather than reset the progress bar.
2010-12-10 16:56:12 -06:00
Augie Fackler
42c8b2cf07 termwidth: move to ui.ui from util 2010-10-10 10:06:36 -05:00
Augie Fackler
07c793d057 progress: make sure stderr has isatty before calling (issue2191) 2010-10-09 09:55:52 -05:00
Brodie Rao
6f58bfc15e color/progress: subclass ui instead of using wrapfunction (issue2096)
This resolves the issue of hg cmd --mq not being colorized. This was due
to color wrapping only the instance of ui passed to dispatch._runcommand(),
which isn't the same ui object that mq.mqcommand() receives. After dispatch
calls extensions.loadall(), it makes sure any changes to ui.__class__ in
uisetup are propagated.

progress is updated to wrap ui in the same manner because wrapfunction
doesn't play well when ui.__class__ has been replaced by another extension
(orig will point to the old class method instead of color's).
2010-07-01 19:23:26 -05:00
Augie Fackler
be26c0a474 progress: check stderr.isatty() before each print
This prevents writing progress information to a non-tty stderr if one is
swapped in after startup, which happens in `hg serve`.
2010-06-27 22:20:47 -05:00
Augie Fackler
8d7cb15f33 progress: fall back to indeterminate progress if position is >= total 2010-04-08 15:04:00 -05:00
Brodie Rao
9a7e3ba689 ui: add ui.write() output labeling API
This adds output labeling support with the following methods:

- ui.write(..., label='topic.name topic2.name2 ...')
- ui.write_err(.., label=...)
- ui.popbuffer(labeled=False)
- ui.label(msg, label)

By adding an API to label output directly, the color extension can forgo
parsing command output and instead override the above methods to insert
ANSI color codes. GUI tools can also override the above methods and use
the labels to do GUI-specific styling.

popbuffer gains a labeled argument that, when set to True, returns its
buffered output with labels handled. In the case of the color extension,
this would return output with color codes embedded. For existing users
that use this method to capture and parse output, labels are discarded
and output returned as normal when labeled is False (the default).

Existing wrappers of ui.write() and ui.write_err() should make sure to
accept its new **opts argument.
2010-04-02 15:22:00 -05:00
Augie Fackler
eeb8822ee1 progress: use stderr instead of stdout; check stderr.isatty()
This means that progress bars will continue to show on the terminal
when both stdin and stdout are redirected.
2010-03-29 16:44:24 -05:00
Augie Fackler
b3f787c2e6 progress: document progress.disable config option 2010-03-11 16:54:34 -06:00
Benoit Boissinot
5b98d49b1f progress: clear progress before writing to stderr 2010-03-06 13:32:14 +01:00
Steve Borho
9309ff3d0c progress: provide an explicit disable method for developers
The other three checks for disabling the progress bar have serious
side effects for any class that derives from ui.ui()
2010-02-23 23:10:01 -06:00
Ronny Pfannschmidt
4e6e8c7c75 make the progress extension honor ui.quiet 2010-02-21 15:26:55 +01:00
Martin Geisler
f60d955070 progress: use inline literals in help string 2010-02-14 17:09:52 +01:00
Patrick Mezard
cdb100ac42 progress: make progress.refresh=0 always display the progress line
This has no effect in real world where progress.refresh in unlikely to be set
to zero, but is very useful in tests where all progress output is to be traced.
It failed on platforms with coarse time.time() granularity, like Windows+py25.
2010-02-14 15:42:47 +01:00
Brodie Rao
892ba5a830 remove unused imports 2010-02-14 01:52:31 -05:00
Patrick Mezard
c4cbe25bb9 progress: make use of progress.refresh 2010-02-14 13:58:30 +01:00
Brodie Rao
3a1961dd4f progress: make determinate bar more like wget progress bar
foo [                                                          ]  0/58
foo [>                                                         ]  1/58
foo [=>                                                        ]  2/58
...
foo [=======================================================>  ] 56/58
foo [========================================================> ] 57/58
foo [=========================================================>] 58/58

The bar now has a '>' character at the end. This indicates the direction,
is consistent with the indeterminate '<=>' bar, and looks much nicer.
2010-02-13 23:34:15 -05:00
Brodie Rao
1b6c146296 progress: simplify spacejoin() 2010-02-13 23:34:20 -05:00
timeless
6562078e97 progress: fix description 2010-02-14 00:46:13 +02:00
Augie Fackler
e22247c3bb progress: only reset state if finishing progress for the current topic
This prevents some visual glitches when doing a clone --pull locally.
2010-02-13 09:49:06 -06:00
Benoit Boissinot
0bb91a20fe progress: correctly handle empty progress topic 2010-02-13 09:55:28 +01:00
Augie Fackler
a30e3bd4a9 Progress bar extension 2010-02-12 21:53:32 -06:00