DiffTextView.st
changeset 8545 e8ab04e3722d
parent 8517 cc7558e6bda0
child 8647 136a25126878
--- a/DiffTextView.st	Mon Feb 16 14:21:24 2009 +0100
+++ b/DiffTextView.st	Mon Feb 16 14:31:44 2009 +0100
@@ -311,36 +311,40 @@
     "
     self save:text1 as:(tmpFile1 := Filename newTemporary).
     self save:text2 as:(tmpFile2 := Filename newTemporary).
+    [
+        "
+         start diff on it ...
+        "
+        diffCmd := diffTemplate
+                    bindWith:tmpFile1 asString
+                    with:tmpFile2 asString.
 
-    "
-     start diff on it ...
-    "
-    diffCmd := diffTemplate
-                bindWith:tmpFile1 asString
-                with:tmpFile2 asString.
+        stream := PipeStream readingFrom:diffCmd.
+        stream isNil ifTrue:[
+            stream := PipeStream readingFrom:('support' , Filename separator , diffCmd).
+        ].                                          
+        stream isNil ifTrue:[
+            self error:'cannot execute diff' mayProceed:true.
+            ^ nil.
+        ].
 
-    stream := PipeStream readingFrom:diffCmd.
-    stream isNil ifTrue:[
-        stream := PipeStream readingFrom:('support' , Filename separator , diffCmd).
-    ].                                          
-    stream isNil ifTrue:[
+        diffList := OrderedCollection new.
+        (stream readWaitWithTimeout:2) ifTrue:[
+            "/ timeout
+            self error:'cannot execute diff (timeout)' mayProceed:true.
+            ^ nil.
+        ].
+
+        [stream atEnd] whileFalse:[
+            line := stream nextLine.
+            line notNil ifTrue:[diffList add:line]
+        ].
+        stream close.
+        ^ diffList
+    ] ensure:[
         tmpFile1 delete.
         tmpFile2 delete.
-        self error:'cannot execute diff' mayProceed:true.
-        ^ nil.
     ].
-
-    diffList := OrderedCollection new.
-    [stream atEnd] whileFalse:[
-        line := stream nextLine.
-        line notNil ifTrue:[diffList add:line]
-    ].
-    stream close.
-
-    tmpFile1 delete.
-    tmpFile2 delete.
-
-    ^ diffList
 !
 
 save:text as:filename
@@ -677,5 +681,5 @@
 !DiffTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.52 2009-01-21 14:35:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.53 2009-02-16 13:31:44 cg Exp $'
 ! !