2849
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2012 eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libbasic3' }"
|
|
13 |
|
|
14 |
SourceCodeManagerUtilities subclass:#SourceCodeManagerUtilitiesForWorkspaceBasedManagers
|
|
15 |
instanceVariableNames:''
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'System-SourceCodeManagement'
|
|
19 |
!
|
|
20 |
|
|
21 |
!SourceCodeManagerUtilitiesForWorkspaceBasedManagers class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 2012 eXept Software AG
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
! !
|
|
36 |
|
|
37 |
!SourceCodeManagerUtilitiesForWorkspaceBasedManagers methodsFor:'utilities-cvs'!
|
|
38 |
|
|
39 |
checkinPackage:packageToCheckIn classes:doClasses extensions:doExtensions buildSupport:doBuild askForMethodsInOtherPackages:askForMethodsInOtherPackages
|
|
40 |
|mgr classesToCheckIn methodsToCheckIn
|
|
41 |
methodsInOtherPackages looseMethods otherPackages
|
|
42 |
msg classesInChangeSet checkinInfo repos pkgDir extensionsSource defClass
|
|
43 |
path fileIsNew|
|
|
44 |
|
|
45 |
mgr := self sourceCodeManagerFor: packageToCheckIn.
|
|
46 |
|
|
47 |
repos := (mgr repositoryNameForPackage:packageToCheckIn) ifNil:[mgr repositoryName].
|
|
48 |
|
|
49 |
"/ clear package directory in the repository (so we get rid of removed files)
|
|
50 |
pkgDir := packageToCheckIn asPackageId pathRelativeToTopDirectory:repos.
|
|
51 |
pkgDir recursiveMakeDirectory.
|
|
52 |
|
|
53 |
"/ containerFileName := self nameOfExtensionsContainer.
|
|
54 |
|
|
55 |
methodsToCheckIn := IdentitySet new.
|
|
56 |
methodsInOtherPackages := IdentitySet new.
|
|
57 |
looseMethods := IdentitySet new.
|
|
58 |
|
|
59 |
classesToCheckIn := Smalltalk allClassesInPackage: packageToCheckIn.
|
|
60 |
|
|
61 |
"/ cg: O(n^2) algorithm
|
|
62 |
"/ classesInChangeSet := classesToCheckIn select:[:cls | cls hasUnsavedChanges].
|
|
63 |
"/ replaced by: O(n) algorithm
|
|
64 |
classesInChangeSet := ChangeSet current selectForWhichIncludesChangeForClassOrMetaclassOrPrivateClassFrom:classesToCheckIn.
|
|
65 |
|
|
66 |
"/ individual methods ...
|
|
67 |
Smalltalk allClassesDo:[:aClass |
|
|
68 |
aClass isMeta ifFalse:[
|
|
69 |
methodsToCheckIn addAll:(aClass extensionsFrom:packageToCheckIn).
|
|
70 |
].
|
|
71 |
].
|
|
72 |
|
|
73 |
self assert:doExtensions.
|
|
74 |
self assert:doClasses.
|
|
75 |
self assert:doBuild.
|
|
76 |
|
|
77 |
msg := '%1 classes (%4 changed) '.
|
|
78 |
methodsToCheckIn notEmpty ifTrue:[
|
|
79 |
msg := msg , 'and %2 extensions '.
|
|
80 |
].
|
|
81 |
msg := msg , 'of project "%3"'.
|
|
82 |
|
|
83 |
checkinInfo := self
|
|
84 |
getCheckinInfoFor:(msg
|
|
85 |
bindWith:classesToCheckIn size
|
|
86 |
with:methodsToCheckIn size
|
|
87 |
with:packageToCheckIn allBold
|
|
88 |
with:classesInChangeSet size)
|
|
89 |
initialAnswer:nil
|
|
90 |
withQuickOption:false.
|
|
91 |
checkinInfo isNil ifTrue:[
|
|
92 |
^ self.
|
|
93 |
].
|
|
94 |
|
|
95 |
"/ check if any of the classes contains methods for other packages ...
|
|
96 |
classesToCheckIn do:[:eachClass |
|
|
97 |
eachClass instAndClassMethodsDo:[:eachMethod |
|
|
98 |
|mPgk|
|
|
99 |
|
|
100 |
mPgk := eachMethod package.
|
|
101 |
(mPgk = packageToCheckIn) ifFalse:[
|
|
102 |
mPgk == PackageId noProjectID ifTrue:[
|
|
103 |
looseMethods add:eachMethod
|
|
104 |
] ifFalse:[
|
|
105 |
methodsInOtherPackages add:eachMethod
|
|
106 |
]
|
|
107 |
]
|
|
108 |
].
|
|
109 |
].
|
|
110 |
|
|
111 |
askForMethodsInOtherPackages ifTrue:[
|
|
112 |
methodsInOtherPackages notEmpty ifTrue:[
|
|
113 |
otherPackages := Set new.
|
|
114 |
methodsInOtherPackages do:[:eachMethod | otherPackages add:eachMethod package].
|
|
115 |
|
|
116 |
methodsInOtherPackages size == 1 ifTrue:[
|
|
117 |
msg := 'The ''%4'' method in ''%5'' is contained in the ''%2'' package.'.
|
|
118 |
msg := msg , '\\This method will remain in its package.'.
|
|
119 |
] ifFalse:[
|
|
120 |
otherPackages size == 1 ifTrue:[
|
|
121 |
msg := 'The %1 methods from the %2 package will remain in its package.'
|
|
122 |
] ifFalse:[
|
|
123 |
msg := 'The %1 methods from %3 other packages will remain in their packages.'
|
|
124 |
].
|
|
125 |
msg := msg , '\\Hint: if these are meant to belong to this package,'.
|
|
126 |
msg := msg , '\move them first, then repeat the checkin operation.'.
|
|
127 |
].
|
|
128 |
msg := msg withCRs.
|
|
129 |
msg := msg bindWith:methodsInOtherPackages size
|
|
130 |
with:otherPackages first allBold
|
|
131 |
with:otherPackages size
|
|
132 |
with:methodsInOtherPackages first selector allBold
|
|
133 |
with:methodsInOtherPackages first mclass name allBold.
|
|
134 |
(Dialog confirm:msg noLabel:(resources string:'Cancel')) ifFalse:[^ self].
|
|
135 |
].
|
|
136 |
].
|
|
137 |
|
|
138 |
classesToCheckIn notEmpty ifTrue:[
|
|
139 |
looseMethods notEmpty ifTrue:[
|
|
140 |
looseMethods size == 1 ifTrue:[
|
|
141 |
msg := 'The ''%2'' method in ''%3'' is unassigned (loose).'.
|
|
142 |
msg := msg , '\\If you proceed, this method will be moved to the ''%4'' package'.
|
|
143 |
msg := msg , '\\Hint: if this is meant to be an extension of another package,'.
|
|
144 |
msg := msg , '\cancel and move it to the appropriate package first.'.
|
|
145 |
] ifFalse:[
|
|
146 |
msg := 'There are %1 unassigned (loose) methods in classes from this project.'.
|
|
147 |
msg := msg , '\\If you proceed, those will be moved to the ''%4'' package ?'.
|
|
148 |
msg := msg , '\\Hint: if these are meant to be extensions of another package,'.
|
|
149 |
msg := msg , '\cancel and move them to the appropriate package first.'.
|
|
150 |
].
|
|
151 |
msg := msg withCRs.
|
|
152 |
msg := msg bindWith:looseMethods size
|
|
153 |
with:(looseMethods isEmpty ifTrue:[''] ifFalse:[looseMethods first selector allBold])
|
|
154 |
with:(looseMethods isEmpty ifTrue:[''] ifFalse:[looseMethods first mclass name allBold])
|
|
155 |
with:packageToCheckIn allBold.
|
|
156 |
(Dialog confirm:msg noLabel:(resources string:'Cancel')) ifFalse:[^ self].
|
|
157 |
|
|
158 |
looseMethods do:[:mthd |
|
|
159 |
mthd package:packageToCheckIn
|
|
160 |
].
|
|
161 |
].
|
|
162 |
|
|
163 |
classesToCheckIn do:[:eachClass |
|
|
164 |
|classFileName|
|
|
165 |
|
|
166 |
classFileName := (Smalltalk fileNameForClass:eachClass) , '.st'.
|
|
167 |
mgr
|
|
168 |
withClass:eachClass
|
|
169 |
classFileName:classFileName
|
|
170 |
filedOutToTemporaryFileDo:[:tempFile |
|
|
171 |
path := pkgDir construct:classFileName.
|
|
172 |
fileIsNew := path exists not.
|
|
173 |
tempFile moveTo:path.
|
|
174 |
fileIsNew ifTrue:[
|
|
175 |
mgr addFile:path baseName inDirectory:path directory.
|
|
176 |
].
|
|
177 |
].
|
|
178 |
].
|
|
179 |
].
|
|
180 |
|
|
181 |
path := pkgDir construct:self nameOfExtensionsContainer.
|
|
182 |
methodsToCheckIn notEmpty ifTrue:[
|
|
183 |
extensionsSource := self sourceCodeForExtensions:methodsToCheckIn package:packageToCheckIn forManager:mgr.
|
|
184 |
fileIsNew := path exists not.
|
|
185 |
path contents:extensionsSource.
|
|
186 |
fileIsNew ifTrue:[
|
|
187 |
mgr addFile:path baseName inDirectory:path directory.
|
|
188 |
].
|
|
189 |
] ifFalse:[
|
|
190 |
"/ there may have been extension-methods previously - if so, remove them
|
|
191 |
path remove
|
|
192 |
].
|
|
193 |
|
|
194 |
defClass := ProjectDefinition definitionClassForPackage: packageToCheckIn.
|
|
195 |
defClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
|
|
196 |
path := pkgDir construct:fileName.
|
|
197 |
fileIsNew := path exists not.
|
|
198 |
path directory exists ifFalse:[
|
|
199 |
path directory recursiveMakeDirectory. "/ for autopackage
|
|
200 |
mgr addFile:path directory baseName inDirectory:path directory directory.
|
|
201 |
].
|
|
202 |
path contents:fileContents.
|
|
203 |
fileIsNew ifTrue:[
|
|
204 |
mgr addFile:fileName inDirectory:path directory.
|
|
205 |
].
|
|
206 |
].
|
|
207 |
|
|
208 |
mgr commitRepository:repos logMessage:checkinInfo logMessage.
|
|
209 |
|
|
210 |
"Created: / 13-10-2011 / 11:15:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
211 |
"Modified: / 25-07-2012 / 23:15:47 / cg"
|
|
212 |
! !
|
|
213 |
|
|
214 |
!SourceCodeManagerUtilitiesForWorkspaceBasedManagers class methodsFor:'documentation'!
|
|
215 |
|
|
216 |
version
|
|
217 |
^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilitiesForWorkspaceBasedManagers.st,v 1.1 2012-07-25 23:30:21 cg Exp $'
|
|
218 |
!
|
|
219 |
|
|
220 |
version_CVS
|
|
221 |
^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilitiesForWorkspaceBasedManagers.st,v 1.1 2012-07-25 23:30:21 cg Exp $'
|
|
222 |
! !
|