Fix for issue #14 - DNU in commit dialog after "show differences"
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 26 Mar 2014 14:48:59 +0000
changeset 406 f52fedd27727
parent 405 9906c030ae1d
child 407 c3470898ba5f
Fix for issue #14 - DNU in commit dialog after "show differences" In HGCommitDialog>>doShowDiffsForEntry:against: check if the file exists in revision and in working copy. If not, substitute it's content by an empty string.
mercurial/HGCommitDialog.st
--- a/mercurial/HGCommitDialog.st	Tue Mar 25 09:43:46 2014 +0000
+++ b/mercurial/HGCommitDialog.st	Wed Mar 26 14:48:59 2014 +0000
@@ -292,36 +292,59 @@
     |wc wcChangeSet repoentry repoChangeSet diffset |
 
     wc := self task temporaryWorkingCopy.
-    repoentry := [ rev / wcentry pathNameRelativeSlashed ] on: HGError do: [
-        Dialog warn: 'File does not exists in changeset ' , rev id printString.
+    repoentry := nil.
+    rev id isNull ifFalse:[
+        [ 
+            repoentry := rev / wcentry pathNameRelativeSlashed 
+        ] on: HGError do: [
+            "/ No such file in given revision...
+        ].
     ].
+
     wcentry suffix = SmalltalkLanguage instance sourceFileSuffix ifTrue:[
-        wcChangeSet := ChangeSet fromFile: wcentry .
+        wcentry exists ifTrue:[ 
+            wcChangeSet := ChangeSet fromFile: wcentry.
+        ] ifFalse:[ 
+            wcChangeSet := ChangeSet new.
+        ].
         wcChangeSet name: wcentry baseName, (resources string: ' (working copy - to be commited)').
-        repoChangeSet := ChangeSet fromStream: repoentry contents asString readStream.
-        repoChangeSet name: wcentry baseName,  ' (' , rev id printString , ')'.
+        repoentry notNil ifTrue:[
+            repoChangeSet := ChangeSet fromStream: repoentry contents asString readStream.
+        ] ifFalse:[ 
+            repoChangeSet := ChangeSet new.
+        ].
+        repoChangeSet name: wcentry baseName,  ' (revision ' , rev id printString , ')'.
         diffset := ChangeSetDiff versionA:wcChangeSet versionB:repoChangeSet.
         (Tools::ChangeSetDiffTool new)
             beSingleColumn;
             diffset:diffset;
-            title:('%1: Diffbetween working copy and rev. %2 ' bindWith: wcentry pathNameRelative with: rev printString);
+            title:('%1: Diffbetween working copy and rev. %2 ' bindWith: wcentry pathNameRelative with: rev id printString);
             showVersionMethodDiffs: false;
             open
     ] ifFalse:[
         | text1 text2 |
-        text1 := wcentry contents asString.
-        text2 := repoentry contents asString.
+
+        wcentry exists ifTrue:[
+            text1 := wcentry contents asString.
+        ] ifFalse:[ 
+            text1 := ''.
+        ].
+        repoentry notNil ifTrue:[
+            text2 := repoentry contents asString.
+        ] ifFalse:[ 
+            text2 := ''.
+        ].
         "/Argh...backward compatibility..."
         (Tools::TextDiff2Tool ? Tools::TextDiffTool) new
             labelA: 'Working copy';
-            labelB: ('%1' bindWith: rev printString);
+            labelB: ('Revision %1' bindWith: rev id printString);
             textA: text1; textB: text2;
-            title:('%1: Diffbetween working copy and rev. %2 ' bindWith: wcentry pathNameRelative with: rev printString);
+            title:('%1: Diffbetween working copy and rev. %2 ' bindWith: wcentry pathNameRelative with: rev id printString);
             open
     ]
 
     "Created: / 09-02-2012 / 14:53:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 29-11-2013 / 11:50:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 26-03-2014 / 14:44:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 doShowDiffsForEntryAgainstHEAD