[PATCH 2 of 2 STABLE] worker: flush messages written by child processes before exit

Yuya Nishihara yuya at tcha.org
Fri Feb 24 23:27:49 EST 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1487994530 -32400
#      Sat Feb 25 12:48:50 2017 +0900
# Branch stable
# Node ID 0a98fef7c72482b78ad384d74d25f78b4147b151
# Parent  21b8ba399a3ba480f66b53d97842ff61d5ec0f28
worker: flush messages written by child processes before exit

I found some child outputs were lost while testing the previous patch. Since
os._exit() does nothing special, we need to do that explicitly.

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -148,12 +148,16 @@ def _posixworker(ui, func, staticargs, a
             # may do some clean-ups which could cause surprises like deadlock.
             # see sshpeer.cleanup for example.
             try:
-                scmutil.callcatch(ui, workerfunc)
+                try:
+                    scmutil.callcatch(ui, workerfunc)
+                finally:
+                    ui.flush()
             except KeyboardInterrupt:
                 os._exit(255)
             except: # never return, therefore no re-raises
                 try:
                     ui.traceback()
+                    ui.flush()
                 finally:
                     os._exit(255)
             else:
diff --git a/tests/test-simple-update.t b/tests/test-simple-update.t
--- a/tests/test-simple-update.t
+++ b/tests/test-simple-update.t
@@ -84,7 +84,8 @@ update with worker processes
 
   $ hg update null
   0 files updated, 0 files merged, 100 files removed, 0 files unresolved
-  $ hg update
+  $ hg update -v | grep 100
+  getting 100
   100 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ cd ..


More information about the Mercurial-devel mailing list