Patchwork commandserver: flush ui before returning from runcommand

login
register
mail settings
Submitter Jun Wu
Date March 12, 2016, 5:12 a.m.
Message ID <9959a827322a48892aca.1457759531@x1c>
Download mbox | patch
Permalink /patch/13818/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - March 12, 2016, 5:12 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1457755658 0
#      Sat Mar 12 04:07:38 2016 +0000
# Node ID 9959a827322a48892aca4aa67c0b6adae394197f
# Parent  82abdd91e22e218fbf17d032cbb15be72252fb28
commandserver: flush ui before returning from runcommand

The client may exit after received the result from runcommand. It is necessary
to do a flush to make sure the process waiting for the commandserver client
will actually see the output after the commandserver client exits.

This helps chgserver pass test-alias.t.
Yuya Nishihara - March 12, 2016, 3:01 p.m.
On Sat, 12 Mar 2016 05:12:11 +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1457755658 0
> #      Sat Mar 12 04:07:38 2016 +0000
> # Node ID 9959a827322a48892aca4aa67c0b6adae394197f
> # Parent  82abdd91e22e218fbf17d032cbb15be72252fb28
> commandserver: flush ui before returning from runcommand
> 
> The client may exit after received the result from runcommand. It is necessary
> to do a flush to make sure the process waiting for the commandserver client
> will actually see the output after the commandserver client exits.
> 
> This helps chgserver pass test-alias.t.
> 
> diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
> --- a/mercurial/commandserver.py
> +++ b/mercurial/commandserver.py
> @@ -250,6 +250,10 @@
>          if '--cwd' in args:
>              os.chdir(self.cwd)
>  
> +        # flush output before returning result to client
> +        for ui in uis:
> +            ui.flush()

Perhaps this is a bug of dispatch. It appears dispatch._runcatch() tries to
flush output in some cases, but not always.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -250,6 +250,10 @@ 
         if '--cwd' in args:
             os.chdir(self.cwd)
 
+        # flush output before returning result to client
+        for ui in uis:
+            ui.flush()
+
         self.cresult.write(struct.pack('>i', int(ret)))
 
     def getencoding(self):