[Updated] [++- ] D8640: ui: add option to timestamp status and diagnostic messages
joerg.sonnenberger (Joerg Sonnenberger)
phabricator at mercurial-scm.org
Mon Jun 22 23:16:19 UTC 2020
joerg.sonnenberger updated this revision to Diff 21685.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8640?vs=21665&id=21685
BRANCH
stable
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8640/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8640
AFFECTED FILES
mercurial/configitems.py
mercurial/ui.py
tests/test-progress.t
tests/test-pull.t
CHANGE DETAILS
diff --git a/tests/test-pull.t b/tests/test-pull.t
--- a/tests/test-pull.t
+++ b/tests/test-pull.t
@@ -142,9 +142,9 @@
pulling from ssh://fakehost%7Ctouch%24%7BIFS%7Downed/path
abort: no suitable response from remote hg!
[255]
- $ hg pull 'ssh://fakehost%7Ctouch%20owned/path'
- pulling from ssh://fakehost%7Ctouch%20owned/path
- abort: no suitable response from remote hg!
+ $ hg --config ui.timestamp-output=true pull 'ssh://fakehost%7Ctouch%20owned/path'
+ \[20[2-9][0-9]-[01][0-9]-[0-3][0-9]T[0-5][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9]\] pulling from ssh://fakehost%7Ctouch%20owned/path (re)
+ \[20[2-9][0-9]-[01][0-9]-[0-3][0-9]T[0-5][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9]\] abort: no suitable response from remote hg! (re)
[255]
$ [ ! -f owned ] || echo 'you got owned'
diff --git a/tests/test-progress.t b/tests/test-progress.t
--- a/tests/test-progress.t
+++ b/tests/test-progress.t
@@ -18,7 +18,8 @@
> @command(b'loop',
> [(b'', b'total', b'', b'override for total'),
> (b'', b'nested', False, b'show nested results'),
- > (b'', b'parallel', False, b'show parallel sets of results')],
+ > (b'', b'parallel', False, b'show parallel sets of results'),
+ > (b'', b'warn', False, b'show warning if step divisible by 3')],
> b'hg loop LOOPS',
> norepo=True)
> def loop(ui, loops, **opts):
@@ -32,6 +33,7 @@
> if opts.get('nested', None):
> nested = True
> loops = abs(loops)
+ > showwarn = opts.get('warn', False)
>
> progress = ui.makeprogress(topiclabel, unit=b'loopnum', total=total)
> other = ui.makeprogress(b'other', unit=b'othernum', total=total)
@@ -48,6 +50,8 @@
> for j in range(nested_steps):
> nested.update(j, item=b'nested.%d' % j)
> nested.complete()
+ > if showwarn and i % 3 == 0:
+ > ui.warn(b'reached step %d\n' %i)
> progress.complete()
>
> topiclabel = b'loop'
@@ -179,6 +183,42 @@
loop [ <=> ] 5/4\r (no-eol) (esc)
\r (no-eol) (esc)
+test interaction with ui.warn
+
+ $ hg loop --warn 6
+ \r (no-eol) (esc)
+ loop [ ] 0/6\r (no-eol) (esc)
+ \r (no-eol) (esc)
+ reached step 0
+ \r (no-eol) (esc)
+ loop [=======> ] 1/6\r (no-eol) (esc)
+ loop [===============> ] 2/6\r (no-eol) (esc)
+ loop [=======================> ] 3/6\r (no-eol) (esc)
+ \r (no-eol) (esc)
+ reached step 3
+ \r (no-eol) (esc)
+ loop [===============================> ] 4/6\r (no-eol) (esc)
+ loop [=======================================> ] 5/6\r (no-eol) (esc)
+ \r (no-eol) (esc)
+
+test interaction with ui.timestamp-output
+
+ $ hg loop --warn --config ui.timestamp-output=true 6
+ \r (no-eol) (esc)
+ loop [ ] 0/6\r (no-eol) (esc)
+ \r (no-eol) (esc)
+ \[20[2-9][0-9]-[01][0-9]-[0-3][0-9]T[0-5][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9]\] reached step 0 (re)
+ \r (no-eol) (esc)
+ loop [=======> ] 1/6\r (no-eol) (esc)
+ loop [===============> ] 2/6\r (no-eol) (esc)
+ loop [=======================> ] 3/6\r (no-eol) (esc)
+ \r (no-eol) (esc)
+ \[20[2-9][0-9]-[01][0-9]-[0-3][0-9]T[0-5][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9]\] reached step 3 (re)
+ \r (no-eol) (esc)
+ loop [===============================> ] 4/6\r (no-eol) (esc)
+ loop [=======================================> ] 5/6\r (no-eol) (esc)
+ \r (no-eol) (esc)
+
test immediate progress completion
$ hg -y loop 0
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -9,6 +9,7 @@
import collections
import contextlib
+import datetime
import errno
import getpass
import inspect
@@ -242,6 +243,7 @@
self._terminfoparams = {}
self._styles = {}
self._uninterruptible = False
+ self.showtimestamp = False
if src:
self._fout = src._fout
@@ -561,6 +563,7 @@
self._reportuntrusted = self.debugflag or self.configbool(
b"ui", b"report_untrusted"
)
+ self.showtimestamp = self.configbool(b'ui', b'timestamp-output')
self.tracebackflag = self.configbool(b'ui', b'traceback')
self.logblockedtimes = self.configbool(b'ui', b'logblockedtimes')
@@ -1217,7 +1220,12 @@
) * 1000
def _writemsg(self, dest, *args, **opts):
+ timestamp = opts.pop('timestamp', False)
+ if timestamp:
+ args = (b'[%s] ' % bytes(datetime.datetime.now().isoformat(), 'ASCII'),) + args
_writemsgwith(self._write, dest, *args, **opts)
+ if timestamp:
+ dest.flush()
def _writemsgnobuf(self, dest, *args, **opts):
_writemsgwith(self._writenobuf, dest, *args, **opts)
@@ -1726,21 +1734,21 @@
This adds an output label of "ui.status".
'''
if not self.quiet:
- self._writemsg(self._fmsgout, type=b'status', *msg, **opts)
+ self._writemsg(self._fmsgout, type=b'status', timestamp=self.showtimestamp, *msg, **opts)
def warn(self, *msg, **opts):
'''write warning message to output (stderr)
This adds an output label of "ui.warning".
'''
- self._writemsg(self._fmsgerr, type=b'warning', *msg, **opts)
+ self._writemsg(self._fmsgerr, type=b'warning', timestamp=self.showtimestamp, *msg, **opts)
def error(self, *msg, **opts):
'''write error message to output (stderr)
This adds an output label of "ui.error".
'''
- self._writemsg(self._fmsgerr, type=b'error', *msg, **opts)
+ self._writemsg(self._fmsgerr, type=b'error', timestamp=self.showtimestamp, *msg, **opts)
def note(self, *msg, **opts):
'''write note to output (if ui.verbose is True)
@@ -1748,7 +1756,7 @@
This adds an output label of "ui.note".
'''
if self.verbose:
- self._writemsg(self._fmsgout, type=b'note', *msg, **opts)
+ self._writemsg(self._fmsgout, type=b'note', timestamp=self.showtimestamp, *msg, **opts)
def debug(self, *msg, **opts):
'''write debug message to output (if ui.debugflag is True)
@@ -1756,7 +1764,7 @@
This adds an output label of "ui.debug".
'''
if self.debugflag:
- self._writemsg(self._fmsgout, type=b'debug', *msg, **opts)
+ self._writemsg(self._fmsgout, type=b'debug', timestamp=self.showtimestamp, *msg, **opts)
self.log(b'debug', b'%s', b''.join(msg))
# Aliases to defeat check-code.
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1391,6 +1391,9 @@
b'ui', b'timeout.warn', default=0,
)
coreconfigitem(
+ b'ui', b'timestamp-output', default=False,
+)
+coreconfigitem(
b'ui', b'traceback', default=False,
)
coreconfigitem(
To: joerg.sonnenberger, #hg-reviewers
Cc: durin42, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200622/6aef8d3d/attachment-0002.html>
More information about the Mercurial-patches
mailing list