Commit Graph

45 Commits

Author SHA1 Message Date
Augie Fackler
3aa5f557a5 progress: stop getting stuck in a nested topic during a long inner step
Convert, for example, has loops like this:
for revision in source_repo:
  progress(revisions)
  for file in revision:
    progresss(file)

Prior to this change, we would start showing the file-level progress
when we encountered a big revision, and then we'd get stuck in showing
file-progress instead of revision progress, often producing many many
instantly-completing progress bars rather than the actually-helpful
top-level revisions bar.
2013-08-23 13:28:18 -04:00
Matt Mackall
96ec634739 progress: respect HGPLAIN 2013-07-16 11:17:01 -05:00
Matt Mackall
d9056446c0 progress: use ui._isatty 2012-05-20 14:37:20 -05:00
Augie Fackler
96d44b39f7 hgext: mark all first-party extensions as such 2012-05-15 14:37:49 -05:00
Martin Geisler
1e5a14b6b5 progress: fix indentation 2012-05-11 18:41:04 +02:00
Augie Fackler
e218dbcfaf progress: Use the same GPL boilerplate as most hg files 2012-01-02 19:30:28 -06:00
David Soria Parra
900ed6b9a8 progress: check for ui.quiet and ui.debugflag before we write
ui.quiet and ui.debugflag are not initialized during uisetup and
reposetup.  progressui is always initialized, therefore we have to check
during write() if ui.quiet is set or not.
2011-12-14 15:41:08 +01:00
Augie Fackler
c679d5be7b progress: add a changedelay to prevent parallel topics from flapping (issue2698)
When combined with the earlier change to make the progress object
truly a singleton, this prevents the progress bar swapping on 'hg
clone --pull' on a local filesystem.

Thanks to timeless for lots of debugging help at the Copenhagen sprint
to isolate the root cause of this and a first draft an idea that would
fix it.
2011-06-23 15:00:45 -05:00
Augie Fackler
be415b3866 progress: make progress bar a singleton to avoid double-progress ui bugs
This helps issue2698 a little, but isn't a complete fix, since
generators still can produce some weird progress bar switching.
2011-06-23 14:55:09 -05:00
Augie Fackler
6842524caa progress: remove superfluous parens 2011-06-02 14:33:01 -05:00
Idan Kamara
02f21a70dc util: add helper function isatty(fd) to check for tty-ness 2011-06-02 00:43:34 +03:00
Martin Geisler
bb9f7dd3c5 progress: add speed format
This is not enabled by default, but the user can add it by setting
progress.format.

We might want to let the estimate format output a speed instead of an
ETA if there is not total. Currently estimate just returns the empty
string in that case.
2011-05-09 16:41:45 +02:00
Patrick Mezard
5f00d486d3 progress: remove useless statement left by 3e633b77d339 2011-05-07 17:25:12 +02:00
timeless
4f44952021 remove unused variables 2011-05-01 17:20:40 +02:00
timeless
ab34ee7694 remove unused imports 2011-05-01 15:21:57 +02:00
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