author | convert-repo |
Tue, 09 Aug 2016 03:35:30 +0000 | |
changeset 1178 | 3a6dad9479fd |
parent 1054 | 9de41ab58114 |
permissions | -rw-r--r-- |
774 | 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 |
" |
|
381 | 26 |
"{ Package: 'stx:libsvn' }" |
10 | 27 |
|
28 |
"{ NameSpace: SVN }" |
|
29 |
||
30 |
Object subclass:#Command |
|
976 | 31 |
instanceVariableNames:'transcript' |
32 |
classVariableNames:'SVNPath' |
|
33 |
poolDictionaries:'' |
|
34 |
category:'SVN-Private-Commands' |
|
10 | 35 |
! |
36 |
||
774 | 37 |
!Command class methodsFor:'documentation'! |
38 |
||
39 |
copyright |
|
40 |
" |
|
41 |
Copyright (c) 2007-2010 Jan Vrany |
|
42 |
Copyright (c) 2009-2010 eXept Software AG |
|
43 |
||
44 |
Permission is hereby granted, free of charge, to any person |
|
45 |
obtaining a copy of this software and associated documentation |
|
46 |
files (the 'Software'), to deal in the Software without |
|
47 |
restriction, including without limitation the rights to use, |
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
49 |
copies of the Software, and to permit persons to whom the |
|
50 |
Software is furnished to do so, subject to the following |
|
51 |
conditions: |
|
52 |
||
53 |
The above copyright notice and this permission notice shall be |
|
54 |
included in all copies or substantial portions of the Software. |
|
55 |
||
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
63 |
OTHER DEALINGS IN THE SOFTWARE. |
|
64 |
||
65 |
" |
|
66 |
! ! |
|
10 | 67 |
|
68 |
!Command class methodsFor:'instance creation'! |
|
69 |
||
70 |
for: aSVNRepository |
|
71 |
||
72 |
^self new |
|
73 |
||
74 |
"Created: / 15-03-2008 / 21:18:34 / janfrog" |
|
75 |
"Modified: / 15-03-2008 / 23:32:10 / janfrog" |
|
76 |
! |
|
77 |
||
78 |
new |
|
79 |
^ self basicNew initialize. |
|
80 |
||
81 |
"Created: / 16-03-2008 / 07:45:22 / janfrog" |
|
82 |
! ! |
|
83 |
||
84 |
!Command class methodsFor:'accessing'! |
|
85 |
||
86 |
verbose |
|
87 |
||
88 |
^UserPreferences current svnVerbose |
|
89 |
||
90 |
"Created: / 19-03-2008 / 12:29:47 / janfrog" |
|
91 |
"Modified: / 19-03-2009 / 14:00:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
92 |
! |
|
93 |
||
94 |
verbose: aBoolean |
|
95 |
||
96 |
UserPreferences current svnVerbose: aBoolean |
|
97 |
||
98 |
"Created: / 19-03-2008 / 12:29:59 / janfrog" |
|
99 |
"Modified: / 19-03-2009 / 14:00:59 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
100 |
! ! |
|
101 |
||
976 | 102 |
!Command class methodsFor:'executing - private'! |
103 |
||
104 |
executable |
|
1054 | 105 |
"Return (autodetected) svn executable to be used. |
106 |
May be overridden in preferences, see |
|
107 |
- UserPreferences>>svnCommand |
|
108 |
- SVN::Command>>svnProgram |
|
109 |
" |
|
110 |
||
976 | 111 |
|h| |
112 |
||
113 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
114 |
SVNPath isNil ifTrue:[ |
|
115 |
h := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\svn.exe'. |
|
116 |
h notNil ifTrue:[ |
|
117 |
SVNPath := h valueNamed:''. |
|
118 |
]. |
|
119 |
]. |
|
120 |
(SVNPath notEmptyOrNil and:[SVNPath asFilename exists]) ifTrue:[ |
|
121 |
"/ path can include spaces (sigh) |
|
122 |
^ '"',SVNPath,'"' |
|
123 |
]. |
|
124 |
]. |
|
125 |
^ 'svn' |
|
126 |
||
127 |
" |
|
128 |
SVNPath := nil. |
|
129 |
self basicNew svnProgram |
|
130 |
" |
|
131 |
||
132 |
"Modified: / 12-04-2010 / 16:14:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
133 |
"Modified: / 19-08-2011 / 13:34:05 / cg" |
|
134 |
"Created: / 04-02-2012 / 19:05:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
135 |
! ! |
|
136 |
||
774 | 137 |
!Command class methodsFor:'others'! |
138 |
||
139 |
version_CVS |
|
870
b5c82209345e
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
791
diff
changeset
|
140 |
^ '$Header$' |
774 | 141 |
! ! |
142 |
||
10 | 143 |
!Command methodsFor:'accessing'! |
144 |
||
145 |
transcript |
|
146 |
^ transcript ? Transcript |
|
147 |
||
148 |
"Created: / 31-03-2008 / 15:37:39 / janfrog" |
|
149 |
! |
|
150 |
||
151 |
transcript:something |
|
152 |
transcript := something. |
|
153 |
||
154 |
"Created: / 31-03-2008 / 15:37:39 / janfrog" |
|
155 |
! ! |
|
156 |
||
774 | 157 |
!Command methodsFor:'debugging support'! |
158 |
||
159 |
printInfo:svnProcess |
|
160 |
|ctx| |
|
161 |
||
162 |
ctx := thisContext. |
|
163 |
3 timesRepeat:[ |
|
164 |
ctx := ctx sender |
|
165 |
]. |
|
166 |
(self transcript) |
|
167 |
cr; |
|
168 |
show:'[SVN] '; |
|
169 |
showCR:svnProcess asShellCommandString; |
|
170 |
show:' in '; |
|
171 |
showCR:self svnCmdWorkdir; |
|
172 |
show:'[SVN] #called from '; |
|
173 |
showCR:ctx printString; |
|
174 |
showCR:'[SVN] #called from ...'. |
|
175 |
||
176 |
[ (ctx receiver class nameSpace = SVN)] |
|
177 |
whileTrue:[ctx := ctx sender]. |
|
178 |
(self transcript) |
|
179 |
show:'[SVN] #called from '; |
|
180 |
showCR:ctx printString; |
|
181 |
show:'[SVN] #called from '; |
|
182 |
showCR:ctx sender printString |
|
183 |
! ! |
|
184 |
||
10 | 185 |
!Command methodsFor:'executing'! |
186 |
||
187 |
execute |
|
188 |
||
189 |
||
190 |
^self svnExecute |
|
191 |
||
192 |
"Modified: / 03-10-2008 / 17:25:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
193 |
! |
|
194 |
||
195 |
svnStderrStream |
|
196 |
^ (String new:64) writeStream |
|
197 |
||
198 |
"Created: / 16-03-2008 / 07:50:38 / janfrog" |
|
199 |
! |
|
200 |
||
201 |
svnStdoutStream |
|
202 |
^ (String new:64) writeStream |
|
203 |
||
204 |
"Created: / 16-03-2008 / 07:50:17 / janfrog" |
|
205 |
! ! |
|
206 |
||
207 |
!Command methodsFor:'executing - private'! |
|
208 |
||
209 |
svnCmd |
|
210 |
"raise an error: must be redefined in concrete subclass(es)" |
|
211 |
||
212 |
^ self subclassResponsibility |
|
213 |
||
214 |
"Created: / 15-03-2008 / 21:03:26 / janfrog" |
|
215 |
! |
|
216 |
||
217 |
svnCmdArgumentsOn:argStream |
|
218 |
"raise an error: must be redefined in concrete subclass(es)" |
|
219 |
||
220 |
^ self subclassResponsibility |
|
221 |
||
222 |
"Created: / 15-03-2008 / 21:21:11 / janfrog" |
|
223 |
! |
|
224 |
||
225 |
svnCmdWorkdir |
|
226 |
"raise an error: must be redefined in concrete subclass(es)" |
|
227 |
||
228 |
^ '.' |
|
229 |
||
230 |
"Created: / 15-03-2008 / 23:41:48 / janfrog" |
|
231 |
! |
|
232 |
||
233 |
svnExecute |
|
234 |
|svnStdoutStream svnStderrStream svnProcess| |
|
235 |
||
236 |
svnStdoutStream := self svnStdoutStream. |
|
237 |
svnStderrStream := self svnStderrStream. |
|
238 |
svnProcess := (self svnExternalProcess) |
|
239 |
stdout:svnStdoutStream; |
|
240 |
stderr:svnStderrStream. |
|
241 |
self class verbose ifTrue:[ |
|
774 | 242 |
self printInfo:svnProcess |
10 | 243 |
]. |
244 |
svnProcess |
|
245 |
execute; |
|
246 |
waitFor. |
|
247 |
self class verbose ifTrue:[ |
|
248 |
svnStdoutStream contents isEmpty not ifTrue:[ |
|
249 |
svnStdoutStream contents asStringCollection do:[:line | |
|
250 |
"self transcript show:'[SVN] '; show: line; cr" |
|
251 |
] |
|
252 |
]. |
|
253 |
svnStderrStream contents isEmpty not ifTrue:[ |
|
254 |
svnStderrStream contents asStringCollection do:[:line | |
|
255 |
(self transcript) |
|
256 |
show:(('[SVN] ' , line) asText colorizeAllWith:Color red); |
|
257 |
cr |
|
258 |
] |
|
259 |
]. |
|
260 |
]. |
|
261 |
^ svnProcess exitValue isZero |
|
774 | 262 |
ifTrue:[ |
263 |
self svnProcessCommandOutput:svnStdoutStream contents readStream |
|
264 |
err:svnStderrStream contents readStream |
|
265 |
] |
|
266 |
ifFalse:[ self svnProcessCommandError:svnStderrStream contents ] |
|
10 | 267 |
|
268 |
"Modified: / 31-03-2008 / 15:39:40 / janfrog" |
|
269 |
"Created: / 03-10-2008 / 17:25:29 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
270 |
"Modified: / 08-04-2009 / 22:18:39 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
271 |
! |
|
272 |
||
273 |
svnExternalProcess |
|
274 |
|argStream| |
|
275 |
||
276 |
argStream := OrderedCollection new writeStream. |
|
277 |
self svnGlobalArgumentsOn:argStream. |
|
278 |
argStream nextPut:self svnCmd. |
|
279 |
self svnCmdArgumentsOn:argStream. |
|
280 |
^ (OSProcess new) |
|
281 |
executable:self svnProgram; |
|
282 |
arguments:argStream contents; |
|
283 |
workdir:self svnCmdWorkdir; |
|
284 |
yourself |
|
285 |
||
286 |
"Modified: / 15-03-2008 / 23:41:26 / janfrog" |
|
287 |
"Created: / 03-10-2008 / 16:32:13 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
288 |
! |
|
289 |
||
290 |
svnGlobalArgumentsOn: argStream |
|
291 |
||
292 |
argStream |
|
293 |
nextPut:'--non-interactive'. |
|
294 |
||
295 |
"Created: / 03-10-2008 / 17:28:55 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
296 |
! |
|
297 |
||
298 |
svnProcessCommandError: errorString |
|
299 |
||
774 | 300 |
^(SVN::SVNError raiseErrorString: errorString) |
10 | 301 |
|
302 |
"Created: / 03-10-2008 / 16:33:18 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
303 |
"Modified: / 03-10-2008 / 17:48:05 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
774 | 304 |
"Modified: / 12-08-2010 / 18:19:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10 | 305 |
! |
306 |
||
307 |
svnProcessCommandOutput:svnStdoutStream err:svnStderrStream |
|
308 |
self subclassResponsibility |
|
309 |
||
310 |
"Created: / 03-10-2008 / 16:31:45 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
311 |
! |
|
312 |
||
313 |
svnProgram |
|
1054 | 314 |
"Answer a 'svn' command to be used" |
315 |
||
316 |
| p | |
|
569 | 317 |
|
1054 | 318 |
p := UserPreferences current svnCommand. |
319 |
p isNil ifTrue:[ |
|
320 |
p := self class executable |
|
321 |
]. |
|
322 |
^p |
|
323 |
||
324 |
"Modified: / 12-03-2012 / 11:26:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10 | 325 |
! ! |
326 |
||
327 |
!Command methodsFor:'initialization'! |
|
328 |
||
329 |
initialize |
|
330 |
"Invoked when a new instance is created." |
|
331 |
||
332 |
"/ please change as required (and remove this comment) |
|
333 |
||
334 |
"/ super initialize. -- commented since inherited method does nothing |
|
335 |
||
336 |
"Created: / 16-03-2008 / 07:45:22 / janfrog" |
|
337 |
! ! |
|
338 |
||
339 |
!Command class methodsFor:'documentation'! |
|
340 |
||
341 |
version |
|
976 | 342 |
^ '$Header$' |
870
b5c82209345e
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
791
diff
changeset
|
343 |
|
163 | 344 |
! |
345 |
||
346 |
version_SVN |
|
870
b5c82209345e
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
791
diff
changeset
|
347 |
^ '§Id: SVN__Command.st 363 2011-08-08 13:49:48Z vranyj1 §' |
10 | 348 |
! ! |