#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 31 Jul 2018 14:36:08 +0200
changeset 23248 ae46b8e2500d
parent 23247 eabe4e9101ef
child 23249 599b1ef2acbe
#FEATURE by cg class: Class changed: #sourceStreamFor: ignore scm-errors if the scm is just a guessed one (i.e. if user did not configure an scm)
Class.st
--- a/Class.st	Mon Jul 30 12:14:48 2018 +0200
+++ b/Class.st	Tue Jul 31 14:36:08 2018 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	       All Rights Reserved
@@ -5307,7 +5305,8 @@
 sourceStreamFor:source
     "return an open stream on a sourcefile, nil if that is not available"
 
-    |owner sourceStream sourceCodeManager validated guessedFileName sep mod dir|
+    |owner sourceStream sourceCodeManager validated guessedFileName 
+     sep mod dir sourceCodeManagerIsGuess|
 
     (owner := self owningClass) notNil ifTrue:[^ owner sourceStreamFor:source].
     validated := false.
@@ -5331,21 +5330,27 @@
         the source from which the class is compiled may not be the one in
         repository. I (JV) think this is a good, less confusing compromise.
     "
+
+    sourceCodeManagerIsGuess := false.
+    
     (TryLocalSourceFirst == true
-        or:[Smalltalk isInitialized not
-            or: [(sourceCodeManager := self sourceCodeManagerFromBinaryRevision) isNil]])
-                ifTrue:[
-                    sourceStream := self localSourceStreamFor:source.
-                ].
+      or:[ Smalltalk isInitialized not
+      or:[ (sourceCodeManager := self sourceCodeManagerFromBinaryRevision) isNil
+    ]]) ifTrue:[
+        sourceStream := self localSourceStreamFor:source.
+    ].
 
     sourceStream isNil ifTrue:[
         "/ mhmh - still no source file.
-        "/ If there is a SourceCodeManager, ask it to acquire the
+        "/ If there is a sourceCodeManager, ask it to acquire the
         "/ source for my class and return an open stream on it.
         "/ If that one does not know about the source, look in
         "/ standard places.
 
         sourceCodeManager notNil ifTrue:[
+            "/ remember iff sourceCodeManager is not the configured one 
+            sourceCodeManagerIsGuess := (sourceCodeManager == SourceCodeManager).
+            
             classFilename ~= source ifTrue:[
                 package notNil ifTrue:[
                     sep := package indexOfAny:'/\:'.
@@ -5355,19 +5360,27 @@
                         mod := package copyTo:sep - 1.
                         dir := package copyFrom:sep + 1.
                         revision :=
-                            self isProjectDefinition ifTrue:[
-                                revisionInfo := self extensionsRevisionInfoForManager:sourceCodeManager.
-
-                                    (revisionInfo notNil and:[ source = revisionInfo fileName ]) ifTrue:[
-                                        revisionInfo revision
-                                    ] ifFalse:[
-                                        self binaryRevision
-                                    ]
+                            (self isProjectDefinition 
+                                ifTrue:[
+                                    revisionInfo := self extensionsRevisionInfoForManager:sourceCodeManager.
+
+                                        (revisionInfo notNil and:[ source = revisionInfo fileName ]) ifTrue:[
+                                            revisionInfo revision
+                                        ] ifFalse:[
+                                            self binaryRevision
+                                        ]
+                                ]
+                                ifFalse:[
+                                    self binaryRevision
+                                ]
+                            ).
+                        sourceCodeManagerIsGuess ifTrue:[
+                            SourceCodeManagerError ignoreIn:[
+                                sourceStream := sourceCodeManager streamForClass:nil fileName:source revision:revision directory:dir module:mod cache:true.
                             ]
-                            ifFalse:[
-                                self binaryRevision
-                            ].
-                        sourceStream := sourceCodeManager streamForClass:nil fileName:source revision:revision directory:dir module:mod cache:true.
+                        ] ifFalse:[    
+                            sourceStream := sourceCodeManager streamForClass:nil fileName:source revision:revision directory:dir module:mod cache:true.
+                        ]
                     ]
                 ].
             ].
@@ -5376,7 +5389,13 @@
                     guessedFileName := (Smalltalk fileNameForClass:self) , '.st'.
                 ].
                 source asFilename baseName = (classFilename ? guessedFileName) asFilename baseName ifTrue:[
-                    sourceStream := sourceCodeManager getSourceStreamFor:self.
+                    sourceCodeManagerIsGuess ifTrue:[
+                        SourceCodeManagerError ignoreIn:[
+                            sourceStream := sourceCodeManager getSourceStreamFor:self.
+                        ]
+                    ] ifFalse:[    
+                        sourceStream := sourceCodeManager getSourceStreamFor:self.
+                    ]
                 ]
             ].
             sourceStream notNil ifTrue:[
@@ -5461,6 +5480,7 @@
     "Modified: / 05-11-2001 / 16:36:30 / cg"
     "Modified: / 08-12-2011 / 19:16:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 01-03-2017 / 14:57:22 / mawalch"
+    "Modified: / 31-07-2018 / 14:35:34 / Claus Gittinger"
 !
 
 updateVersionMethodFor:newRevisionString