fastlog: show all hg log output even if fastlog request failed

Summary:
We had a few troubles where fastlog failed with a weird error and people got
incorrect log output. While I still don't know why fastlog failed in the first
place, I've found the reason why log output was truncated. And this diff fixes
it. See the comments in the code for details.

Test Plan: Run unit-test

Reviewers: #fbhgext, simonfar

Reviewed By: #fbhgext, simonfar

Subscribers: simonfar

Differential Revision: https://phab.mercurial-scm.org/D193
This commit is contained in:
Stanislau Hlebik 2017-07-31 00:58:55 -07:00
parent 6203a99ed4
commit b88304992e
2 changed files with 29 additions and 2 deletions

View File

@ -486,8 +486,17 @@ class FastLogThread(Thread):
if self.stopped():
break
self.queue.put((self.id, True, rev))
self.queue.put((self.id, True, None))
# The end marker (self.id, True, None) indicates that the thread
# completed successfully. Don't send it if the thread is stopped.
# The thread can be stopped for one of two reasons:
# 1. The fastlog service failed - in this case, flagging a successful
# finish is harmful, because it will stop us continuing with local
# results, truncating output.
# 2. The caller is going to ignore all future results from us. In this
# case, it'll ignore the end marker anyway - it's discarding the
# entire queue.
if not self.stopped():
self.queue.put((self.id, True, None))
if __name__ == '__main__':
import doctest

View File

@ -250,3 +250,21 @@ Multi-path queries
5946a2427fdfcb068a8aec1a59227d0d76062b43
728676e01661ccc3d7e39de054ca3a7288d7e7b6
Test with failed network call
$ cat > $TESTTMP/bad_conduit.py <<'EOF'
> def call_conduit(*args, **kwargs):
> raise Exception('failed')
> def conduit_config(*args, **kwargs):
> return True
> EOF
$ cat >> $HGRCPATH << EOF
> [extensions]
> fbconduit=$TESTTMP/bad_conduit.py
> EOF
$ hg log parent -T '{rev} {desc}\n' 2>&1 | grep --invert-match 'failed'
9 toys
8 treats
7 cookies
6 major repo reorg