[PATCH 1 of 2 V2] log: flush stdout/err for the first log entries

Durham Goode durham at fb.com
Thu Sep 24 19:20:32 UTC 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1443118388 25200
#      Thu Sep 24 11:13:08 2015 -0700
# Node ID 7a9aaaadaed9887a956cb6a1e79be527e6f4a20f
# Parent  a0eff7ebc2aebb32cf4c8da276104102ff37d786
log: flush stdout/err for the first log entries

There have been problems with the pager where we get no results until the python
buffer has been filled. Let's fix that by manually flushing the buffer for the
first 50 commits from log. 50 was chosen because it will likely fill the users
screen and doesn't introduce a significant overhead.

The overhead of this is negiligble. I see no perf difference when running log on
100,000 commits.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4658,6 +4658,13 @@ def log(ui, repo, *pats, **opts):
         if displayer.flush(ctx):
             count += 1
 
+        # We want the first batch of results to show up as soon as possible, so
+        # let's flush. 50 was chosen because 50 flushes adds very little
+        # overhead, but will likely fill the user's screen even if they are
+        # printing one line per commit.
+        if count < 50:
+            ui.flush()
+
     displayer.close()
 
 @command('manifest',


More information about the Mercurial-devel mailing list