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