Skip to content

Commit

Permalink
redo-log: sometimes print a (resumed) line after ending a level of re…
Browse files Browse the repository at this point in the history
…cursion.

If A calls B, and B produces stderr output, and then A wants to produce
output, the resulting log would be confusing: we'd see 'redo A' and
then 'redo B' and then B's output, but no indicator that B has ended
and we're back in A.  Now we show 'redo A (resumed)' before A's output.

If B didn't produce any output, or A doesn't produce any output, we
don't bother with the (resumed) line.  This seems nice, as it doesn't
clutter the log when there is no ambiguity anyway.
  • Loading branch information
apenwarr committed Mar 3, 2019
1 parent b196315 commit cead02b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 21 additions & 3 deletions redo/cmd_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ def catlog(t):
Note: this function's behaviour depends on global command-line options.
"""
global total_lines, status
lines_written = 0
interrupted = 0
if t in already:
return
return 0
if t != '-':
depth.append(t)
_fix_depth()
Expand Down Expand Up @@ -178,32 +180,47 @@ def catlog(t):
if opt.recursive:
if loglock:
loglock.unlock()
catlog(os.path.join(mydir, text))
got = catlog(os.path.join(mydir, text))
interrupted += got
lines_written += got
if loglock:
loglock.waitlock(shared=True)
already.add(fixname)
elif kind in ('do', 'waiting', 'locked', 'unlocked'):
if opt.debug_locks:
logs.meta(kind, relname, pid=pid)
logs.write(line.rstrip())
lines_written += 1
elif fixname not in already:
logs.meta('do', relname, pid=pid)
lines_written += 1
if opt.recursive:
assert text
if loglock:
loglock.unlock()
catlog(os.path.join(mydir, text))
got = catlog(os.path.join(mydir, text))
interrupted += got
lines_written += got
if loglock:
loglock.waitlock(shared=True)
already.add(fixname)
elif kind == 'done':
rv, name = text.split(' ', 1)
logs.meta(kind, rv + ' ' + _rel(topdir, mydir, name))
lines_written += 1
else:
logs.write(line.rstrip())
lines_written += 1
else:
if opt.details:
if interrupted:
d = env.v.DEPTH
env.v.DEPTH = env.v.DEPTH[:-2]
logs.meta('resumed', t)
env.v.DEPTH = d
interrupted = 0
logs.write(line.rstrip())
lines_written += 1
if loglock:
loglock.unlock()
if status:
Expand All @@ -217,6 +234,7 @@ def catlog(t):
assert depth[-1] == t
depth.pop(-1)
_fix_depth()
return lines_written


def main():
Expand Down
2 changes: 2 additions & 0 deletions redo/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def write(self, s):
elif env.v.VERBOSE or env.v.XTRACE or env.v.DEBUG:
self._pretty(pid, GREEN, '%s (done)' % name)
self.file.write('\n')
elif kind == 'resumed':
self._pretty(pid, GREEN, '%s (resumed)' % text)
elif kind == 'locked':
if env.v.DEBUG_LOCKS:
self._pretty(pid, GREEN, '%s (locked...)' % text)
Expand Down

0 comments on commit cead02b

Please sign in to comment.