SourceCodeManagerUtilities.st
branchjv
changeset 3158 f8c56a311307
parent 3128 87750af738dc
parent 3153 c2bca6dbe3a7
child 3159 68e577a623f8
--- a/SourceCodeManagerUtilities.st	Fri Mar 22 11:11:55 2013 +0000
+++ b/SourceCodeManagerUtilities.st	Thu Mar 28 12:22:48 2013 +0000
@@ -52,6 +52,7 @@
 "
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'instance creation'!
 
 forManager: aSourceCodeManager
@@ -72,6 +73,7 @@
     "Modified: / 25-07-2012 / 17:10:55 / cg"
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'Signal constants'!
 
 yesToAllNotification
@@ -88,6 +90,7 @@
     ^ YesToAllQuery
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'accessing'!
 
 default
@@ -123,6 +126,7 @@
     LastPackage := something.
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'error handling'!
 
 doesNotUnderstand: aMessage
@@ -140,6 +144,7 @@
     "Created: / 10-10-2011 / 14:04:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'private-migration'!
 
 compileForwarders
@@ -174,12 +179,14 @@
     "Created: / 11-10-2011 / 10:55:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'resources'!
 
 resourcePackage
     ^ #'stx:libtool'
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'utilities'!
 
 classIsNotYetInRepository:aClass withManager:mgr
@@ -249,6 +256,7 @@
     ^self default versionString:a isLessThan:b
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'utilities-cvs'!
 
 changeSetForExtensionMethodsForPackage:packageToCheckOut askForRevision:askForRevision usingManager:aSourceCodeManager
@@ -559,6 +567,7 @@
     "Created: / 29-12-2011 / 14:31:43 / cg"
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'utilities-cvs-helpers'!
 
 getMethodVersionsOfClass:aClass selector:selector numberOfRevisions:numberOfRevisionsOrNil
@@ -570,6 +579,7 @@
     ^self default getMethodVersionsOfClass:aClass selector:selector numberOfRevisions:numberOfRevisionsOrNil
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'utilities-cvs-user interaction'!
 
 askForContainer:boxText title:title note:notice initialModule:initialModule initialPackage:initialPackage initialFileName:initialFileName
@@ -643,6 +653,7 @@
     ^self default goodInitialLogMessageForCheckinClassOfClass:aClass
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'utilities-encoding'!
 
 guessEncodingOfFile:aFilename
@@ -661,6 +672,7 @@
     ^ CharacterEncoder guessEncodingOfStream:aStream
 ! !
 
+
 !SourceCodeManagerUtilities methodsFor:'accessing'!
 
 classResources
@@ -704,6 +716,7 @@
     "Created: / 11-10-2011 / 12:01:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+
 !SourceCodeManagerUtilities methodsFor:'error handling'!
 
 doesNotUnderstand: aMessage
@@ -721,6 +734,7 @@
     "Created: / 10-10-2011 / 14:02:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+
 !SourceCodeManagerUtilities methodsFor:'initialization'!
 
 initialize
@@ -744,6 +758,7 @@
     "Modified: / 25-07-2012 / 08:35:35 / cg"
 ! !
 
+
 !SourceCodeManagerUtilities methodsFor:'utilities'!
 
 classIsNotYetInRepository:aClass withManager:mgr
@@ -807,10 +822,10 @@
     ].
 !
 
-sourceCodeForExtensions:aCollectionOfMethods package:aPackageID forManager:scmManager
+sourceCodeForExtensions:aCollectionOfMethods package:aPackageID forManager:scmManagerOrNil
     |s methodsSortedByName defClass|
 
-    s := '' writeStream.
+    s := WriteStream on:(String new:1000).
 
     s nextPutAll:'"{ Package: '''.
     s nextPutAll:aPackageID asString.
@@ -843,16 +858,18 @@
         s cr.
     ].
 
-    defClass := ProjectDefinition definitionClassForPackage:aPackageID.
-    defClass notNil ifTrue:[
-        "/ make sure, an extensionVersion_XXX method is included...
-        "/ (notice: no need to support a secondary backward compatible non-manager related version method here)
-        (methodsSortedByName contains:[:aMethod | aMethod selector == scmManager nameOfVersionMethodForExtensions]) ifFalse:[
-            s nextPutLine:('!!%1 class methodsFor:''documentation''!!' bindWith:defClass name).
-            s cr.
-            s nextChunkPut:
-                (scmManager versionMethodTemplateForSmalltalkFor:(scmManager nameOfVersionMethodForExtensions)).
-            s space; nextPutChunkSeparator.
+    scmManagerOrNil notNil ifTrue:[
+        defClass := ProjectDefinition definitionClassForPackage:aPackageID.
+        defClass notNil ifTrue:[
+            "/ make sure, an extensionVersion_XXX method is included...
+            "/ (notice: no need to support a secondary backward compatible non-manager related version method here)
+            (methodsSortedByName contains:[:aMethod | aMethod selector == scmManagerOrNil nameOfVersionMethodForExtensions]) ifFalse:[
+                s nextPutLine:('!!%1 class methodsFor:''documentation''!!' bindWith:defClass name).
+                s cr.
+                s nextChunkPut:
+                    (scmManagerOrNil versionMethodTemplateForSmalltalkFor:(scmManagerOrNil nameOfVersionMethodForExtensions)).
+                s space; nextPutChunkSeparator; cr.
+            ].
         ].
     ].
 
@@ -898,6 +915,47 @@
     ^ src
 !
 
+validateConsistencyOfPackage:aPackage
+    ^ self validateConsistencyOfPackage:aPackage doClasses:true  doExtensions:true
+!
+
+validateConsistencyOfPackage:aPackage doClasses:doClasses doExtensions:doExtensions
+    |checker defClass report msg answer dialog|
+
+    defClass := aPackage asPackageId projectDefinitionClass.
+    "/ also done by ProjectChecker
+    "/ defClass validateDescription.
+
+    checker := ProjectChecker new.
+    checker checkExtensionsOnly:(doClasses not and:[ doExtensions ]).
+    report := checker check: defClass package.
+    (report notNil and:[report problems notEmptyOrNil]) ifTrue:[
+        report problems size == 1 ifTrue:[
+            msg := 'The ProblemChecker found the following error/inconsistency:\\    %2\\Need more detail or help for repair?'
+        ] ifFalse:[
+            msg := 'The ProblemChecker found %1 errors/inconsistencies.\\Browse them for detail or repair?'
+        ].
+        answer := Dialog confirmWithCancel:(msg bindWith:report problems size 
+                                                with:report problems first label) withCRs.
+        answer isNil ifTrue:[
+            "/ cancel
+            AbortSignal raiseRequest
+        ].
+        answer == true ifTrue:[
+            dialog := Tools::ProjectCheckerBrowser new.
+            dialog
+                projectChecker: (ProjectChecker forPackage: defClass package);
+                problemList:report problems;
+                showCancel:true;
+                openModal.
+self halt.
+            dialog accepted ifFalse:[
+                AbortSignal raiseRequest
+            ].
+        ].
+    ].
+!
+
 versionString:a isLessThan:b
     "compare two strings of the form: a.b.c..."
 
@@ -944,6 +1002,7 @@
     "Modified: / 17-02-2011 / 10:20:14 / cg"
 ! !
 
+
 !SourceCodeManagerUtilities methodsFor:'utilities-cvs'!
 
 changeSetForExtensionMethodsForPackage:packageToCheckOut askForRevision:askForRevision usingManager:aSourceCodeManager
@@ -2097,10 +2156,9 @@
 
     className := aClass name.
 
-    aClass isProjectDefinition ifTrue:[
-        "/ no way - their package is already known and fix.
-        module := aClass module.
-        directory := aClass moduleDirectory.
+    aClass package ~= PackageId noProjectID ifTrue:[
+        module := aClass package asPackageId module.
+        directory := aClass package asPackageId directory.
     ] ifFalse:[
         "/
         "/ defaults, if nothing at all is known
@@ -2110,7 +2168,7 @@
         ].
         (directory := LastPackage) isNil ifTrue:[
             directory := 'private'.
-        ].
+        ]. 
     ].
 
     "/
@@ -2998,6 +3056,7 @@
     "Created: / 29-12-2011 / 14:32:38 / cg"
 ! !
 
+
 !SourceCodeManagerUtilities methodsFor:'utilities-cvs-helpers'!
 
 getMethodVersionsOfClass:aClass selector:selector numberOfRevisions:numberOfRevisionsOrNil
@@ -3074,6 +3133,7 @@
     "
 ! !
 
+
 !SourceCodeManagerUtilities methodsFor:'utilities-cvs-user interaction'!
 
 askForContainer:boxText title:title note:notice initialModule:initialModule initialPackage:initialPackage initialFileName:initialFileName
@@ -3612,13 +3672,30 @@
      and other info (mark as stable, for example).
      Return the info-object (actually: the dialog) or nil if aborted."
 
+    ^  self 
+        getCheckinInfoFor:aClassNameOrPackageNameString initialAnswer:initialAnswerOrNil withQuickOption:withQuickOption
+        withValidateConsistencyOption:false
+
+    "
+     SourceCodeManagerUtilities default getCheckinInfoFor:'hello' initialAnswer:'bla'
+    "
+
+    "Modified: / 12-03-2012 / 13:12:40 / cg"
+!
+
+getCheckinInfoFor:aClassNameOrPackageNameString initialAnswer:initialAnswerOrNil withQuickOption:withQuickOption withValidateConsistencyOption:withValidateConsistencyOption
+    "ask for a log message for checking in a class (plus checkinQuick state info),
+     and other info (mark as stable, for example).
+     Return the info-object (actually: the dialog) or nil if aborted."
+
     |logMsg infoDialog|
 
     infoDialog := Tools::CheckinInfoDialog 
                     getCheckinInfoFor:aClassNameOrPackageNameString 
                     initialAnswer:(initialAnswerOrNil ? LastSourceLogMessage)
                     withQuickOption:withQuickOption
-                    logHistory:(LastSourceLogMessages ? #()).
+                    logHistory:(LastSourceLogMessages ? #())
+                    withValidateConsistencyOption:withValidateConsistencyOption.
 
     infoDialog notNil ifTrue:[
         logMsg := infoDialog logMessage.
@@ -3791,6 +3868,7 @@
     "Modified: / 26-09-2012 / 18:31:38 / cg"
 ! !
 
+
 !SourceCodeManagerUtilities methodsFor:'utilities-encoding'!
 
 guessEncodingOfFile:aFilename
@@ -3828,14 +3906,15 @@
     ^ CharacterEncoder guessEncodingOfStream:aStream
 ! !
 
+
 !SourceCodeManagerUtilities class methodsFor:'documentation'!
 
 version
-    ^ '$Header: SourceCodeManagerUtilities.st 1985 2013-01-16 11:55:57Z vranyj1 $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.268 2013-03-27 19:36:57 cg Exp $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.264 2012/11/07 16:54:17 cg Exp §'
+    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.268 2013-03-27 19:36:57 cg Exp $'
 !
 
 version_HG