Commits

Anonymous committed 225c600

gpopen: improve user perceived delay in command output

by reading the first 100 lines of command output one line at a time,
after that read the output in incrementing block, up to a block size of
50KB.

Comments (0)

Files changed (1)

tortoise/gpopen.py

         bytes = 0
         try:
             print "run_program: popened"
+            line = 0
+            blocksize = 1024
             while pop.poll() == None:
-                out = pop.stdout.readline()
-                bytes += len(out)
+                if line < 100:
+                    out = pop.stdout.readline()
+                    line += 1
+                else:
+                    out = pop.stdout.read(blocksize)
+                    if blocksize < 1024 * 50:
+                        blocksize *= 2
                 out = out.replace('\n', '\r\n') # fileter LF for binary output
                 self.out_text(out)
             out = pop.stdout.read()
     
 if __name__ == "__main__":
     #gui = OutputDialog("Hg help")
-    run(['C:\Python24\Scripts\hg.bat', 'help'])
+    run(['python -u C:\Python24\Scripts\hg -R C:\hg\h1 log -v'])
+    #run(['C:\Python24\Scripts\hg.bat', 'help'])