author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 19 Nov 2012 23:08:35 +0000 | |
changeset 81 | eeb86ad71bc3 |
parent 72 | 66345356fa65 |
child 85 | e4adc663da48 |
permissions | -rw-r--r-- |
44 | 1 |
" |
2 |
Copyright (c) 2007-2010 Jan Vrany |
|
3 |
Copyright (c) 2009-2010 eXept Software AG |
|
4 |
||
5 |
Permission is hereby granted, free of charge, to any person |
|
6 |
obtaining a copy of this software and associated documentation |
|
7 |
files (the 'Software'), to deal in the Software without |
|
8 |
restriction, including without limitation the rights to use, |
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
copies of the Software, and to permit persons to whom the |
|
11 |
Software is furnished to do so, subject to the following |
|
12 |
conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall be |
|
15 |
included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
24 |
OTHER DEALINGS IN THE SOFTWARE. |
|
25 |
" |
|
26 |
"{ Package: 'stx:libscm/common' }" |
|
27 |
||
28 |
SCMAbstractFileoutLikeTask subclass:#SCMAbstractCommitTask |
|
29 |
instanceVariableNames:'message paths' |
|
30 |
classVariableNames:'' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'SCM-Common-StX-Tasks' |
|
33 |
! |
|
34 |
||
35 |
!SCMAbstractCommitTask class methodsFor:'documentation'! |
|
36 |
||
37 |
copyright |
|
38 |
" |
|
39 |
Copyright (c) 2007-2010 Jan Vrany |
|
40 |
Copyright (c) 2009-2010 eXept Software AG |
|
41 |
||
42 |
Permission is hereby granted, free of charge, to any person |
|
43 |
obtaining a copy of this software and associated documentation |
|
44 |
files (the 'Software'), to deal in the Software without |
|
45 |
restriction, including without limitation the rights to use, |
|
46 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
47 |
copies of the Software, and to permit persons to whom the |
|
48 |
Software is furnished to do so, subject to the following |
|
49 |
conditions: |
|
50 |
||
51 |
The above copyright notice and this permission notice shall be |
|
52 |
included in all copies or substantial portions of the Software. |
|
53 |
||
54 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
55 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
56 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
57 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
58 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
59 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
60 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
61 |
OTHER DEALINGS IN THE SOFTWARE. |
|
62 |
||
63 |
" |
|
64 |
! ! |
|
65 |
||
66 |
!SCMAbstractCommitTask methodsFor:'accessing'! |
|
67 |
||
68 |
message |
|
69 |
||
70 |
message ifNil:[ |
|
71 |
message := String streamContents: [:s| |
|
72 |
| classes methods msg | |
|
73 |
classes := self classesToFileOut. |
|
74 |
methods := self extensionMethodsToFileOut. |
|
75 |
classes do:[:cls| |
|
81
eeb86ad71bc3
Fixed all references to libsvn classes. Added SCMCompatModeQuery.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
72
diff
changeset
|
76 |
msg := SCMAbstractSourceCodeManager utilities goodInitialLogMessageForCheckinClassOfClass:cls. |
44 | 77 |
msg notEmptyOrNil ifTrue: [ |
78 |
s nextPutLine: ' - ', cls name. |
|
79 |
msg asStringCollection do:[:line| |
|
80 |
s nextPutAll:' '; nextPutLine: line. |
|
81 |
] |
|
82 |
]. |
|
83 |
]. |
|
84 |
methods notEmptyOrNil ifTrue:[ |
|
85 |
s nextPutLine: ' - extensions'. |
|
86 |
s nextPutLine: ' ...'. |
|
87 |
]. |
|
88 |
] |
|
89 |
]. |
|
90 |
^message. |
|
91 |
||
81
eeb86ad71bc3
Fixed all references to libsvn classes. Added SCMCompatModeQuery.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
72
diff
changeset
|
92 |
"Modified: / 19-11-2012 / 23:04:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
44 | 93 |
! |
94 |
||
95 |
message:aString |
|
96 |
message := aString. |
|
97 |
! |
|
98 |
||
99 |
paths |
|
100 |
^ paths |
|
101 |
! |
|
102 |
||
103 |
paths:aCollection |
|
104 |
paths := aCollection. |
|
105 |
! ! |
|
106 |
||
107 |
!SCMAbstractCommitTask methodsFor:'executing'! |
|
108 |
||
109 |
do |
|
110 |
self |
|
111 |
doPrepareWorkingCopy; |
|
112 |
doCommit |
|
113 |
||
114 |
"Created: / 23-03-2009 / 11:15:37 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
115 |
"Modified: / 17-06-2009 / 10:16:37 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
116 |
! |
|
117 |
||
118 |
doCommit |
|
56
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
119 |
|containers commitLabel msg | |
44 | 120 |
|
121 |
msg := ((message ? '<no commit message>') asStringCollection |
|
122 |
reject: [:line|line size >= 2 and:[line first == $# and:[line second == $#]]]) |
|
123 |
asString. |
|
124 |
||
125 |
self do:[ |
|
126 |
self isPackageCommit ifFalse:[ |
|
127 |
paths size > 2 ifTrue:[ |
|
128 |
commitLabel := ((paths upTo: 2) asStringWith:', ') , (' and %1 others' bindWith: paths size - 3). |
|
129 |
] ifFalse:[ |
|
130 |
commitLabel := paths asStringWith:', ' |
|
131 |
]. |
|
132 |
containers := paths |
|
133 |
] ifTrue:[ |
|
68
0abe8aeae95a
Utility methods
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
60
diff
changeset
|
134 |
(paths isEmptyOrNil or:[paths size > 2]) ifTrue:[ |
56
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
135 |
commitLabel := self package name ? ''. |
44 | 136 |
] ifFalse:[ |
137 |
commitLabel := paths asStringWith:', ' |
|
138 |
]. |
|
139 |
paths isEmptyOrNil ifTrue:[ |
|
140 |
self isSelectiveFileoutTask ifTrue:[ |
|
141 |
containers := self containersToFileOut |
|
142 |
] ifFalse:[ |
|
72
66345356fa65
Fix in SCMAbstractCommitTask>>doCommit
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
68
diff
changeset
|
143 |
containers := nil "/Meaning - all modified files will be commited" |
44 | 144 |
] |
145 |
] ifFalse:[ |
|
146 |
containers := paths |
|
147 |
] |
|
148 |
]. |
|
72
66345356fa65
Fix in SCMAbstractCommitTask>>doCommit
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
68
diff
changeset
|
149 |
(containers isNil or:[containers notEmpty]) ifTrue: [ |
60 | 150 |
ActivityNotification notify:'Commiting ' , commitLabel. |
151 |
self doCommit: msg files: containers. |
|
152 |
]. |
|
56
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
153 |
ActivityNotification notify:'Shrinking changes'. |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
154 |
self doShrinkChanges. |
44 | 155 |
]. |
156 |
self package commited. |
|
157 |
||
158 |
"Created: / 11-04-2008 / 09:20:01 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
159 |
"Modified: / 19-08-2009 / 12:27:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
160 |
"Modified: / 14-03-2012 / 17:42:25 / jv" |
|
72
66345356fa65
Fix in SCMAbstractCommitTask>>doCommit
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
68
diff
changeset
|
161 |
"Modified: / 17-11-2012 / 01:02:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
56
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
162 |
! |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
163 |
|
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
164 |
doCommit: msg files: containers |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
165 |
"Actually commit the changes, To be overridden by subclasses" |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
166 |
|
60 | 167 |
self synchronized:[ |
56
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
168 |
self package workingCopy commit: msg files: containers. |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
169 |
|
60 | 170 |
"/ "Update the working copy. We need svn info |
171 |
"/ to report commited revision" |
|
172 |
"/ (UpdateCommand new) |
|
173 |
"/ workingCopy:self workingCopy; |
|
174 |
"/ execute |
|
175 |
]. |
|
56
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
176 |
|
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
177 |
"Created: / 15-11-2012 / 09:39:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
60 | 178 |
"Modified: / 15-11-2012 / 16:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
44 | 179 |
! |
180 |
||
181 |
doPrepareWorkingCopy |
|
182 |
||
183 |
self doPrepareWorkingCopy1. |
|
184 |
self doPrepareWorkingCopy2. |
|
185 |
||
186 |
"Created: / 11-04-2008 / 09:19:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
187 |
"Modified: / 17-08-2009 / 18:28:34 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
188 |
"Modified: / 07-10-2012 / 09:32:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
189 |
! |
|
190 |
||
191 |
doPrepareWorkingCopy1 |
|
192 |
||
193 |
self isPackageCommit ifTrue:[ |
|
194 |
self do:[ |
|
195 |
self doUpdateCode. |
|
196 |
] |
|
197 |
]. |
|
198 |
||
199 |
"Created: / 10-05-2012 / 17:08:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
200 |
! |
|
201 |
||
202 |
doPrepareWorkingCopy2 |
|
203 |
||
204 |
self isPackageCommit ifTrue:[ |
|
205 |
self do:[ |
|
206 |
self package ensureWorkingCopy. |
|
207 |
self doFileOut |
|
208 |
] |
|
209 |
]. |
|
210 |
||
211 |
"Created: / 10-05-2012 / 17:08:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
212 |
! |
|
213 |
||
214 |
doSanityChecks |
|
215 |
"Perform some sanity checks on the package |
|
216 |
(or individual classes and/or methods). |
|
217 |
Return a project checker. Use #problems to get the |
|
218 |
list of problems" |
|
219 |
||
220 |
self isPackageCommit ifFalse:[ ^ nil ]. |
|
221 |
(ConfigurableFeatures includesFeature:#ProjectChecker) ifFalse:[ ^ nil ]. |
|
222 |
||
223 |
^ProjectChecker new |
|
224 |
package: self package name; |
|
225 |
classes: classes; |
|
226 |
methods: (extensionMethods = #() ifTrue:[nil] ifFalse:[extensionMethods]); |
|
227 |
check; |
|
228 |
yourself |
|
229 |
||
230 |
"Created: / 11-04-2008 / 09:19:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
231 |
"Modified: / 17-08-2009 / 18:28:34 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
232 |
"Created: / 13-02-2012 / 16:36:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
56
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
233 |
! |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
234 |
|
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
235 |
doShrinkChanges |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
236 |
|
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
237 |
"Do this only iff this is a package commit" |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
238 |
self isPackageCommit ifTrue:[ |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
239 |
(ChangeSet current) |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
240 |
condenseChangesForPackage2:self package name; |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
241 |
condenseChangesForExtensionsInPackage:self package name; |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
242 |
flushChangedClassesCache; |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
243 |
yourself. |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
244 |
]. |
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
245 |
|
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
246 |
"Created: / 15-11-2012 / 09:41:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
44 | 247 |
! ! |
248 |
||
249 |
!SCMAbstractCommitTask methodsFor:'testing'! |
|
250 |
||
251 |
isPackageCommit |
|
252 |
"Returns true iff this task is for a package |
|
253 |
(or part of it). False if this is ad-hoc commit task - |
|
254 |
for example ad-hoc commit from a file browser" |
|
255 |
||
256 |
^ self package notNil" and:[paths isEmptyOrNil]" |
|
257 |
||
258 |
"Modified: / 14-03-2012 / 17:27:17 / jv" |
|
259 |
"Modified: / 17-03-2012 / 19:49:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
260 |
! ! |
|
261 |
||
262 |
!SCMAbstractCommitTask class methodsFor:'documentation'! |
|
263 |
||
264 |
version_GIT |
|
265 |
"Never, ever change this method. Ask JV or CG why" |
|
266 |
^thisContext method mclass theNonMetaclass instVarNamed: #revision |
|
267 |
! |
|
268 |
||
53
8043f7b6f41a
- More common code refactored
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
44
diff
changeset
|
269 |
version_HG |
8043f7b6f41a
- More common code refactored
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
44
diff
changeset
|
270 |
"Never, ever change this method. Ask JV or CG why" |
8043f7b6f41a
- More common code refactored
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
44
diff
changeset
|
271 |
^thisContext method mclass theNonMetaclass instVarNamed: #revision |
8043f7b6f41a
- More common code refactored
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
44
diff
changeset
|
272 |
! |
8043f7b6f41a
- More common code refactored
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
44
diff
changeset
|
273 |
|
44 | 274 |
version_SVN |
56
c183805e5eb1
Few hacks to make Mercurial commits working.
vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
parents:
53
diff
changeset
|
275 |
^ '§Id:: §' |
44 | 276 |
! ! |