checkin from browser
authorClaus Gittinger <cg@exept.de>
Wed, 18 Aug 1999 12:44:11 +0200
changeset 813 a7daf8306001
parent 812 b39178b69b8a
child 814 58fbd75117a2
checkin from browser
AbstrSCMgr.st
AbstractSourceCodeManager.st
--- a/AbstrSCMgr.st	Tue Aug 17 15:48:34 1999 +0200
+++ b/AbstrSCMgr.st	Wed Aug 18 12:44:11 1999 +0200
@@ -325,6 +325,47 @@
 
 !AbstractSourceCodeManager class methodsFor:'private'!
 
+checkMethodPackagesOf:aClass
+    "check if aClass contains methods from another package;
+     ask if these should be checked in with the class.
+     Return false, if checkIn is to be suppressed."
+
+    |checkInClassPackageOnly clsPackage otherPackages msg|
+
+    checkInClassPackageOnly := false.
+
+    clsPackage := aClass package.
+    otherPackages := IdentitySet new.
+    aClass methodDictionary keysAndValuesDo:[:sel :mthd |
+        |mthdPackage|
+
+        (mthdPackage := mthd package) ~= clsPackage ifTrue:[
+            otherPackages add:mthdPackage.
+        ]
+    ].
+    otherPackages notEmpty ifTrue:[
+        otherPackages size == 1 ifTrue:[
+            msg := 'The class contains methods for the ''%1'' package.\\Change those to belong to the ''%3'' package ?'
+        ] ifFalse:[
+            msg := 'The class contains methods for %2 other packages.\\Change those to belong to the ''%3'' package ?'
+        ].
+        (self confirm:(msg bindWith:(otherPackages first asText allBold) with:(otherPackages size) with:clsPackage asText allBold) withCRs) ifTrue:[
+            aClass methodDictionary keysAndValuesDo:[:sel :mthd |
+                mthd package:clsPackage
+            ]
+        ] ifFalse:[
+            (self confirm:'Ignore those methods in the classes container ?') ifTrue:[
+                checkInClassPackageOnly := true
+            ] ifFalse:[
+                self warn:'checkin of ''' , aClass name , ''' aborted'.
+                ^ false.
+            ]
+        ]
+    ].
+    ^ true
+
+!
+
 containerFromSourceInfo:info
     "given a sourceInfo, return the classes container"
 
@@ -723,7 +764,10 @@
 
     |tempDir tempFile ok|
 
+    (self checkMethodPackagesOf:aClass) ifFalse:[^ false].
+
     tempDir := (Filename newTemporaryIn:nil) makeDirectory; yourself.
+    ok := false.
     [
         |aStream|
 
@@ -748,23 +792,20 @@
 
         tempFile exists ifFalse:[
             'SOURCEMGR: temporary fileout failed' errorPrintCR.
-            ^ false
-        ].
-
-        ok := self 
-            checkinClass:aClass
-            fileName:classFileName 
-            directory:packageDir 
-            module:moduleDir
-            source:(tempFile name)
-            logMessage:logMessage
-            force:force.
-
-        ^ ok
+        ] ifTrue:[
+            ok := self 
+                checkinClass:aClass
+                fileName:classFileName 
+                directory:packageDir 
+                module:moduleDir
+                source:(tempFile name)
+                logMessage:logMessage
+                force:force.
+        ]
     ] valueNowOrOnUnwindDo:[
         tempDir recursiveRemove
     ].
-    ^ false
+    ^ ok
 
     "
      SourceCodeManager checkinClass:Array
@@ -1134,7 +1175,7 @@
     ^ nil
 
     "
-     SourceCodeManager revisionInfoFromString:'$Revision: 1.99 $'
+     SourceCodeManager revisionInfoFromString:'$Revision: 1.100 $'
      SourceCodeManager revisionInfoFromString:(SourceCodeManager version)
     "
 
@@ -1470,6 +1511,6 @@
 !AbstractSourceCodeManager class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/Attic/AbstrSCMgr.st,v 1.99 1999-07-12 08:03:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/Attic/AbstrSCMgr.st,v 1.100 1999-08-18 10:44:11 cg Exp $'
 ! !
 AbstractSourceCodeManager initialize!
--- a/AbstractSourceCodeManager.st	Tue Aug 17 15:48:34 1999 +0200
+++ b/AbstractSourceCodeManager.st	Wed Aug 18 12:44:11 1999 +0200
@@ -325,6 +325,47 @@
 
 !AbstractSourceCodeManager class methodsFor:'private'!
 
+checkMethodPackagesOf:aClass
+    "check if aClass contains methods from another package;
+     ask if these should be checked in with the class.
+     Return false, if checkIn is to be suppressed."
+
+    |checkInClassPackageOnly clsPackage otherPackages msg|
+
+    checkInClassPackageOnly := false.
+
+    clsPackage := aClass package.
+    otherPackages := IdentitySet new.
+    aClass methodDictionary keysAndValuesDo:[:sel :mthd |
+        |mthdPackage|
+
+        (mthdPackage := mthd package) ~= clsPackage ifTrue:[
+            otherPackages add:mthdPackage.
+        ]
+    ].
+    otherPackages notEmpty ifTrue:[
+        otherPackages size == 1 ifTrue:[
+            msg := 'The class contains methods for the ''%1'' package.\\Change those to belong to the ''%3'' package ?'
+        ] ifFalse:[
+            msg := 'The class contains methods for %2 other packages.\\Change those to belong to the ''%3'' package ?'
+        ].
+        (self confirm:(msg bindWith:(otherPackages first asText allBold) with:(otherPackages size) with:clsPackage asText allBold) withCRs) ifTrue:[
+            aClass methodDictionary keysAndValuesDo:[:sel :mthd |
+                mthd package:clsPackage
+            ]
+        ] ifFalse:[
+            (self confirm:'Ignore those methods in the classes container ?') ifTrue:[
+                checkInClassPackageOnly := true
+            ] ifFalse:[
+                self warn:'checkin of ''' , aClass name , ''' aborted'.
+                ^ false.
+            ]
+        ]
+    ].
+    ^ true
+
+!
+
 containerFromSourceInfo:info
     "given a sourceInfo, return the classes container"
 
@@ -723,7 +764,10 @@
 
     |tempDir tempFile ok|
 
+    (self checkMethodPackagesOf:aClass) ifFalse:[^ false].
+
     tempDir := (Filename newTemporaryIn:nil) makeDirectory; yourself.
+    ok := false.
     [
         |aStream|
 
@@ -748,23 +792,20 @@
 
         tempFile exists ifFalse:[
             'SOURCEMGR: temporary fileout failed' errorPrintCR.
-            ^ false
-        ].
-
-        ok := self 
-            checkinClass:aClass
-            fileName:classFileName 
-            directory:packageDir 
-            module:moduleDir
-            source:(tempFile name)
-            logMessage:logMessage
-            force:force.
-
-        ^ ok
+        ] ifTrue:[
+            ok := self 
+                checkinClass:aClass
+                fileName:classFileName 
+                directory:packageDir 
+                module:moduleDir
+                source:(tempFile name)
+                logMessage:logMessage
+                force:force.
+        ]
     ] valueNowOrOnUnwindDo:[
         tempDir recursiveRemove
     ].
-    ^ false
+    ^ ok
 
     "
      SourceCodeManager checkinClass:Array
@@ -1134,7 +1175,7 @@
     ^ nil
 
     "
-     SourceCodeManager revisionInfoFromString:'$Revision: 1.99 $'
+     SourceCodeManager revisionInfoFromString:'$Revision: 1.100 $'
      SourceCodeManager revisionInfoFromString:(SourceCodeManager version)
     "
 
@@ -1470,6 +1511,6 @@
 !AbstractSourceCodeManager class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.99 1999-07-12 08:03:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.100 1999-08-18 10:44:11 cg Exp $'
 ! !
 AbstractSourceCodeManager initialize!