[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Flush stdout more often

From: Stefan Haller <haller_at_ableton.com>
Date: 2006-04-09 18:28:43 CEST

Sorry to be a pest, but I'd like to bring this issue up again, hoping it
may be possible to reach some kind of consensus this time.

For those who missed the beginning of this thread (about two months
ago), it started at
<http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=112026>.

To recap: For operations that can take a long time to complete, such as
status or update, it is nice to flush stdout after every line of status
output, to give nicer behaviour when piping output into, say, a pager,
or tee.

Looking back through the postings in this thread, quite a lot of people
were in favour of applying the patch in this form. Only Justin
Erenkrantz opposed; the objection was that the patch is incomplete, for
example it doesn't flush diff output. That's correct, but fixing this
would require much bigger changes than I feel is justified for this; as
I see it, it would require adding a callback to svn_client_diff3 and
svn_client_diff_peg3, and changing the svn_wc_diff_callbacks2_t vtable
to store this callback. I don't think it's worth that, especially since
diff is a subcommand where streamy output is not nearly as important in
practice as it is for status, update, or merge.

Apart from diff, I'm not aware of any other places that need flushing;
please point out any that I might have missed. (I did add flushing to
svn log since the first version of the patch.) Personally I think that
even if this is incomplete, the usefulness for those operations where it
does flush now outweighs the inconsistency by far.

May I ask for opinions again, please.

-- 
Stefan Haller
Ableton
http://www.ableton.com/
[[[
Flush stdout after every line of status output.  This is useful when
piping svn output into post-processor tools, e.g. to colorize the
output, or simply into tee.
* subversion/svn/diff-cmd.c
  (summarize_func): Flush output after every line printed.
* subversion/svn/log-cmd.c
  (log_message_receiver): Flush output after every log entry.
* subversion/svn/status.c
  (print_status): Flush output after every line printed.
* subversion/svn/notify.c
  (notify): Flush output after every line printed.
]]]
Index: subversion/svn/diff-cmd.c
===================================================================
--- subversion/svn/diff-cmd.c   (revision 19285)
+++ subversion/svn/diff-cmd.c   (working copy)
@@ -83,6 +83,8 @@
                              summary->prop_changed ? 'M' : ' ',
                              path));
 
+  SVN_ERR(svn_cmdline_fflush(stdout));
+
   return SVN_NO_ERROR;
 }
 
Index: subversion/svn/log-cmd.c
===================================================================
--- subversion/svn/log-cmd.c    (revision 19285)
+++ subversion/svn/log-cmd.c    (working copy)
@@ -231,6 +231,8 @@
       SVN_ERR(svn_cmdline_printf(pool, "\n%s\n", msg));
     }
 
+  SVN_ERR(svn_cmdline_fflush(stdout));
+
   return SVN_NO_ERROR;
 }
 
Index: subversion/svn/status.c
===================================================================
--- subversion/svn/status.c (revision 19285)
+++ subversion/svn/status.c (working copy)
@@ -191,6 +191,8 @@
                            ? 'K' : ' '),
                           path));
 
+  SVN_ERR(svn_cmdline_fflush(stdout));
+
   return SVN_NO_ERROR;
 }
 
Index: subversion/svn/notify.c
===================================================================
--- subversion/svn/notify.c (revision 19285)
+++ subversion/svn/notify.c (working copy)
@@ -344,7 +344,6 @@
 
       if ((err = svn_cmdline_printf(pool, ".")))
         goto print_error;
-      fflush(stdout);
       break;
 
     case svn_wc_notify_locked:
@@ -368,6 +367,9 @@
       break;
     }
 
+  if ((err = svn_cmdline_fflush(stdout)))
+    goto print_error;
+
   return;
 
  print_error:
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Apr 9 18:29:57 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.