gitview: Fix the blame interface.
The async reading from the pipe was skipping some of the input lines. Fix the same by making sure that we add the partial content of the previous read to the newly read data. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Aneesh Kumar K.V committed
Jun 13, 2007 at 14:16 UTC
30a844874db6ee25b6f54ea786f0adabd8e074d7
1 file changed
+18
-1
contrib/gitview/gitview
+18
-1
@@ -352,6 +352,7 @@ class AnnotateWindow(object):
352
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
353
self.window.set_border_width(0)
354
self.window.set_title("Git repository browser annotation window")
355
+ self.prev_read = ""
356
357
# Use two thirds of the screen by default
358
screen = self.window.get_screen()
@@ -401,7 +402,10 @@ class AnnotateWindow(object):
402
def data_ready(self, source, condition):
403
while (1):
404
try :
404
- buffer = source.read(8192)
405
+ # A simple readline doesn't work
406
+ # a readline bug ??
407
+ buffer = source.read(100)
408
+
409
except:
410
# resource temporary not available
411
return True
@@ -411,6 +415,19 @@ class AnnotateWindow(object):
415
source.close()
416
return False
417
418
+ if (self.prev_read != ""):
419
+ buffer = self.prev_read + buffer
420
+ self.prev_read = ""
421
+
422
+ if (buffer[len(buffer) -1] != '\n'):
423
+ try:
424
+ newline_index = buffer.rindex("\n")
425
+ except ValueError:
426
+ newline_index = 0
427
+
428
+ self.prev_read = buffer[newline_index:(len(buffer))]
429
+ buffer = buffer[0:newline_index]
430
+
431
for buff in buffer.split("\n"):
432
annotate_line = re.compile('^([0-9a-f]{40}) (.+) (.+) (.+)$')
433
m = annotate_line.match(buff)