Patchwork [1,of,2] log: add a config for flushing log output

login
register
mail settings
Submitter Durham Goode
Date Sept. 22, 2015, 1:18 a.m.
Message ID <7f997a372e42f61638cb.1442884720@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/10561/
State Changes Requested
Headers show

Comments

Durham Goode - Sept. 22, 2015, 1:18 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1442884093 25200
#      Mon Sep 21 18:08:13 2015 -0700
# Node ID 7f997a372e42f61638cb2609b3323c3fb7b45ed3
# Parent  a0eff7ebc2aebb32cf4c8da276104102ff37d786
log: add a config for flushing log output

When using the pager, log output can be buffered up and take a long time to be
printed. This patch adds a config knob that let's us flush stdout/err after a
certain period of time.

The default is 1 second, and it shows no affect on perf when I time "time hg log
-l 10000".

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4638,6 +4638,8 @@  def log(ui, repo, *pats, **opts):
             endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
         getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
 
+    lastflush = time.time()
+    flushlimit = float(ui.config('ui', 'maxlogflushdelay', 1))
     displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
     for rev in revs:
         if count == limit:
@@ -4657,6 +4659,10 @@  def log(ui, repo, *pats, **opts):
         displayer.show(ctx, copies=copies, matchfn=revmatchfn)
         if displayer.flush(ctx):
             count += 1
+        now = time.time()
+        if now - lastflush > flushlimit:
+            ui.flush()
+            lastflush = now
 
     displayer.close()
 
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1428,6 +1428,10 @@  User interface controls.
 ``logtemplate``
     Template string for commands that print changesets.
 
+``maxlogflushdelay``
+    How long to wait before flushing stdout/stderr when running log. Mainly used
+    in conjunction with a pager.
+
 ``merge``
     The conflict resolution program to use during a manual merge.
     For more information on merge tools see :hg:`help merge-tools`.