PerforceSourceCodeManagerUtilities.st
branchjv
changeset 15566 184cea584be5
parent 13657 fdc78070d46d
parent 15020 76c067348d2b
child 16066 471853fc1521
--- a/PerforceSourceCodeManagerUtilities.st	Sun Jan 12 23:30:25 2014 +0000
+++ b/PerforceSourceCodeManagerUtilities.st	Wed Apr 01 10:38:01 2015 +0100
@@ -153,8 +153,6 @@
     packageHolder := initialPackage asValue.
     fileNameHolder := initialFileName asValue.
 
-    resources := self classResources.
-
     "/
     "/ open a dialog for this
     "/
@@ -214,7 +212,7 @@
     box addAbortAndOkButtons.
 
     (YesToAllNotification notNil and:[YesToAllNotification isHandled]) ifTrue:[
-        component := Button label:'Yes to all'.
+        component := Button label:(resources string:'Yes to All').
         component action:[
                             YesToAllNotification queryWith:true.
                             box doAccept.
@@ -223,7 +221,7 @@
         box addButton:component.
     ].
     (AbortAllSignal isHandled) ifTrue:[
-        component := Button label:'Cancel all'.
+        component := Button label:(resources string:'Cancel All').
         component action:[
                             box hide.
                             AbortAllSignal raiseSignal.
@@ -270,97 +268,96 @@
 
     |logMessage checkinInfo mgr pri doSubmit|
 
-    resources := self classResources.
     doSubmit := false.
 
     aClass isLoaded ifFalse:[
-	self information:(resources string:'Cannot checkin unloaded classes (%1)' with:aClass name).
-	^ false.
+        self information:(resources string:'Cannot checkin unloaded classes (%1)' with:aClass name).
+        ^ false.
     ].
 
     mgr := managerOrNil.
     mgr isNil ifTrue:[
-	mgr := self sourceCodeManagerFor:aClass.
-	mgr isNil ifTrue:[
-	    ^ false
-	]
+        mgr := self sourceCodeManagerFor:aClass.
+        mgr isNil ifTrue:[
+            ^ false
+        ]
     ].
 
     self ensureCorrectVersionMethodsInClass:aClass usingManager:mgr.
     mgr supportsCheckinLogMessages ifTrue:[
-	(self
-	    getLogMessageForClassCheckinTakingDefaultsFromPreviousLogInfo:aLogInfoOrNil
-	    forClass:aClass
-	    valuesInto:[:logMessageRet :checkinInfoRet |
-		logMessage := logMessageRet.
-		checkinInfo := checkinInfoRet.
-		checkinInfo notNil ifTrue:[
-		    doSubmit := checkinInfo submitHolder value.
-		].
-	    ]
-	) ifFalse:[^ false].
+        (self
+            getLogMessageForClassCheckinTakingDefaultsFromPreviousLogInfo:aLogInfoOrNil
+            forClass:aClass
+            valuesInto:[:logMessageRet :checkinInfoRet |
+                logMessage := logMessageRet.
+                checkinInfo := checkinInfoRet.
+                checkinInfo notNil ifTrue:[
+                    doSubmit := checkinInfo submitHolder value.
+                ].
+            ]
+        ) ifFalse:[^ false].
     ].
 
     (self classIsNotYetInRepository:aClass withManager:mgr) ifTrue:[
-	(self createSourceContainerForClass:aClass usingManager:mgr) ifFalse:[
+        (self createSourceContainerForClass:aClass usingManager:mgr) ifFalse:[
 "/            self warn:'did not create a container for ''' , aClass name , ''''.
-	    ^ false
-	].
-	^ true.
+            ^ false
+        ].
+        ^ true.
     ].
 
     self activityNotification:(resources string:'checking in %1' with:aClass name).
     pri := Processor activePriority.
     Processor activeProcess withPriority:pri-1 to:pri
     do:[
-	|revision aborted|
-
-
-
-	aborted := false.
-	AbortOperationRequest handle:[:ex |
-	    aborted := true.
-	    ex return.
-	] do:[
-	    |checkinState cause|
-	    checkinState := false.
-	    cause := ''.
-	    [
-		checkinState := mgr checkinClass:aClass logMessage:logMessage submit:doSubmit
-	    ] on:SourceCodeManagerError do:[:ex|
-		cause := ex description.
-		ex proceed.
-	    ].
-
-	    checkinState ifFalse:[
-		Transcript showCR:'checkin of ''' , aClass name , ''' failed - ', cause.
-		self warn:(resources stringWithCRs:'Checkin of "%1" failed\\' with:aClass name allBold),cause.
-		^ false.
-	    ].
-	    checkinInfo notNil ifTrue:[
-		checkinInfo isStable ifTrue:[
-		    "set stable tag for class that has been checked in"
-		    self tagClass:aClass as:#stable.
-		].
-		checkinInfo tagIt ifTrue:[
-		    "set an additional tag for class that has been checked in"
-		    self tagClass:aClass as:(checkinInfo tag).
-		].
-	    ].
-	].
-	aborted ifTrue:[  |con|
-	    Transcript showCR:'Checkin of ''' , aClass name , ''' aborted'.
-
-	    AbortAllOperationWantedQuery query ifTrue:[
-		(Dialog
-		    confirm:(resources stringWithCRs:'Checkin of "%1" aborted.\\Cancel all ?' with:aClass name)
-		    default:false)
-		ifTrue:[
-		    AbortAllOperationRequest raise.
-		]
-	    ].
-	    ^ false.
-	].
+        |revision aborted|
+
+
+
+        aborted := false.
+        AbortOperationRequest handle:[:ex |
+            aborted := true.
+            ex return.
+        ] do:[
+            |checkinState cause|
+            checkinState := false.
+            cause := ''.
+            [
+                checkinState := mgr checkinClass:aClass logMessage:logMessage submit:doSubmit
+            ] on:SourceCodeManagerError do:[:ex|
+                cause := ex description.
+                ex proceed.
+            ].
+
+            checkinState ifFalse:[
+                Transcript showCR:'checkin of ''' , aClass name , ''' failed - ', cause.
+                self warn:(resources stringWithCRs:'Checkin of "%1" failed\\' with:aClass name allBold),cause.
+                ^ false.
+            ].
+            checkinInfo notNil ifTrue:[
+                checkinInfo isStable ifTrue:[
+                    "set stable tag for class that has been checked in"
+                    self tagClass:aClass as:#stable.
+                ].
+                checkinInfo tagIt ifTrue:[
+                    "set an additional tag for class that has been checked in"
+                    self tagClass:aClass as:(checkinInfo tag).
+                ].
+            ].
+        ].
+        aborted ifTrue:[  |con|
+            Transcript showCR:'Checkin of ''' , aClass name , ''' aborted'.
+
+            AbortAllOperationWantedQuery query ifTrue:[
+                (Dialog
+                    confirm:(resources stringWithCRs:'Checkin of "%1" aborted.\\Cancel all ?' with:aClass name)
+                    default:false)
+                ifTrue:[
+                    AbortAllOperationRequest raise.
+                ]
+            ].
+            ^ false.
+        ].
     ].
     ^ true
 
@@ -379,52 +376,51 @@
 
     mgr isNil ifTrue:[^  false].
 
-    resources := self classResources.
     aClass isLoaded ifFalse:[
-	self warn:(resources string:'Please load the %1-class first' with:aClass name).
-	^ false.
+        self warn:(resources string:'Please load the %1-class first' with:aClass name).
+        ^ false.
     ].
 
     className := aClass name.
 
     aClass isProjectDefinition ifTrue:[
-	"/ no way - their package is already known and fix.
-	module := aClass module.
-	directory := aClass moduleDirectory.
+        "/ no way - their package is already known and fix.
+        module := aClass module.
+        directory := aClass moduleDirectory.
     ] ifFalse:[
-	"/
-	"/ defaults, if nothing at all is known
-	"/
-	projectDefinitionClass := aClass projectDefinitionClass.
-	projectDefinitionClass notNil ifTrue:[
-	    packageId := PackageId from:projectDefinitionClass package.
-	    module := packageId module.
-	    directory := packageId directory.
-	] ifFalse:[
-	    (module := LastModule) isNil ifTrue:[
-		module := (OperatingSystem getLoginName).
-	    ].
-	    (directory := LastPackage) isNil ifTrue:[
-		directory := 'private'.
-	    ].
-	].
+        "/
+        "/ defaults, if nothing at all is known
+        "/
+        projectDefinitionClass := aClass projectDefinitionClass.
+        projectDefinitionClass notNil ifTrue:[
+            packageId := PackageId from:projectDefinitionClass package.
+            module := packageId module.
+            directory := packageId directory.
+        ] ifFalse:[
+            (module := LastModule) isNil ifTrue:[
+                module := (OperatingSystem getLoginName).
+            ].
+            (directory := LastPackage) isNil ifTrue:[
+                directory := 'private'.
+            ].
+        ].
     ].
 
     "/
     "/ try to extract some useful defaults from the current project
     "/
     (Project notNil and:[(project := Project current) notNil]) ifTrue:[
-	directory isNil ifTrue:[
-	    (nm := project repositoryDirectory) isNil ifTrue:[
-		nm := project name
-	    ].
-	    directory := nm.
-	].
-	module isNil ifTrue:[
-	    (nm := project repositoryModule) notNil ifTrue:[
-		module := nm
-	    ]
-	].
+        directory isNil ifTrue:[
+            (nm := project repositoryDirectory) isNil ifTrue:[
+                nm := project name
+            ].
+            directory := nm.
+        ].
+        module isNil ifTrue:[
+            (nm := project repositoryModule) notNil ifTrue:[
+                module := nm
+            ]
+        ].
     ].
 
     "/
@@ -433,23 +429,23 @@
     "/
     info := mgr sourceInfoOfClass:aClass.
     info notNil ifTrue:[
-	true "module ~= LastModule" ifTrue:[
-	    (info includesKey:#module) ifTrue:[
-		module := (info at:#module).
-	    ].
-	].
+        true "module ~= LastModule" ifTrue:[
+            (info includesKey:#module) ifTrue:[
+                module := (info at:#module).
+            ].
+        ].
 "/        true "package ~= LastPackage" ifTrue:[
 "/            (info includesKey:#directory) ifTrue:[
 "/                package := (info at:#directory).
 "/            ].
 "/        ].
-	fileName := mgr containerFromSourceInfo:info.
-	(nameSpace := aClass nameSpace) ~~ Smalltalk ifTrue:[
-	    nameSpacePrefix := nameSpace name , '::'.
-	    (fileName startsWith:nameSpacePrefix) ifTrue:[
-		fileName := fileName copyFrom:(nameSpacePrefix size + 1).
-	    ]
-	].
+        fileName := mgr containerFromSourceInfo:info.
+        (nameSpace := aClass nameSpace) ~~ Smalltalk ifTrue:[
+            nameSpacePrefix := nameSpace name , '::'.
+            (fileName startsWith:nameSpacePrefix) ifTrue:[
+                fileName := fileName copyFrom:(nameSpacePrefix size + 1).
+            ]
+        ].
 "/        (info includesKey:#fileName) ifTrue:[
 "/            fileName := (info at:#fileName).
 "/        ] ifFalse:[
@@ -464,12 +460,12 @@
     ].
 
     fileName isNil ifTrue:[
-	fileName := (Smalltalk fileNameForClass:aClass) , '.st'.
+        fileName := (Smalltalk fileNameForClass:aClass) , '.st'.
     ].
 
     OperatingSystem isMSDOSlike ifTrue:[
-	module replaceAll:$\ with:$/.
-	directory replaceAll:$\ with:$/.
+        module replaceAll:$\ with:$/.
+        directory replaceAll:$\ with:$/.
     ].
 
     "/
@@ -504,36 +500,36 @@
 "/    ].
 "/].
     mgr isContainerBased ifTrue:[
-	doCheckinWithoutAsking ifFalse:[
-	    "/
-	    "/ open a dialog for this
-	    "/
-	    (mgr checkForExistingContainer:fileName inModule:module directory:directory) ifFalse:[
-		note := 'Notice: class seems to have no container yet.'.
-		creatingNew := true.
-	    ] ifTrue:[
-		creatingNew := false.
-	    ].
-
-	    rslt := self
-		    askForContainer:boxText title:title note:note
-		    initialModule:module initialPackage:directory initialFileName:fileName
-		    forNewContainer:true.
-
-	    rslt isNil ifTrue:[
-		^ false
-	    ].
-
-	    module := rslt at:#module.
-	    directory := rslt at:#package.
-	    fileName := rslt at:#fileName.
-	].
-	(fileName endsWith:',v') ifTrue:[
-	    fileName := fileName copyButLast:2
-	].
-	(fileName endsWith:'.st') ifFalse:[
-	    fileName := fileName , '.st'
-	].
+        doCheckinWithoutAsking ifFalse:[
+            "/
+            "/ open a dialog for this
+            "/
+            (mgr checkForExistingContainer:fileName inModule:module directory:directory) ifFalse:[
+                note := 'Notice: class seems to have no container yet.'.
+                creatingNew := true.
+            ] ifTrue:[
+                creatingNew := false.
+            ].
+
+            rslt := self
+                    askForContainer:boxText title:title note:note
+                    initialModule:module initialPackage:directory initialFileName:fileName
+                    forNewContainer:true.
+
+            rslt isNil ifTrue:[
+                ^ false
+            ].
+
+            module := rslt at:#module.
+            directory := rslt at:#package.
+            fileName := rslt at:#fileName.
+        ].
+        (fileName endsWith:',v') ifTrue:[
+            fileName := fileName copyButLast:2
+        ].
+        (fileName endsWith:'.st') ifFalse:[
+            fileName := fileName , '.st'
+        ].
 
     ].
 
@@ -548,45 +544,45 @@
 "/                ^ false
 "/            ]
 "/        ].
-	aClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | mthd setPackage:requiredPackage].
-	aClass package:requiredPackage.
+        aClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | mthd setPackage:requiredPackage].
+        aClass package:requiredPackage.
     ].
 
     info := aClass revisionInfo.
     info notNil ifTrue:[
-	(info repositoryPathName isNil) ifTrue:[
-	    info := nil
-	].
+        (info repositoryPathName isNil) ifTrue:[
+            info := nil
+        ].
 "/        (info includesKey:#repositoryPathName) ifFalse:[
 "/            info := nil
 "/        ]
     ].
 
     info isNil ifTrue:[
-	true "doCheckinWithoutAsking" ifFalse:[
-	    answer := Dialog
-		 confirmWithCancel:(resources string:'%1 does not have any (usable) revision info (#version method)\\Shall I create one ?' with:className) withCRs
-		 labels:(resources array:#( 'Cancel' 'No' 'Yes')).
-	    answer isNil ifTrue:[^ false].
-	] ifTrue:[
-	    answer := true.
-	].
-	answer ifTrue:[
-	    mgr
-		updateVersionMethodOf:aClass
-		for:(mgr initialRevisionStringFor:aClass
-			 inModule:module
-			 directory:directory
-			 container:fileName).
-	].
+        true "doCheckinWithoutAsking" ifFalse:[
+            answer := Dialog
+                 confirmWithCancel:(resources string:'%1 does not have any (usable) revision info (#version method)\\Shall I create one ?' with:className) withCRs
+                 labels:(resources array:#( 'Cancel' 'No' 'Yes')).
+            answer isNil ifTrue:[^ false].
+        ] ifTrue:[
+            answer := true.
+        ].
+        answer ifTrue:[
+            mgr
+                updateVersionMethodOf:aClass
+                for:(mgr initialRevisionStringFor:aClass
+                         inModule:module
+                         directory:directory
+                         container:fileName).
+        ].
     ].
 
     (self checkForExistingModule:module usingManager:mgr allowCreate:(createDirs or:[creatingNew]))
-	ifFalse:[^ false].
+        ifFalse:[^ false].
     LastModule := module.
 
     (self checkForExistingModule:module directory:directory usingManager:mgr allowCreate:(createDirs or:[creatingNew]))
-	ifFalse:[^ false].
+        ifFalse:[^ false].
     LastPackage := directory.
 
     "/
@@ -603,87 +599,87 @@
 "/                ^ false.
 "/            ].
 
-	mgr isContainerBased ifTrue:[
-	    creatingNew ifTrue:[
-		self warn:(resources string:'Container for %1 already exists in %2/%3.' with:fileName with:module with:directory) withCRs.
-	    ].
-
-	    doCheckinWithoutAsking ifFalse:[
-		(Dialog
-		    confirm:(resources string:'check %1 into the existing container
+        mgr isContainerBased ifTrue:[
+            creatingNew ifTrue:[
+                self warn:(resources string:'Container for %1 already exists in %2/%3.' with:fileName with:module with:directory) withCRs.
+            ].
+
+            doCheckinWithoutAsking ifFalse:[
+                (Dialog
+                    confirm:(resources string:'check %1 into the existing container
 
     %2 / %3 / %4  ?'
-				    with:className
-				    with:module
-				    with:directory
-				    with:fileName) withCRs
-		    noLabel:'Cancel')
-		ifFalse:[
-		    ^ false.
-		].
-	    ].
-	].
-	oldFileName notNil ifTrue:[
-	    msg := ('forced checkin / source container change from ' , oldFileName).
-	] ifFalse:[
-	    msg := 'defined source container'
-	].
-
-	(forceCheckIn := doCheckinWithoutAsking) ifFalse:[
-	    (mgr
-		checkinClass:aClass
-		fileName:fileName
-		directory:directory
-		module:module
-		logMessage:msg)
-	    ifFalse:[
-		doCheckinWithoutAsking ifFalse:[
-		    (Dialog
-			confirm:'No easy merge seems possible; force checkin (no merge) ?'
-			noLabel:'Cancel')
-		    ifFalse:[
-			^ false.
-		    ].
-		].
-		forceCheckIn := true.
-	    ]
-	].
-	forceCheckIn ifTrue:[
-	    (mgr
-		checkinClass:aClass
-		fileName:fileName
-		directory:directory
-		module:module
-		logMessage:msg
-		force:true)
-	    ifFalse:[
-		self warn:(resources string:'Failed to check into existing container.').
-		^ false.
-	    ].
-	].
-	^ true
+                                    with:className
+                                    with:module
+                                    with:directory
+                                    with:fileName) withCRs
+                    noLabel:'Cancel')
+                ifFalse:[
+                    ^ false.
+                ].
+            ].
+        ].
+        oldFileName notNil ifTrue:[
+            msg := ('forced checkin / source container change from ' , oldFileName).
+        ] ifFalse:[
+            msg := 'defined source container'
+        ].
+
+        (forceCheckIn := doCheckinWithoutAsking) ifFalse:[
+            (mgr
+                checkinClass:aClass
+                fileName:fileName
+                directory:directory
+                module:module
+                logMessage:msg)
+            ifFalse:[
+                doCheckinWithoutAsking ifFalse:[
+                    (Dialog
+                        confirm:'No easy merge seems possible; force checkin (no merge) ?'
+                        noLabel:'Cancel')
+                    ifFalse:[
+                        ^ false.
+                    ].
+                ].
+                forceCheckIn := true.
+            ]
+        ].
+        forceCheckIn ifTrue:[
+            (mgr
+                checkinClass:aClass
+                fileName:fileName
+                directory:directory
+                module:module
+                logMessage:msg
+                force:true)
+            ifFalse:[
+                self warn:(resources string:'Failed to check into existing container.').
+                ^ false.
+            ].
+        ].
+        ^ true
     ] ifFalse:[
-	(createContainer or:[creatingNew]) ifFalse:[
-	    (Dialog
-		 confirm:(resources string:'No container exists for %1 in %2/%3\\create ?'
-				      with:fileName with:module with:directory) withCRs
-		 noLabel:'Cancel') ifFalse:[
-		^ false
-	    ]
-	]
+        (createContainer or:[creatingNew]) ifFalse:[
+            (Dialog
+                 confirm:(resources string:'No container exists for %1 in %2/%3\\create ?'
+                                      with:fileName with:module with:directory) withCRs
+                 noLabel:'Cancel') ifFalse:[
+                ^ false
+            ]
+        ]
     ].
 
     aClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | mthd setPackage:requiredPackage].
     aClass package:requiredPackage.
 
     (mgr
-	createContainerFor:aClass
-	inModule:module
-	package:directory
-	container:fileName
+        createContainerFor:aClass
+        inModule:module
+        package:directory
+        container:fileName
     ) ifFalse:[
-	self warn:(resources string:'Failed to create container.').
-	^ false.
+        self warn:(resources string:'Failed to create container.').
+        ^ false.
     ].
     ^ true
 
@@ -2611,12 +2607,10 @@
 !
 
 revisionLogOf:clsOrNil 
-fromRevision:firstRev 
-toRevision:lastRef 
-numberOfRevisions:numRevisions 
-fileName:classFileName 
-directory:packageDir 
-module:aPackage
+        fromRevision:firstRev toRevision:lastRef numberOfRevisions:numRevisions 
+        fileName:classFileName directory:packageDir module:aPackage
+
+    "actually do return a revisionLog. The main worker method."
 
     |atEnd line inHeaderInfo info record revisionRecords headerOnly msg revArg infoAndLogString elements 
      foundView outputStream errorStream inStream packagePath fullFilename depotPath perforceCommand result labelLineElements tags label revision|
@@ -3243,7 +3237,7 @@
 
     PerforceSourceCodeManager verboseSourceCodeAccess == true ifTrue:[
         executeStream := WriteStream on:''.
-        executeStream nextPutAll:AbsoluteTime now printString.
+        executeStream nextPutAll:Timestamp now printString.
         executeStream cr.
         executeStream nextPutAll:('Command <', command, '>').
         executeStream cr.
@@ -4125,19 +4119,10 @@
 !PerforceSourceCodeManagerUtilities class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/PerforceSourceCodeManagerUtilities.st,v 1.7 2013-09-28 12:54:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/PerforceSourceCodeManagerUtilities.st,v 1.12 2014-12-12 19:17:30 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/PerforceSourceCodeManagerUtilities.st,v 1.7 2013-09-28 12:54:42 cg Exp $'
-!
-
-version_HG
-
-    ^ '$Changeset: <not expanded> $'
-!
-
-version_SVN
-    ^ '$Id:: PerforceSourceCodeManagerUtilities.st 8074 2012-11-30 17:23:39Z vranyj1                                                $'
+    ^ '$Header: /cvs/stx/stx/libtool/PerforceSourceCodeManagerUtilities.st,v 1.12 2014-12-12 19:17:30 cg Exp $'
 ! !