author | penk |
Wed, 15 Dec 2004 11:32:43 +0100 | |
changeset 1407 | f8314a9474cf |
parent 1406 | 725a5b2866f2 |
child 1408 | 762e5320c296 |
permissions | -rw-r--r-- |
1362 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
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 |
||
13 |
"{ Package: 'stx:libbasic3' }" |
|
14 |
||
15 |
AbstractSourceCodeManager subclass:#CVSSourceCodeManager |
|
16 |
instanceVariableNames:'' |
|
17 |
classVariableNames:'Verbose CVSRoot CVSWorkDirectory RemoteCVS CVSBinDir |
|
18 |
CVSModuleRoots CMD_checkout CVSTempDir DisabledModules' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'System-SourceCodeManagement' |
|
21 |
! |
|
22 |
||
23 |
!CVSSourceCodeManager class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
130 | 26 |
" |
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
807
f84a9377278e
Fix .stxCvsDummy / import stuff.
Stefan Vogel <sv@exept.de>
parents:
806
diff
changeset
|
28 |
All Rights Reserved |
130 | 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 |
" |
|
1362 | 37 |
! |
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
SourceCodeManager which accesses the sourcecode through cvs. |
|
42 |
It requires the shell environment variable CVSROOT to be set |
|
43 |
to the top of the repository tree. (or alternatively, the CVSRoot |
|
44 |
variable being set by a private.rc file). |
|
45 |
Under that top, for each module (especially the stx module itself), |
|
46 |
a subdirectory containing that modules directories must exist. |
|
47 |
||
48 |
If not specified otherwise, the module defaults to 'stx'. |
|
49 |
If a class has its home in another module, it has to be compiled |
|
50 |
with a corresponding entry in the package string (see below). |
|
51 |
Within a module, classes are organized in classlibraries, and the corresponding |
|
52 |
source code is found in various subdirectories of CVSROOT. The directories |
|
53 |
name can also be provided by the package string - if not, it defaults to the |
|
54 |
libraries name. |
|
55 |
The package string controls all this, and is REQUIRED in order for the sourceCodeManager |
|
56 |
to be able to retrieve a classes source. |
|
57 |
The package strings format is: |
|
58 |
'...any infotext....(sourceCodeInfo)' |
|
59 |
the sourceCOdeInfo consists of multiple entries, separated by colons. |
|
60 |
The following formats are allowed: |
|
61 |
(libraryName) - module defaults to 'stx'; directory to the name of the library |
|
62 |
(foo/bar/x) - module defaults to 'stx'; dir is 'foo/bar/x'; library name defaults to x |
|
63 |
(module:directory:libname) - specifies all components |
|
64 |
The first formats are intermediate, for backward compatibility. We urge everyone |
|
65 |
to use the last format (by changing the Make.proto files and add a -P flag to |
|
66 |
the stc compiler flags (see libbasic/Make.proto as an example). |
|
67 |
||
68 |
Notice, that the sourceCodeManager is (currently) only consulted, if no |
|
69 |
source subdirectory exists, or no source file is found there. If it does exist, |
|
70 |
that one is supposed to contain an up-to-date version of the classes source |
|
71 |
(this is temporary - in the future the probe order will be reversed, trying |
|
72 |
the source repository first). |
|
73 |
The source directory is required for systems which do NO source code control. |
|
74 |
||
75 |
Setup: |
|
76 |
- make certain, that the commands 'cvs' and 'co' are available on your system. |
|
77 |
- add setup for the CVSROOT environment variable to your .bashrc / .login / .profile |
|
78 |
- Make certain that either no local source directory exists, or it is empty or it contains |
|
79 |
only source code for files NOT found in the repository (this will not be required in future versions). |
|
80 |
||
81 |
Caveat: |
|
82 |
currently, the rcs container is accessed directly, since cvs mangles the files ident-string and |
|
83 |
thus does not correctly recreate the original file (all source is offset by some characters w.r.t. the |
|
84 |
compiled file). |
|
85 |
Therefore, sevrer-mode CVS is not supported. |
|
86 |
||
87 |
[class variables:] |
|
88 |
CVSTempDir <String | nil> where a directory tree is |
|
89 |
generated temporarily for checkin/checkout |
|
1407 | 90 |
(default is nil -> systems tmp-dir) |
1362 | 91 |
|
92 |
CVSRoot <String> the CVS root. Imported from the |
|
93 |
CVSROOT shell variable. |
|
94 |
||
95 |
RemoteCVS <Boolean> if true, remote CVS access is used |
|
96 |
(i.e. via a socket to a CVS server). |
|
97 |
if false, disk access is used; |
|
98 |
files in CVSRoot must be accessable. |
|
99 |
||
100 |
CVSWorkDirectory not yet supported/implemented. |
|
101 |
PLANNED: name of a directory hierarchy, |
|
102 |
which is kept in sync with the current |
|
103 |
version. |
|
104 |
||
105 |
CVSBinDir where the CVS commands are found |
|
106 |
||
107 |
CVSModuleRoots <Directory> per-module roots. |
|
108 |
If empty, or no entry is found for a |
|
109 |
module is found, CVSRoot is used. |
|
110 |
Otherwise, specifies a per-module CVSRoot. |
|
111 |
(allows multiple CVS hierarchies) |
|
112 |
||
113 |
[author:] |
|
114 |
Claus Gittinger |
|
115 |
||
116 |
[see also:] |
|
117 |
( cvs manual page :man: cvs ) |
|
118 |
( Coding style used in Smalltalk/X classes :html: programming/codingStyle.html ) |
|
119 |
||
120 |
[restrictions:] |
|
121 |
commercial version only |
|
122 |
" |
|
123 |
! |
|
124 |
||
125 |
examples |
|
126 |
" |
|
127 |
Default setup: |
|
128 |
This setup accesses all sources from a single repository: /files/CVS. |
|
129 |
Actually, this is the setup as used within eXept for development. |
|
130 |
||
131 |
CVSSourceCodeManager initializeForRepository:'/files/CVS'. |
|
132 |
||
133 |
||
134 |
Dual repository setup: |
|
135 |
This accesses all ST/X standard classes' source from the /files/CVS |
|
136 |
repository, while your private classes are created in and accessed from |
|
137 |
'/files/myCVS'. |
|
138 |
This setup is useful, if you need revision management on the |
|
139 |
ST/X standard classes as well as for your own classes. |
|
140 |
In order to do this, you should (manually) check in all ST/X classes |
|
141 |
into a private repository WHILE preserving the original revision numbers. |
|
142 |
A shell-procedure similar to: |
|
143 |
||
144 |
for i in lib*/*.st |
|
145 |
do |
|
146 |
id=`ident $i` |
|
147 |
set $id |
|
148 |
rev=$3 |
|
149 |
ci -r$rev <CVSDIR>/$i $i |
|
150 |
done |
|
151 |
||
152 |
should acomplish this. |
|
153 |
Now, that you have all ST/X files in your own repository (and with the |
|
154 |
original revision numbers), access is possible by defining CVSROOT |
|
155 |
as above. However, in order to have your own files being stored in |
|
156 |
another repository, you have to give a per-module repository. |
|
157 |
||
158 |
This defines the default repository (for your containers): |
|
159 |
||
160 |
CVSSourceCodeManager initializeForRepository:'/files/myCVS'. |
|
161 |
||
162 |
and this specifies a repository for all standard ST/X classes (in the stx module): |
|
163 |
||
164 |
CVSSourceCodeManager repositoryName:'/files/CVS' forModule:'stx' |
|
165 |
||
166 |
Dual repository setup for eXept customers with a full licence |
|
167 |
(these can access our in-house master repository, for convenient software update |
|
168 |
and uploading): |
|
169 |
All class sourcees under the 'stx' module (i.e. packageID is 'stx:*') can be accessed |
|
170 |
from the eXept cvs server (i.e. CVSROOT for them is :pserver:userName@exept.de:/files/CVS/stc). |
|
171 |
All local classes should be maintained in and accessed from a local cvs repository |
|
172 |
such as '/files/myCVS'. |
|
173 |
||
174 |
Then, tell the CVSSourceCodeManager about this; |
|
175 |
first the default repository: |
|
176 |
||
177 |
CVSSourceCodeManager initializeForRepository:'/files/myCVS'. |
|
178 |
||
179 |
and the repository for all standard ST/X classes (in the stx module): |
|
180 |
||
181 |
CVSSourceCodeManager repositoryName:':pserver:userName@exept.de:/files/CVS' forModule:'stx' |
|
182 |
" |
|
183 |
! ! |
|
184 |
||
185 |
!CVSSourceCodeManager class methodsFor:'initialization'! |
|
186 |
||
187 |
forgetDisabledModules |
|
188 |
DisabledModules := nil. |
|
189 |
! |
|
190 |
||
191 |
initCommands |
|
192 |
CMD_checkout := 'cvs -n checkout %1'. |
|
193 |
! |
|
194 |
||
195 |
initialize |
|
196 |
"check if $CVSROOT (the shell variable) or CVSRoot (the smalltalk global) |
|
197 |
is set, check if cvs commands can be executed and install myself as the |
|
198 |
SourceCodeManager if this works out ok" |
|
199 |
||
200 |
| s f top ok triedPath cvsCmd cmdName | |
|
201 |
||
202 |
DisabledModules := nil. |
|
203 |
||
204 |
"/ |
|
205 |
"/ if CVSROOT is non-empty and both cvs and co are available |
|
206 |
"/ as commands, assume this system uses a cvs source code management. |
|
207 |
"/ |
|
208 |
CVSRoot ifNil:[ |
|
1407 | 209 |
CVSRoot := OperatingSystem getEnvironment:'CVSROOT'. |
210 |
CVSRoot ifNil:[ |
|
211 |
"disabled since $CVSROOT is not set" |
|
212 |
^ self |
|
213 |
]. |
|
1362 | 214 |
]. |
215 |
||
216 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
217 |
cvsCmd := 'cvs.exe' |
|
218 |
] ifFalse:[ |
|
219 |
cvsCmd := 'cvs' |
|
220 |
]. |
|
221 |
||
222 |
CVSBinDir size > 0 ifTrue:[ |
|
223 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
224 |
cmdName := CVSBinDir asFilename constructString:cvsCmd. |
|
225 |
( OperatingSystem canExecuteCommand:cmdName) ifFalse:[ |
|
226 |
CVSBinDir := ''. |
|
227 |
] ifTrue:[ |
|
228 |
CVSBinDir := CVSBinDir asFilename pathName |
|
229 |
] |
|
230 |
] |
|
231 |
]. |
|
232 |
||
233 |
CVSBinDir size == 0 ifTrue:[ |
|
234 |
CVSBinDir := ''. |
|
235 |
(ok := OperatingSystem canExecuteCommand:cvsCmd) ifFalse:[ |
|
236 |
"/ mhmh - no cvs; |
|
237 |
||
238 |
OperatingSystem isUNIXlike ifTrue:[ |
|
239 |
triedPath := #( '/usr/local/bin' ). |
|
240 |
] ifFalse:[ |
|
241 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
242 |
triedPath := Array with:'c:\bin' |
|
243 |
with:(Filename currentDirectory pathName) |
|
244 |
with:(OperatingSystem stxBinDirPath ? 'c:\windows'). |
|
245 |
] ifFalse:[ |
|
246 |
triedPath := #() |
|
247 |
] |
|
248 |
]. |
|
249 |
||
250 |
triedPath do:[:eachTriedDir | |
|
251 |
ok ifFalse:[ |
|
252 |
(OperatingSystem canExecuteCommand:(eachTriedDir asFilename constructString:cvsCmd)) ifTrue:[ |
|
253 |
ok := true. |
|
254 |
CVSBinDir := eachTriedDir. |
|
255 |
] |
|
256 |
] |
|
257 |
]. |
|
258 |
]. |
|
259 |
] ifFalse:[ |
|
260 |
ok := OperatingSystem canExecuteCommand:(CVSBinDir asFilename constructString:cvsCmd). |
|
261 |
]. |
|
262 |
||
263 |
ok ifFalse:[ |
|
264 |
'CVSSourceCodeManager [warning]: disabled since no >> cvs << command found' infoPrintCR. |
|
265 |
^ self |
|
266 |
]. |
|
267 |
||
268 |
"/ (OperatingSystem canExecuteCommand:(CVSBinDir , 'co')) ifFalse:[ |
|
269 |
"/ 'CVSSourceCodeManager [warning]: limited functionality - no >> co << command found' infoPrintCR. |
|
270 |
"/ ]. |
|
271 |
"/ (OperatingSystem canExecuteCommand:(CVSBinDir , 'rlog')) ifFalse:[ |
|
272 |
"/ 'CVSSourceCodeManager [warning]: limited functionality - no >> rlog << command found' infoPrintCR. |
|
273 |
"/ ]. |
|
274 |
"/ (OperatingSystem canExecuteCommand:(CVSBinDir , 'patch')) ifFalse:[ |
|
275 |
"/ 'CVSSourceCodeManager [warning]: limited functionality - no >> patch << command found' infoPrintCR. |
|
276 |
"/ ]. |
|
277 |
||
278 |
RemoteCVS := true. |
|
279 |
UseWorkTree := false. |
|
280 |
||
281 |
CacheDirectoryName ifNil:[ |
|
282 |
self initCacheDirPath. |
|
283 |
]. |
|
284 |
CachingSources ifNil:[ |
|
285 |
CachingSources := true. |
|
286 |
]. |
|
287 |
||
288 |
"/ |
|
289 |
"/ check if there is an stx directory there |
|
290 |
"/ |
|
291 |
((f := CVSRoot asFilename) isDirectory |
|
292 |
and:[(top := f construct:'stx') isDirectory |
|
293 |
and:[top isReadable]]) ifTrue:[ |
|
294 |
RemoteCVS := false |
|
295 |
]. |
|
296 |
||
297 |
Smalltalk at:#SourceCodeManager put:self. |
|
298 |
DefaultManager := self. |
|
299 |
||
300 |
('CVSSourceCodeManager [info]: repository CVSROOT is ''' , CVSRoot , '''.') infoPrintCR. |
|
301 |
RemoteCVS ifTrue:[ |
|
302 |
'CVSSourceCodeManager [info]: assume remote CVS mode (no stx found in CVSROOT)' infoPrintCR. |
|
303 |
^ self |
|
304 |
]. |
|
305 |
||
306 |
"/ |
|
307 |
"/ optionally set the WorkTreeDirectoryName from $STX_WORKTREE; |
|
308 |
"/ if non-nil, a working tree is kept there |
|
309 |
"/ and updated/commited files are not removed. |
|
310 |
"/ If you use a regular (make-) tree, |
|
311 |
"/ set WorkTreeDirectoryName (or the environment variable) to that. |
|
312 |
"/ |
|
313 |
"/ this is not yet finished. |
|
314 |
"/ |
|
315 |
s := OperatingSystem getEnvironment:'STX_WORKTREE'. |
|
316 |
s notNil ifTrue:[ |
|
317 |
WorkTreeDirectoryName := s. |
|
318 |
UseWorkTree := true. |
|
319 |
] |
|
320 |
||
321 |
" |
|
322 |
AbstractSourceCodeManager initialize |
|
323 |
CVSSourceCodeManager initialize |
|
324 |
" |
|
325 |
||
326 |
" |
|
327 |
CVSRoot := '/files/CVS'. |
|
328 |
AbstractSourceCodeManager initialize. |
|
329 |
CVSSourceCodeManager initialize. |
|
330 |
" |
|
331 |
||
332 |
"Created: / 4.11.1995 / 19:14:38 / cg" |
|
333 |
"Modified: / 19.12.1995 / 14:25:46 / stefan" |
|
334 |
"Modified: / 5.12.2001 / 18:52:00 / cg" |
|
335 |
! |
|
336 |
||
337 |
initializeForRepository:aDirectoryName |
|
338 |
"set the global CVSROOT directory (i.e. the repositories name). |
|
339 |
And reinitialize. |
|
340 |
Can be used from the launcher to change/configure the repository." |
|
341 |
||
342 |
self repositoryName:aDirectoryName. |
|
343 |
AbstractSourceCodeManager initialize. |
|
344 |
CVSSourceCodeManager initialize. |
|
345 |
||
346 |
" |
|
347 |
CVSSourceCodeManager initializeForRepository:'/files/CVS' |
|
348 |
CVSSourceCodeManager initializeForRepository:'ibm:/files/CVS' |
|
349 |
" |
|
350 |
||
351 |
"Created: / 13.8.1997 / 17:20:57 / cg" |
|
352 |
"Modified: / 25.9.1997 / 12:28:05 / stefan" |
|
353 |
"Modified: / 2.11.1997 / 17:08:27 / cg" |
|
354 |
! ! |
|
355 |
||
356 |
!CVSSourceCodeManager class methodsFor:'accessing'! |
|
357 |
||
358 |
cvsBinDirectory |
|
359 |
"return the name of the bin repository. |
|
360 |
Thats the directory, where the cvs / cvs.exe command is found." |
|
361 |
||
362 |
^ CVSBinDir |
|
363 |
! |
|
364 |
||
365 |
cvsBinDirectory:aString |
|
366 |
"set the name of the bin repository. |
|
367 |
Thats the directory, where the cvs / cvs.exe command is found." |
|
368 |
||
369 |
aString isEmpty ifTrue:[ |
|
370 |
CVSBinDir := aString |
|
371 |
] ifFalse:[ |
|
372 |
CVSBinDir := aString asFilename pathName. |
|
373 |
(CVSBinDir endsWith:Filename separator) ifTrue:[ |
|
374 |
CVSBinDir := CVSBinDir copyWithoutLast:1. |
|
375 |
] |
|
376 |
]. |
|
377 |
! |
|
378 |
||
1407 | 379 |
cvsTmpDirectory |
380 |
"return the name of the tmp repository. |
|
381 |
Thats the directory, where temporary files are created for checkin/checkout. |
|
382 |
If nil, the systems default tempDirectory is used." |
|
383 |
||
384 |
^ (CVSTempDir ? Filename tempDirectory pathName) |
|
385 |
||
386 |
" |
|
387 |
CVSTempDir := nil |
|
388 |
" |
|
389 |
! |
|
390 |
||
391 |
cvsTmpDirectory:aPathNameString |
|
392 |
"set the name of the tmp repository. |
|
393 |
Thats the directory, where temporary files are created for checkin/checkout. |
|
394 |
If nil, the systems default tempDirectory is used." |
|
395 |
||
396 |
CVSTempDir := aPathNameString |
|
397 |
! |
|
398 |
||
1362 | 399 |
repositoryName |
400 |
"return the name of the global repository. |
|
401 |
This is used, if no per-module repository is defined." |
|
402 |
||
403 |
^ CVSRoot |
|
404 |
||
405 |
"Created: 14.9.1996 / 13:22:05 / cg" |
|
406 |
"Modified: 19.9.1997 / 06:12:02 / cg" |
|
407 |
! |
|
408 |
||
409 |
repositoryName:aDirectoryName |
|
410 |
"set the name of the repository; |
|
411 |
thats the name of the global CVSROOT directory, which is used |
|
412 |
if no specific repository was defined for a module. |
|
413 |
Can be used from an rc-script, to override the CVSROOT shell |
|
414 |
variable setting." |
|
415 |
||
416 |
DisabledModules := nil. |
|
417 |
CVSRoot := aDirectoryName. |
|
418 |
||
419 |
"Created: 14.9.1996 / 13:22:24 / cg" |
|
420 |
"Modified: 19.9.1997 / 06:10:31 / cg" |
|
421 |
! |
|
422 |
||
423 |
repositoryName:aRepositoryName forModule:aModuleName |
|
424 |
"set the CVSROOT directory which provides the sources for all |
|
425 |
classes in a particular module. |
|
426 |
This can be used from an rc-script, to specify a repository |
|
427 |
for a particular module. |
|
428 |
If left unspecified, the global (i.e. fallBack) repository is used." |
|
429 |
||
430 |
DisabledModules := nil. |
|
431 |
CVSModuleRoots isNil ifTrue:[ |
|
432 |
CVSModuleRoots := Dictionary new. |
|
433 |
]. |
|
434 |
CVSModuleRoots at:aModuleName put:aRepositoryName |
|
435 |
||
436 |
"Modified: 19.9.1997 / 06:09:40 / cg" |
|
437 |
! |
|
438 |
||
439 |
repositoryNameForModule:aModuleName |
|
440 |
"return the CVSROOT directory which provides the sources for all |
|
441 |
classes in a particular module. |
|
442 |
Nil is returned for unspecified moduleRoots; in this case, |
|
443 |
the global (i.e. fallBack) repository will be used for source access." |
|
444 |
||
445 |
CVSModuleRoots isNil ifTrue:[^nil]. |
|
446 |
^ CVSModuleRoots at:aModuleName ifAbsent:nil. |
|
447 |
||
448 |
"Modified: 19.9.1997 / 06:09:40 / cg" |
|
449 |
"Created: 19.9.1997 / 06:13:06 / cg" |
|
450 |
! |
|
451 |
||
452 |
repositoryNamesPerModule |
|
453 |
"return the dictionary, which associates CVSRoots to module names. |
|
454 |
If no entry is contained in this dictionary for some module, |
|
455 |
the default cvsRoot (CVSRoot) will be used." |
|
456 |
||
457 |
^ CVSModuleRoots ? (Dictionary new) |
|
458 |
! |
|
459 |
||
460 |
repositoryNamesPerModule:aDictionary |
|
461 |
"set the dictionary, which associates CVSRoots to module names. |
|
462 |
If no entry is contained in this dictionary for some module, |
|
463 |
the default cvsRoot (CVSRoot) will be used." |
|
464 |
||
465 |
CVSModuleRoots := aDictionary |
|
466 |
! ! |
|
467 |
||
468 |
!CVSSourceCodeManager class methodsFor:'private'! |
|
469 |
||
470 |
checkOut:relativeFilename module:moduleDir in:tempdir |
|
471 |
"checkout realtiveFilename in tempdir" |
|
472 |
||
473 |
|cmd| |
|
474 |
||
475 |
cmd := 'checkout -l ' , relativeFilename. |
|
476 |
^ self |
|
477 |
executeCVSCommand:cmd |
|
478 |
module:moduleDir |
|
479 |
inDirectory:tempdir name |
|
480 |
log:false |
|
481 |
||
482 |
||
483 |
" |
|
484 |
self checkOut:'stx/libbasic/Integer.st' asFilename in:'/tmp' asFilename |
|
485 |
" |
|
486 |
||
487 |
"Created: / 18.1.2000 / 20:30:01 / cg" |
|
488 |
"Modified: / 18.1.2000 / 20:35:06 / cg" |
|
489 |
! |
|
490 |
||
491 |
checkinTroubleDialog:title message:message log:log abortable:abortable option:optionTitle |
|
492 |
"trouble checking in - open a dialog" |
|
493 |
||
494 |
^ self |
|
495 |
checkinTroubleDialog:title |
|
496 |
message:message |
|
497 |
log:log |
|
498 |
abortable:abortable |
|
499 |
option:optionTitle |
|
500 |
option2:nil |
|
501 |
||
502 |
"Created: 10.12.1995 / 17:34:33 / cg" |
|
503 |
"Modified: 12.9.1996 / 02:39:06 / cg" |
|
504 |
! |
|
505 |
||
506 |
checkinTroubleDialog:title message:message log:log abortable:abortable option:optionTitle option2:optionTitle2 |
|
507 |
^self |
|
508 |
checkinTroubleDialog:title |
|
509 |
message:message |
|
510 |
log:log |
|
511 |
abortable:abortable |
|
512 |
option:optionTitle |
|
513 |
option2:optionTitle2 |
|
514 |
option3:nil |
|
515 |
! |
|
516 |
||
517 |
checkinTroubleDialog:title message:message log:log abortable:abortable option:optionTitle option2:optionTitle2 option3:optionTitle3 |
|
518 |
"trouble checking in - open a dialog" |
|
519 |
||
520 |
|l box list listView optionPressed option2Pressed option3Pressed| |
|
521 |
||
522 |
l := log collect:[:line | line withTabsExpanded]. |
|
523 |
list := SelectionInList with:l. |
|
524 |
||
525 |
box := Dialog new. |
|
526 |
box label:(title). |
|
527 |
||
528 |
(box addTextLabel:message) borderWidth:0. |
|
529 |
||
530 |
listView := SelectionInListView on:list. |
|
531 |
listView disable. |
|
532 |
listView height:200. |
|
533 |
box addComponent:(HVScrollableView forView:listView miniScrollerH:true) tabable:false. |
|
534 |
box addVerticalSpace. |
|
535 |
||
536 |
abortable ifTrue:[ |
|
537 |
box addAbortButton |
|
538 |
]. |
|
539 |
optionTitle notNil ifTrue:[ |
|
540 |
box addOkButton:(Button label:optionTitle action:[optionPressed := true. box hide]). |
|
541 |
]. |
|
542 |
optionTitle2 notNil ifTrue:[ |
|
543 |
box addOkButton:(Button label:optionTitle2 action:[option2Pressed := true. box hide]). |
|
544 |
]. |
|
545 |
optionTitle3 notNil ifTrue:[ |
|
546 |
box addOkButton:(Button label:optionTitle3 action:[option3Pressed := true. box hide]). |
|
547 |
]. |
|
548 |
box addOkButton. |
|
549 |
||
550 |
box extent:(box preferredExtent). |
|
551 |
box minExtent:box extent. |
|
552 |
box maxExtent:box extent. |
|
553 |
||
554 |
box open. |
|
555 |
||
556 |
box destroy. |
|
557 |
optionPressed == true ifTrue:[^ #option]. |
|
558 |
option2Pressed == true ifTrue:[^ #option2]. |
|
559 |
option3Pressed == true ifTrue:[^ #option3]. |
|
560 |
^ box accepted |
|
561 |
||
562 |
"Created: 9.9.1996 / 19:12:45 / cg" |
|
563 |
"Modified: 12.9.1996 / 02:39:10 / cg" |
|
564 |
! |
|
565 |
||
566 |
createEntryFor:pathInRepository module:aModule in:aDirectory revision:rev date:date special:special overwrite:overwrite |
|
567 |
"create an CVS/Repository and CVS/Entries entry for filename. |
|
568 |
If the path does not exist, it will be created |
|
569 |
If overwrite is true, an existing Entry will be overwritten. |
|
570 |
" |
|
571 |
||
572 |
|filename cvsRoot cvsDir name entries firstPart s path| |
|
573 |
||
574 |
filename := pathInRepository asFilename. |
|
575 |
cvsDir := (aDirectory asFilename construct:'CVS') recursiveMakeDirectory. |
|
576 |
entries := cvsDir construct:'Entries'. |
|
577 |
name := filename baseName. |
|
578 |
firstPart := '/', name, '/'. |
|
579 |
||
580 |
s := entries readStreamOrNil. |
|
581 |
s isNil ifTrue:[ |
|
582 |
"/ |
|
583 |
"/ no Repository yet, create one |
|
584 |
"/ |
|
585 |
|index root| |
|
586 |
||
587 |
cvsRoot := self getCVSROOTForModule:aModule. |
|
588 |
"/ |
|
589 |
"/ match for first '/', to get the path portion without :pserver:host: |
|
590 |
"/ |
|
591 |
index := cvsRoot indexOf:$/. |
|
592 |
index > 0 ifTrue:[ |
|
593 |
root := cvsRoot copyFrom:(index). |
|
594 |
] ifFalse:[ |
|
595 |
root := cvsRoot. |
|
596 |
]. |
|
597 |
"/ create Repository |
|
598 |
"/ (notice, contents must be a Unix filename ... |
|
599 |
||
600 |
s := (cvsDir construct:'Repository') writeStream. |
|
601 |
path := Filename components:filename directory name. |
|
602 |
path := path asStringWith:$/. |
|
603 |
s nextPutLine:(root, '/', path). |
|
604 |
s close. |
|
605 |
||
606 |
"/ make new Entries file. |
|
607 |
s := entries writeStream. |
|
608 |
] ifFalse:[ |
|
609 |
|newName newStream line| |
|
610 |
||
611 |
newName := Filename newTemporaryIn:cvsDir. |
|
612 |
newStream := newName writeStream. |
|
613 |
[(line := s nextLine) notNil] whileTrue:[ |
|
614 |
(line findString:firstPart) ~= 1 ifTrue:[ |
|
615 |
"/ we have found an entry for ourself. |
|
616 |
"/ If we do not want to overwrite it, clean up everything and return. |
|
617 |
overwrite ifFalse:[ |
|
618 |
newName remove. |
|
619 |
newStream close. |
|
620 |
s close. |
|
621 |
^ self |
|
622 |
]. |
|
623 |
newStream nextPutLine:line |
|
624 |
]. |
|
625 |
]. |
|
626 |
newName renameTo:entries. |
|
627 |
s close. |
|
628 |
s := newStream. |
|
629 |
]. |
|
630 |
s nextPutLine:firstPart, rev, '/', date, '/', special, '/'. |
|
631 |
s close. |
|
632 |
||
633 |
" |
|
634 |
self createEntryFor:'foo/xxx/yyy' in:'foo/xxx' revision:'1.22' date:'dummy' special:'' |
|
635 |
self createEntryFor:'foo/xxx/yyy' in:'foo/xxx' revision:'3.44' date:'new dummy' special:'special' |
|
636 |
" |
|
637 |
||
638 |
"Created: / 19.9.1997 / 06:21:02 / cg" |
|
639 |
"Modified: / 7.1.1998 / 14:15:35 / stefan" |
|
640 |
"Modified: / 20.8.1998 / 00:12:11 / cg" |
|
641 |
! |
|
642 |
||
643 |
createLocalDirectory:packageDir inModule:moduleDir |
|
644 |
"create a local working directory for module/package. |
|
645 |
To speed up things, we checkout the file '.cvsignore', to create |
|
646 |
the whole tree. If the file is not present, we will create it as empty file. |
|
647 |
Return the name of a temporary directory containing the package" |
|
648 |
||
649 |
^ self |
|
650 |
createLocalDirectory:packageDir |
|
651 |
inModule:moduleDir |
|
652 |
with:'.cvsignore' |
|
653 |
||
654 |
" |
|
655 |
self createLocalDirectory:'libbasic' inModule:'stx' |
|
656 |
" |
|
657 |
||
658 |
"Created: / 23.7.1999 / 19:14:28 / stefan" |
|
659 |
"Modified: / 26.7.1999 / 17:43:35 / stefan" |
|
660 |
"Modified: / 18.1.2000 / 20:56:19 / cg" |
|
661 |
! |
|
662 |
||
663 |
createLocalDirectory:packageDir inModule:moduleDir with:fileToCheckout |
|
664 |
"create a local working directory for module/package, and checkout the |
|
665 |
given file there. |
|
666 |
Return the name of a temporary directory containing the package, or nil" |
|
667 |
||
668 |
|path absolutePath tempdir workingDir unixPath| |
|
669 |
||
670 |
path := (moduleDir asFilename construct:packageDir) construct:fileToCheckout. |
|
671 |
||
672 |
tempdir := self createTempDirectory:nil forModule:nil. |
|
673 |
tempdir isNil ifTrue:[ |
|
674 |
('CVSSourceCodeManager [error]: no tempDir - cannot checkout') errorPrintCR. |
|
675 |
^ nil |
|
676 |
]. |
|
677 |
||
678 |
[ |
|
679 |
OperatingSystem isUNIXlike ifTrue:[ |
|
680 |
unixPath := path name. |
|
681 |
] ifFalse:[ |
|
682 |
OperatingSystem isVMSlike ifTrue:[ |
|
683 |
self error:'VMS case not yet implemented' |
|
684 |
]. |
|
685 |
unixPath := path name copy replaceAll:$\ with:$/ |
|
686 |
]. |
|
687 |
||
688 |
(self checkOut:unixPath module:moduleDir in:tempdir) ifFalse:[ |
|
689 |
"dummy file does not exist, so create it" |
|
690 |
||
691 |
absolutePath := tempdir construct:path. |
|
692 |
absolutePath directory recursiveMakeDirectory. |
|
693 |
"now create the file" |
|
694 |
(absolutePath writeStream close) isNil ifTrue:[ |
|
695 |
('CVSSourceCodeManager [error]: cannot create dummy') errorPrintCR. |
|
696 |
tempdir recursiveRemove. |
|
697 |
^ nil. |
|
698 |
]. |
|
699 |
||
700 |
"now create the dummy file in the repository" |
|
701 |
(self import:moduleDir in:tempdir) ifFalse:[ |
|
702 |
('CVSSourceCodeManager [error]: cannot import dummy') errorPrintCR. |
|
703 |
]. |
|
704 |
||
705 |
"remove the path, so that checkout works" |
|
706 |
(tempdir construct:moduleDir) recursiveRemove. |
|
707 |
||
708 |
"checkout the dummy, the intermediate directories will be created" |
|
709 |
(self checkOut:unixPath module:moduleDir in:tempdir) ifFalse:[ |
|
710 |
('CVSSourceCodeManager [warning]: import failed (to create working dir)') errorPrintCR. |
|
711 |
"/false ifTrue:[ |
|
712 |
"/ "/ manually create it |
|
713 |
"/ |
|
714 |
"/ (tempdir construct:unixPath) directory recursiveMakeDirectory. |
|
715 |
"/ workingDir := tempdir. |
|
716 |
"/ unixPath asFilename directory components do:[:each | |
|
717 |
"/ self executeCVSCommand:('add ' , each) module:moduleDir inDirectory:workingDir. |
|
718 |
"/ workingDir := workingDir construct:each. |
|
719 |
"/ ]. |
|
720 |
"/ (absolutePath writeStream close) isNil ifTrue:[ |
|
721 |
"/ ('CVSSourceCodeManager [error]: cannot create dummy') errorPrintCR. |
|
722 |
"/ tempdir recursiveRemove. |
|
723 |
"/ ^ nil. |
|
724 |
"/ ]. |
|
725 |
"/ self executeCVSCommand:('add ' , fileToCheckout) module:moduleDir inDirectory:workingDir. |
|
726 |
"/ self executeCVSCommand:('commit ' , fileToCheckout) module:moduleDir inDirectory:workingDir. |
|
727 |
"/ |
|
728 |
"/ ^ tempdir |
|
729 |
"/]. |
|
730 |
tempdir recursiveRemove. |
|
731 |
^ nil. |
|
732 |
]. |
|
733 |
]. |
|
1406 | 734 |
] ifCurtailed:[ |
1362 | 735 |
tempdir recursiveRemove. |
736 |
]. |
|
737 |
||
738 |
^ tempdir. |
|
739 |
||
740 |
" |
|
741 |
self createLocalDirectory:'libbasic' inModule:'stx' |
|
742 |
" |
|
743 |
||
744 |
"Modified: / 26.7.1999 / 17:43:35 / stefan" |
|
745 |
"Created: / 18.1.2000 / 20:55:52 / cg" |
|
746 |
"Modified: / 18.1.2000 / 20:56:45 / cg" |
|
747 |
! |
|
748 |
||
749 |
createTempDirectory:packageDir forModule:moduleDir |
|
750 |
"create a temp directory for checking out" |
|
751 |
||
752 |
|tempdir dir| |
|
753 |
||
754 |
"/ if CVSTempDir isNil, use current. |
|
1407 | 755 |
tempdir := Filename newTemporaryIn:(self cvsTmpDirectory). |
1362 | 756 |
tempdir exists ifTrue:[ |
757 |
tempdir recursiveRemove. |
|
758 |
]. |
|
759 |
OperatingSystem errorSignal handle:[:ex | |
|
760 |
'SourceCodemanager [error]: cannot create temporary directory' errorPrintCR. |
|
761 |
^ nil. |
|
762 |
] do:[ |
|
763 |
tempdir makeDirectory. |
|
764 |
]. |
|
765 |
||
766 |
moduleDir notNil ifTrue:[ |
|
767 |
dir := tempdir construct:moduleDir. |
|
768 |
dir makeDirectory. |
|
769 |
||
770 |
packageDir notNil ifTrue:[ |
|
771 |
dir := dir construct:packageDir. |
|
772 |
dir recursiveMakeDirectory. |
|
773 |
]. |
|
774 |
dir exists ifFalse:[ |
|
775 |
tempdir recursiveRemove. |
|
776 |
'SourceCodemanager [error]: cannot create temporary directory' errorPrintCR. |
|
777 |
^ nil. |
|
778 |
]. |
|
779 |
]. |
|
780 |
^ tempdir |
|
781 |
||
782 |
"self createTempDirectory:'fooPackage' forModule:'fooModule'" |
|
783 |
||
784 |
"Created: 9.12.1995 / 19:14:35 / cg" |
|
785 |
"Modified: 19.12.1995 / 16:13:02 / stefan" |
|
786 |
"Modified: 18.8.1997 / 19:06:52 / cg" |
|
787 |
! |
|
788 |
||
789 |
cvsTimeString:absoluteTime |
|
1388
6fae02877da5
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
1387
diff
changeset
|
790 |
"convert a Timestamp to a string suitable for the CVS/Entries file: |
1362 | 791 |
|
792 |
123456789012345678901234 |
|
793 |
Tue Dec 19 20:56:26 1995 |
|
794 |
" |
|
795 |
||
796 |
|date time stream| |
|
797 |
||
798 |
date := absoluteTime asDate. |
|
799 |
time := absoluteTime asTime. |
|
800 |
stream := WriteStream on:(String new:24). |
|
801 |
||
802 |
(#('Mon' 'Tue' 'Wed' 'Thu' 'Fri' 'Sat' 'Sun') at:(date dayInWeek)) printOn:stream. |
|
803 |
stream space. |
|
804 |
||
805 |
(#('Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec') |
|
806 |
at:(date month)) printOn:stream. |
|
807 |
stream space. |
|
808 |
||
809 |
date day printOn:stream. |
|
810 |
stream space. |
|
811 |
||
812 |
time print24HourFormatOn: stream. |
|
813 |
stream space. |
|
814 |
||
815 |
date year printOn:stream. |
|
816 |
||
817 |
^ stream contents |
|
818 |
||
819 |
||
820 |
" |
|
1388
6fae02877da5
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
1387
diff
changeset
|
821 |
CVSSourceCodeManager cvsTimeString:(Timestamp now) |
1362 | 822 |
" |
823 |
||
824 |
"Modified: 20.12.1995 / 11:03:32 / stefan" |
|
825 |
! |
|
826 |
||
827 |
executeCVSCommand:cvsCommand module:moduleName inDirectory:dir |
|
828 |
"execute command and prepend cvs command name and global options. |
|
829 |
if dir ~= nil, execute command in that directory. |
|
830 |
This also leads to a log-entry to be added to cvs's logfile." |
|
831 |
||
832 |
^ self |
|
833 |
executeCVSCommand:cvsCommand |
|
834 |
module:moduleName |
|
835 |
inDirectory:dir |
|
836 |
log:true |
|
837 |
||
838 |
"Modified: / 20.5.1998 / 16:07:28 / cg" |
|
839 |
! |
|
840 |
||
841 |
executeCVSCommand:cvsCommand module:moduleName inDirectory:dir log:doLog |
|
842 |
"execute command and prepend cvs command name and global options. |
|
843 |
if dir ~= nil, execute command in that directory. |
|
844 |
The doLog argument, if false supresses a logEntry to be added |
|
845 |
in the cvs log file (used when reading / extracting history)" |
|
846 |
||
847 |
^ self |
|
848 |
executeCVSCommand:cvsCommand module:moduleName inDirectory:dir log:doLog |
|
849 |
pipe:false |
|
850 |
! |
|
851 |
||
1390
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
852 |
executeCVSCommand:cvsCommand module:moduleName inDirectory:dirArg log:doLog errorTo:errorStream |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
853 |
"execute command and prepend cvs command name and global options. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
854 |
execute command in the dirArg directory. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
855 |
The doLog argument, if false supresses a logEntry to be added |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
856 |
in the cvs log file (used when reading / extracting history)" |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
857 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
858 |
|command cvsRoot rslt ok pathOfDir p dir| |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
859 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
860 |
dir := dirArg asFilename. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
861 |
pathOfDir := dir pathName. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
862 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
863 |
cvsRoot := self getCVSROOTForModule:moduleName. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
864 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
865 |
command := CVSBinDir. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
866 |
command size > 0 ifTrue:[ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
867 |
(command endsWith:Filename separator) ifFalse:[ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
868 |
command := command , (Filename separator) |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
869 |
] |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
870 |
]. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
871 |
command := command , 'cvs'. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
872 |
(command includes:Character space) ifTrue:[ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
873 |
command := '"' , command , '"' |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
874 |
]. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
875 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
876 |
doLog ifFalse:[ |
1393
28d04a5111c6
cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents:
1390
diff
changeset
|
877 |
"/ cvs 1.11.14 fails with -l option |
28d04a5111c6
cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents:
1390
diff
changeset
|
878 |
"/ command := command , ' -l'. |
1390
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
879 |
]. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
880 |
command := command , ' -d "', cvsRoot, '" ', cvsCommand. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
881 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
882 |
Verbose == true ifTrue:[ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
883 |
('CVSSourceCodeManager [info]: executing: ' , command , ' [in ' , pathOfDir , ']') infoPrintCR. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
884 |
]. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
885 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
886 |
Processor isDispatching ifFalse:[ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
887 |
rslt := ok := OperatingSystem executeCommand:command |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
888 |
inputFrom:nil |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
889 |
outputTo:nil |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
890 |
errorTo:errorStream |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
891 |
auxFrom:nil |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
892 |
inDirectory:pathOfDir |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
893 |
lineWise:false |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
894 |
onError:[:status| false]. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
895 |
] ifTrue:[ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
896 |
p := [ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
897 |
rslt := ok := OperatingSystem executeCommand:command |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
898 |
inputFrom:nil |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
899 |
outputTo:nil |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
900 |
errorTo:errorStream |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
901 |
auxFrom:nil |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
902 |
inDirectory:pathOfDir |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
903 |
lineWise:false |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
904 |
onError:[:status| false]. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
905 |
] fork. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
906 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
907 |
(p waitUntilTerminatedWithTimeout:300) ifTrue:[ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
908 |
('CVSSourceCodeManager [info]: command timeout: ' , command) errorPrintCR. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
909 |
^ false |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
910 |
]. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
911 |
]. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
912 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
913 |
ok ifFalse:[ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
914 |
('CVSSourceCodeManager [info]: command failed: ' , command) errorPrintCR. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
915 |
]. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
916 |
^ rslt |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
917 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
918 |
"Modified: / 23.4.1996 / 15:24:00 / stefan" |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
919 |
"Created: / 20.5.1998 / 16:06:34 / cg" |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
920 |
"Modified: / 19.5.1999 / 10:43:57 / cg" |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
921 |
! |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
922 |
|
1362 | 923 |
executeCVSCommand:cvsCommand module:moduleName inDirectory:dirArg log:doLog pipe:doPipe |
924 |
"execute command and prepend cvs command name and global options. |
|
925 |
execute command in the dirArg directory. |
|
926 |
The doLog argument, if false supresses a logEntry to be added |
|
927 |
in the cvs log file (used when reading / extracting history)" |
|
928 |
||
929 |
|command cvsRoot rslt ok pathOfDir p dir| |
|
930 |
||
931 |
dir := dirArg asFilename. |
|
932 |
pathOfDir := dir pathName. |
|
933 |
||
934 |
cvsRoot := self getCVSROOTForModule:moduleName. |
|
935 |
||
936 |
command := CVSBinDir. |
|
937 |
command size > 0 ifTrue:[ |
|
938 |
(command endsWith:Filename separator) ifFalse:[ |
|
1387 | 939 |
command := command , (Filename separator) |
1362 | 940 |
] |
941 |
]. |
|
942 |
command := command , 'cvs'. |
|
943 |
(command includes:Character space) ifTrue:[ |
|
944 |
command := '"' , command , '"' |
|
945 |
]. |
|
946 |
||
947 |
doLog ifFalse:[ |
|
1393
28d04a5111c6
cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents:
1390
diff
changeset
|
948 |
"/ cvs 1.11.14 fails with -l option |
28d04a5111c6
cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents:
1390
diff
changeset
|
949 |
"/ command := command , ' -l'. |
1362 | 950 |
]. |
951 |
command := command , ' -d "', cvsRoot, '" ', cvsCommand. |
|
952 |
||
953 |
Verbose == true ifTrue:[ |
|
954 |
('CVSSourceCodeManager [info]: executing: ' , command , ' [in ' , pathOfDir , ']') infoPrintCR. |
|
955 |
]. |
|
956 |
||
957 |
doPipe ifTrue:[ |
|
958 |
rslt := PipeStream readingFrom:command inDirectory:pathOfDir. |
|
959 |
ok := rslt notNil. |
|
960 |
] ifFalse:[ |
|
961 |
Processor isDispatching ifFalse:[ |
|
962 |
rslt := ok := OperatingSystem executeCommand:command inDirectory:pathOfDir. |
|
963 |
] ifTrue:[ |
|
964 |
p := [ |
|
965 |
rslt := ok := OperatingSystem executeCommand:command inDirectory:pathOfDir. |
|
966 |
] fork. |
|
967 |
||
968 |
(p waitUntilTerminatedWithTimeout:300) ifTrue:[ |
|
969 |
('CVSSourceCodeManager [info]: command timeout: ' , command) errorPrintCR. |
|
970 |
^ false |
|
971 |
]. |
|
972 |
]. |
|
973 |
]. |
|
974 |
||
975 |
ok ifFalse:[ |
|
976 |
('CVSSourceCodeManager [info]: command failed: ' , command) errorPrintCR. |
|
977 |
]. |
|
978 |
^ rslt |
|
979 |
||
980 |
"Modified: / 23.4.1996 / 15:24:00 / stefan" |
|
981 |
"Created: / 20.5.1998 / 16:06:34 / cg" |
|
982 |
"Modified: / 19.5.1999 / 10:43:57 / cg" |
|
983 |
! |
|
984 |
||
985 |
getCVSROOTForModule:aModuleName |
|
986 |
"internal: used when accessing a source repository. |
|
987 |
Return the CVSROOT which provides the sources for a particular module. |
|
988 |
If no specific root was defined for that module, return the value of |
|
989 |
the global (fallBack) CVSRoot. |
|
990 |
Nil is returned if no repository is available." |
|
991 |
||
992 |
|root| |
|
993 |
||
994 |
CVSModuleRoots isNil ifTrue:[^ CVSRoot]. |
|
995 |
aModuleName isNil ifTrue:[^ CVSRoot]. |
|
996 |
root := CVSModuleRoots at:aModuleName ifAbsent:nil. |
|
997 |
^ root ? CVSRoot |
|
998 |
||
999 |
"Created: / 19.9.1997 / 06:18:07 / cg" |
|
1000 |
"Modified: / 20.5.1998 / 16:30:12 / cg" |
|
1001 |
! |
|
1002 |
||
1003 |
getCVSROOTsPerModule |
|
1004 |
"return a dictionary, which associates CVSRoots to modules" |
|
1005 |
||
1006 |
^ CVSModuleRoots ? #() |
|
1007 |
! |
|
1008 |
||
1009 |
import:moduleDir in:tempdir |
|
1010 |
"import the existing tree in tempdir as repository" |
|
1011 |
||
1012 |
|cmd| |
|
1013 |
||
1014 |
cmd := 'import -m "checkin from stx browser" . initialV initialR'. |
|
1015 |
^ self |
|
1016 |
executeCVSCommand:cmd |
|
1017 |
module:moduleDir |
|
1018 |
inDirectory:tempdir name |
|
1019 |
log:false |
|
1020 |
||
1021 |
||
1022 |
" |
|
1023 |
|f d| |
|
1024 |
f := 'stefan/dummy/fasel'. |
|
1025 |
d := '/tmp/tt' asFilename construct:f. |
|
1026 |
d directory recursiveMakeDirectory. |
|
1027 |
d writeStream close. |
|
1028 |
self import:'stefan' in:'/tmp/tt/stefan' asFilename |
|
1029 |
" |
|
1030 |
||
1031 |
"Created: / 23.7.1999 / 19:19:34 / stefan" |
|
1032 |
"Modified: / 26.7.1999 / 17:46:29 / stefan" |
|
1033 |
"Modified: / 18.1.2000 / 20:21:32 / cg" |
|
1034 |
! |
|
1035 |
||
1036 |
releaseAndRemove:tempdir module:moduleDir outputTo:outputFilename |
|
1037 |
"cleanup; release tree towards cvs and remove the temporary tree" |
|
1038 |
||
1039 |
|cmd redirect| |
|
1040 |
||
1041 |
outputFilename isNil ifTrue:[ |
|
1042 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
1043 |
redirect := 'NUL' |
|
1044 |
] ifFalse:[ |
|
1045 |
redirect := '/dev/null' |
|
1046 |
] |
|
1047 |
] ifFalse:[ |
|
1048 |
redirect := outputFilename name |
|
1049 |
]. |
|
1050 |
||
1051 |
"/ |
|
1052 |
"/ release it towards cvs |
|
1053 |
"/ |
|
1393
28d04a5111c6
cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents:
1390
diff
changeset
|
1054 |
cmd := 'release > ' , redirect. |
1362 | 1055 |
(self |
1056 |
executeCVSCommand:cmd |
|
1057 |
module:moduleDir |
|
1058 |
inDirectory:tempdir name |
|
1059 |
log:false |
|
1060 |
) ifFalse:[ |
|
1061 |
"/ 'CVSMGR: failed to release: ' errorPrint. cmd errorPrintNL. |
|
1062 |
]. |
|
1063 |
||
1064 |
tempdir recursiveRemove. |
|
1065 |
||
1066 |
"Modified: / 23.4.1996 / 14:29:49 / stefan" |
|
1067 |
"Created: / 19.9.1997 / 06:28:02 / cg" |
|
1068 |
"Modified: / 20.5.1998 / 16:44:07 / cg" |
|
1069 |
"Modified: / 3.9.1999 / 14:51:29 / ps" |
|
1070 |
! |
|
1071 |
||
1072 |
repositoryTopDirectory |
|
1073 |
"return the top of the repository. This handles remote CVS connections |
|
1074 |
as well" |
|
1075 |
||
1076 |
CVSRoot isNil ifTrue:[^ nil]. |
|
1077 |
^ self repositoryTopDirectory:CVSRoot. |
|
1078 |
||
1079 |
" |
|
1080 |
CVSSourceCodeManager repositoryTopDirectory |
|
1081 |
" |
|
1082 |
||
1083 |
"Created: / 25.11.1995 / 18:39:19 / cg" |
|
1084 |
"Modified: / 16.1.1998 / 17:33:31 / stefan" |
|
1085 |
! |
|
1086 |
||
1087 |
repositoryTopDirectory:aString |
|
1088 |
"return the top of the repository (without remote prefix)" |
|
1089 |
||
1090 |
|idx| |
|
1091 |
||
1092 |
idx := aString indexOf:$/. |
|
1093 |
idx <= 1 ifTrue:[ |
|
1094 |
^ aString. |
|
1095 |
]. |
|
1096 |
^ aString copyFrom:idx. |
|
1097 |
||
1098 |
" |
|
1099 |
CVSSourceCodeManager repositoryTopDirectory:':pserver:stefan@ibm.exept.de:/archiv/cvs' |
|
1100 |
CVSSourceCodeManager repositoryTopDirectory:'exept:/files/CVS' |
|
1101 |
CVSSourceCodeManager repositoryTopDirectory:'/archiv/cvs' |
|
1102 |
" |
|
1103 |
||
1104 |
"Modified: / 16.1.1998 / 17:32:03 / stefan" |
|
1105 |
! |
|
1106 |
||
1107 |
revisionStringFromLog:log entry:entry forClass:aClass |
|
1108 |
"given a log entry, extract a revision string" |
|
1109 |
||
1110 |
|oldRev idx special| |
|
1111 |
||
1112 |
oldRev := aClass revisionString. |
|
1113 |
special := ''. |
|
1114 |
||
1115 |
oldRev notNil ifTrue:[ |
|
1116 |
idx := oldRev lastIndexOf:$[. |
|
1117 |
idx ~~ 0 ifTrue:[ |
|
1118 |
idx := oldRev indexOf:$[ startingAt:idx+1. |
|
1119 |
idx ~~ 0 ifTrue:[ |
|
1120 |
special := ' ' , (oldRev copyFrom:idx). |
|
1121 |
] |
|
1122 |
]. |
|
1123 |
]. |
|
1124 |
||
1125 |
^ '$Header: ' , (log at:#container) , |
|
1126 |
' ' , (entry at:#revision) , |
|
1127 |
' ' , (entry at:#date) , |
|
1128 |
' ' , (entry at:#author) , |
|
1129 |
' ' , (entry at:#state) , |
|
1130 |
' $' , |
|
1131 |
special |
|
1132 |
||
1133 |
"Created: 16.9.1996 / 20:24:14 / cg" |
|
1134 |
"Modified: 3.3.1997 / 22:31:51 / cg" |
|
1135 |
! |
|
1136 |
||
1137 |
updatedRevisionStringOf:aClass forRevision:newRevision with:originalVersionString |
|
1138 |
"update a revision string" |
|
1139 |
||
1140 |
|idx leftPart rightPart vsnString newVsn| |
|
1141 |
||
1142 |
"/ search for ,v |
|
1143 |
idx := originalVersionString indexOfSubCollection:'.st,v'. |
|
1144 |
idx == 0 ifTrue:[^ nil]. |
|
1145 |
||
1146 |
leftPart := originalVersionString copyTo:(idx - 1 + 5). |
|
1147 |
rightPart := (originalVersionString copyFrom:(idx + 5)) withoutSpaces. |
|
1148 |
idx := rightPart indexOfSeparator. |
|
1149 |
idx == 0 ifTrue:[^ nil]. |
|
1150 |
||
1151 |
vsnString := rightPart copyTo:idx - 1. |
|
1152 |
rightPart := rightPart copyFrom:idx + 1. |
|
1153 |
||
1154 |
newRevision isNil ifTrue:[ |
|
1155 |
(vsnString endsWith:'m') ifTrue:[ |
|
1156 |
"/ alread a modified class |
|
1157 |
"/ ('already modified: ' , vsnString) printNL. |
|
1158 |
^ nil |
|
1159 |
]. |
|
1160 |
newVsn := vsnString , 'm' |
|
1161 |
] ifFalse:[ |
|
1162 |
newVsn := newRevision |
|
1163 |
]. |
|
1164 |
||
1165 |
^ leftPart , ' ' , newVsn , ' ' , rightPart |
|
1166 |
||
1167 |
"Created: 7.12.1995 / 20:23:38 / cg" |
|
1168 |
"Modified: 16.9.1996 / 20:24:28 / cg" |
|
1169 |
! ! |
|
1170 |
||
1171 |
!CVSSourceCodeManager class methodsFor:'source code access'! |
|
1172 |
||
1173 |
checkin:containerFilename text:someText directory:packageDir module:moduleDir logMessage:logMessage force:force |
|
1174 |
"enter some (source) code (which is someText) |
|
1175 |
into the source repository. If the force argument is true, no merge is done; |
|
1176 |
instead, the code is checked in as given (Dangerous). |
|
1177 |
Return true if ok, false if not." |
|
1178 |
||
1179 |
|tempdir cmd checkoutName logMsg revision logTmp |
|
1180 |
cmdOut whatHappened s idx changeLog changesAsLogged l |
|
1181 |
newRevision msg answer didMerge |
|
1182 |
mySource mergedSource modulePath time |
|
1183 |
editor checkInRepaired didAccept emphasizedText repairedText out |
|
1184 |
emSep comment| |
|
1185 |
||
1186 |
revision := self newestRevisionInFile:containerFilename directory:packageDir module:moduleDir. |
|
1187 |
||
1188 |
logMsg := logMessage. |
|
1189 |
(logMsg isNil or:[logMsg isEmpty]) ifTrue:[ |
|
1190 |
logMsg := 'checkin from browser'. |
|
1191 |
]. |
|
1192 |
||
1193 |
cmdOut := Filename newTemporary. |
|
1194 |
cmdOut exists ifTrue:[ |
|
1195 |
cmdOut remove. |
|
1196 |
]. |
|
1197 |
||
1198 |
"/ |
|
1199 |
"/ in CVS, we have to checkout the file first, in order |
|
1200 |
"/ to get up-to-date CVS entries, and also to be able to merge in |
|
1201 |
"/ other users changes. |
|
1202 |
"/ |
|
1203 |
||
1204 |
"/ |
|
1205 |
"/ first, create a temporary work tree |
|
1206 |
"/ |
|
1207 |
tempdir := self createTempDirectory:nil forModule:nil. |
|
1208 |
tempdir isNil ifTrue:[ |
|
1209 |
('CVSSourceCodeManager [error]: no tempDir - cannot checkin ' , containerFilename) errorPrintCR. |
|
1210 |
^ false |
|
1211 |
]. |
|
1212 |
||
1213 |
"/ |
|
1214 |
"/ next, create CVS/Entries and CVS/Repository with version information of current version |
|
1215 |
"/ |
|
1216 |
modulePath := moduleDir , '/' , packageDir. |
|
1217 |
checkoutName := modulePath , '/' , containerFilename. |
|
1218 |
||
1219 |
revision isNil ifTrue:[ |
|
1220 |
"/ a new file ... |
|
1221 |
^ self |
|
1222 |
createContainerForText:someText inModule:moduleDir package:packageDir container:containerFilename |
|
1223 |
]. |
|
1224 |
||
1225 |
"/ |
|
1226 |
"/ correct our current time, so that converting it will give us UTC |
|
1227 |
"/ |
|
1388
6fae02877da5
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
1387
diff
changeset
|
1228 |
time := Timestamp now subtractSeconds:1. |
1362 | 1229 |
time := time addSeconds:(time utcOffset). |
1230 |
||
1231 |
self createEntryFor:checkoutName |
|
1232 |
module:moduleDir |
|
1233 |
in:(tempdir construct:modulePath) |
|
1234 |
revision:revision |
|
1235 |
date:(self cvsTimeString:time) |
|
1236 |
special:'' |
|
1237 |
overwrite:true. |
|
1238 |
||
1239 |
"/ |
|
1240 |
"/ copy-over our current version |
|
1241 |
"/ |
|
1242 |
Stream errorSignal handle:[:ex| |
|
1243 |
tempdir recursiveRemove. |
|
1244 |
'CVSSourceCodeManager [error]: cannot copy-over filedOut class source' errorPrintCR. |
|
1245 |
^ false. |
|
1246 |
] do:[ |
|
1247 |
s := (tempdir construct:checkoutName) writeStream. |
|
1248 |
s nextPutAll:someText. |
|
1249 |
s close. |
|
1250 |
]. |
|
1251 |
||
1252 |
"/ |
|
1253 |
"/ synchronize i.e. merge in any changes |
|
1254 |
"/ |
|
1255 |
self activityNotification:'merging ' , containerFilename , ' with repository version ...'. |
|
1256 |
||
1257 |
cmd := 'update ', containerFilename, ' >', '"' , cmdOut name , '"'. |
|
1258 |
(self |
|
1259 |
executeCVSCommand:cmd |
|
1260 |
module:moduleDir |
|
1261 |
inDirectory:((tempdir construct:moduleDir) constructString:packageDir) |
|
1262 |
) ifFalse:[ |
|
1263 |
force ifFalse:[ |
|
1264 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
1265 |
tempdir recursiveRemove. |
|
1266 |
cmdOut remove. |
|
1267 |
'CVSSourceCodeManager [error]: cannot merge current source with repository version' errorPrintCR. |
|
1268 |
^ false. |
|
1269 |
]. |
|
1270 |
] ifTrue:[ |
|
1271 |
"/ |
|
1272 |
"/ check what happened - the contents of the cmdOut file may be: |
|
1273 |
"/ empty -> nothing changed |
|
1274 |
"/ M xxx -> merged-in changes from other users |
|
1275 |
"/ C xxx -> a conflict occured and the differences have been merged into the source |
|
1276 |
"/ needs special action |
|
1277 |
"/ |
|
1278 |
(cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[ |
|
1279 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
1280 |
]. |
|
1281 |
]. |
|
1282 |
cmdOut remove. |
|
1283 |
||
1284 |
(whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[ |
|
1285 |
"/ |
|
1286 |
"/ no change |
|
1287 |
"/ |
|
1288 |
"/ Transcript showCR:'no change in ' , containerFilename , ' (repository unchanged)'. |
|
1289 |
force ifFalse:[ |
|
1290 |
self information:'nothing changed in ' , containerFilename , ' (repository unchanged)'. |
|
1291 |
]. |
|
1292 |
tempdir recursiveRemove. |
|
1293 |
^ true |
|
1294 |
]. |
|
1295 |
||
1296 |
Verbose == true ifTrue:[ |
|
1297 |
('CVSMGR: result is: ' , whatHappened) infoPrintCR. |
|
1298 |
]. |
|
1299 |
||
1300 |
force ifFalse:[ |
|
1301 |
revision isNil ifTrue:[ |
|
1302 |
changeLog := self revisionLogOfContainer:containerFilename directory:packageDir module:moduleDir. |
|
1303 |
] ifFalse:[ |
|
1304 |
changeLog := self revisionLogOfContainer:containerFilename module:moduleDir package:packageDir fromRevision:(self revisionAfter:revision) toRevision:nil. |
|
1305 |
]. |
|
1306 |
changeLog notNil ifTrue:[ |
|
1307 |
s := WriteStream on:String new. |
|
1308 |
self writeRevisionLogMessagesFrom:changeLog withHeader:false to:s. |
|
1309 |
changesAsLogged := s contents. |
|
1310 |
] ifFalse:[ |
|
1311 |
"/ mhmh - that should not happen |
|
1312 |
changesAsLogged := ''. |
|
1313 |
]. |
|
1314 |
]. |
|
1315 |
||
1316 |
didMerge := false. |
|
1317 |
||
1318 |
"/ |
|
1319 |
"/ cvs above rel10 returns a multiline info ... |
|
1320 |
"/ we have to extract the one line which states what happened. |
|
1321 |
"/ |
|
1322 |
whatHappened := whatHappened asCollectionOfLines asStringCollection. |
|
1323 |
whatHappened := whatHappened select:[:line | |
|
1324 |
(line startsWith:'RCS file') not |
|
1325 |
and:[(line startsWith:'retrieving') not |
|
1326 |
and:[(line startsWith:'Merging') not |
|
1327 |
and:[line size > 0]]] |
|
1328 |
]. |
|
1329 |
whatHappened := whatHappened asString. |
|
1330 |
||
1331 |
(force or:[whatHappened startsWith:'M ']) ifTrue:[ |
|
1332 |
"/ |
|
1333 |
"/ merged in changes |
|
1334 |
"/ |
|
1335 |
(force |
|
1336 |
or:[changeLog isNil |
|
1337 |
or:[(changeLog at:#revisions) isEmpty]]) ifTrue:[ |
|
1338 |
"/ |
|
1339 |
"/ pretty good - nothing has changed in the meanwhile |
|
1340 |
"/ |
|
1341 |
Transcript showCR:'checking in ' , containerFilename , ' ...' |
|
1342 |
] ifFalse:[ |
|
1343 |
"/ |
|
1344 |
"/ someone else has changed things in the meanwhile, but there is no conflict |
|
1345 |
"/ and version have been merged. |
|
1346 |
"/ |
|
1347 |
didMerge := true. |
|
1348 |
changesAsLogged := changesAsLogged asCollectionOfLines. |
|
1349 |
||
1350 |
s := WriteStream on:String new. |
|
1351 |
s nextPutAll:someText. |
|
1352 |
mySource := s contents asString. |
|
1353 |
mergedSource := (tempdir construct:checkoutName) readStream contents asString. |
|
1354 |
||
1355 |
mySource = mergedSource ifTrue:[ |
|
1356 |
msg := 'The source of ' , containerFilename , ' has been changed in the meanwhile as listed below. |
|
1357 |
||
1358 |
I have merged your version with the newest repository version, |
|
1359 |
and found no differences between the result and your current version |
|
1360 |
(i.e. your version seemed up-to-date).'. |
|
1361 |
||
1362 |
self checkinTroubleDialog:'Merging versions' |
|
1363 |
message:msg |
|
1364 |
log:changesAsLogged |
|
1365 |
abortable:false |
|
1366 |
option:nil. |
|
1367 |
didMerge := false. |
|
1368 |
] ifFalse:[ |
|
1369 |
msg := 'The source of ' , containerFilename , ' has been changed in the meanwhile as listed below. |
|
1370 |
||
1371 |
If you continue, your new changes (based upon rev. ' , revision printString , ') will be MERGED |
|
1372 |
into the newest revision. This will combine the other version with your changes |
|
1373 |
into a new common revision which may be different from both. |
|
1374 |
Although this is a nice feature, it may fail to create the expected result in certain situations. |
|
1375 |
||
1376 |
You should carefully check the result - by comparing the current version with the |
|
1377 |
most recent version in the repository. If that does not contain an acceptable version, |
|
1378 |
change methods as required and check in again. |
|
1379 |
Be aware, that after that, the actual repository version is different from your current classes, |
|
1380 |
and you should update your class from the repository. |
|
1381 |
||
1382 |
Continue ?'. |
|
1383 |
||
1384 |
answer := self checkinTroubleDialog:'Merging versions' |
|
1385 |
message:msg |
|
1386 |
log:changesAsLogged |
|
1387 |
abortable:true |
|
1388 |
option:'Stop - see first'. |
|
1389 |
answer ~~ true ifTrue:[ |
|
1390 |
answer == #option ifTrue:[ |
|
1391 |
DiffTextView |
|
1392 |
openOn:mySource |
|
1393 |
label:'current version' |
|
1394 |
and:mergedSource |
|
1395 |
label:'merged version'. |
|
1396 |
||
1397 |
]. |
|
1398 |
Transcript showCR:'checkin aborted - (no merge; repository unchanged)'. |
|
1399 |
tempdir recursiveRemove. |
|
1400 |
^ false. |
|
1401 |
]. |
|
1402 |
]. |
|
1403 |
||
1404 |
"/ changesAsLogged := (changesAsLogged asStringCollection collect:[:line | line withTabsExpanded]) asString. |
|
1405 |
"/ msg := 'The source of ' , containerFilename , ' has been changed in the meanwhile as follows: |
|
1406 |
"/' , changesAsLogged , ' |
|
1407 |
"/ |
|
1408 |
"/If you continue, your new changes (based upon rev. ' , revision , ') will be MERGED |
|
1409 |
"/into the newest revision. This will combine the other version with your changes |
|
1410 |
"/into a new common revision which is different from both. |
|
1411 |
"/Although convenient, it may fail to create the expected result in certain situations. |
|
1412 |
"/ |
|
1413 |
"/You should carefully check the result - by comparing the current version with the |
|
1414 |
"/most recent version in the repository. If that does not contain an acceptable version, |
|
1415 |
"/change methods as required and check in again. Be aware, that the actual repository version |
|
1416 |
"/is different from your current classes. |
|
1417 |
"/ |
|
1418 |
"/Continue ?'. |
|
1419 |
"/ (self confirm:msg) ifFalse:[ |
|
1420 |
"/ Transcript showCR:'checkin aborted - (no merge; repository unchanged)'. |
|
1421 |
"/ tempdir recursiveRemove. |
|
1422 |
"/ ^ false. |
|
1423 |
"/ ]. |
|
1424 |
Transcript showCR:'checking in ' , containerFilename , ' (merged other changes) ...' |
|
1425 |
] |
|
1426 |
] ifFalse:[ |
|
1427 |
(whatHappened startsWith:'C ') ifTrue:[ |
|
1428 |
"/ |
|
1429 |
"/ conflict; someone else checked in something in the meanwhile, |
|
1430 |
"/ and there is a conflict between this version and the checked in version. |
|
1431 |
"/ |
|
1432 |
||
1433 |
changesAsLogged := changesAsLogged asCollectionOfLines. |
|
1434 |
||
1435 |
msg := 'The source of ' , containerFilename , ' has been changed in the meanwhile as listed below. |
|
1436 |
||
1437 |
Your new changes (based upon rev. ' , revision printString , ') CONFLICT with those changes. |
|
1438 |
||
1439 |
You should fix things by comparing your class with the most recent repository version |
|
1440 |
and change your methods avoiding conflicts. The checkin again. |
|
1441 |
'. |
|
1442 |
||
1443 |
answer := self checkinTroubleDialog:'Version conflict' |
|
1444 |
message:msg |
|
1445 |
log:changesAsLogged |
|
1446 |
abortable:false |
|
1447 |
option:'show conflicts' |
|
1448 |
option2:'resolve conflicts'. |
|
1449 |
||
1450 |
answer == #option ifTrue:[ |
|
1451 |
"/ |
|
1452 |
"/ show conflicts in a 3-way DiffTextView ... |
|
1453 |
"/ |
|
1454 |
Diff3TextView |
|
1455 |
openOnMergedText:(tempdir construct:checkoutName) readStream contents |
|
1456 |
label:'your version (checkin attempt)' |
|
1457 |
label:'original (base version)' |
|
1458 |
label:'newest repository version'. |
|
1459 |
]. |
|
1460 |
||
1461 |
checkInRepaired := false. |
|
1462 |
answer == #option2 ifTrue:[ |
|
1463 |
"/ |
|
1464 |
"/ allow checkin of repair version |
|
1465 |
"/ this is error prone ... |
|
1466 |
"/ |
|
1467 |
"/ |
|
1468 |
"/ show merged version in an editor ... |
|
1469 |
"/ ... accept will check it in. |
|
1470 |
"/ |
|
1471 |
emphasizedText := (tempdir construct:checkoutName) readStream contents. |
|
1472 |
emSep := (Array with:(#color->Color black) |
|
1473 |
with:(#backgroundColor->Color green)). |
|
1474 |
emphasizedText := Diff3TextView |
|
1475 |
emphasizeMergedDiff3Text:emphasizedText |
|
1476 |
emphasize1:(Array with:(#color->Color white) |
|
1477 |
with:(#backgroundColor->Color blue)) |
|
1478 |
emphasize2:(Array with:(#color->Color white) |
|
1479 |
with:(#backgroundColor->Color red)) |
|
1480 |
emphasizeSep:emSep. |
|
1481 |
||
1482 |
comment := |
|
1483 |
'"/ *************************************************************** |
|
1484 |
"/ This text contains your current versions code (blue) |
|
1485 |
"/ merged with the conflicting code as found in the repository (red) which resulted |
|
1486 |
"/ from some other checkin. |
|
1487 |
"/ Each such conflict is surrounded by green text (like this paragraph). |
|
1488 |
"/ |
|
1489 |
"/ Please have a look at ALL the conflicts and fix things as appropriate. |
|
1490 |
"/ Delete the green lines as a confirmation - I will not checkin the changed text, |
|
1491 |
"/ unless no more green parts are present. This includes this comment at the top. |
|
1492 |
"/ *************************************************************** |
|
1493 |
'. |
|
1494 |
comment := (Text string:comment emphasis:emSep) asStringCollection. |
|
1495 |
emphasizedText := comment , emphasizedText. |
|
1496 |
||
1497 |
didAccept := false. checkInRepaired := true. |
|
1498 |
[didAccept not and:[checkInRepaired]] whileTrue:[ |
|
1499 |
editor := RCSConflictEditTextView |
|
1500 |
setupWith:emphasizedText |
|
1501 |
title:'Resolve conflicts in ' , containerFilename , ', then accept & close to checkin'. |
|
1502 |
||
1503 |
editor acceptAction:[:dummy | |
|
1504 |
repairedText := editor list. |
|
1505 |
didAccept := true. |
|
1506 |
]. |
|
1507 |
didAccept := false. |
|
1508 |
editor topView openModal. |
|
1509 |
||
1510 |
didAccept ifFalse:[ |
|
1511 |
(Dialog confirm:'You did not accept the new text. Edit again ?') |
|
1512 |
ifFalse:[ |
|
1513 |
checkInRepaired := false. |
|
1514 |
] |
|
1515 |
] ifTrue:[ |
|
1516 |
"/ check if all green-stuff (separators) have been removed |
|
1517 |
(repairedText findFirst:[:line | line notNil and:[line notEmpty and:[(line emphasisAt:1) = emSep]]]) ~~ 0 ifTrue:[ |
|
1518 |
self warn:'You have to look at ALL conflicts, and remove ALL green lines as a confirmation !!'. |
|
1519 |
didAccept := false. |
|
1520 |
] |
|
1521 |
]. |
|
1522 |
||
1523 |
]. |
|
1524 |
||
1525 |
checkInRepaired ifTrue:[ |
|
1526 |
[ |
|
1527 |
out := (tempdir construct:checkoutName) writeStream. |
|
1528 |
out nextPutAll:(repairedText asString string). |
|
1529 |
didAccept := true. |
|
1530 |
out close. |
|
1531 |
] on:FileStream openErrorSignal do:[:ex| |
|
1532 |
self warn:'could not write file ' , (tempdir constructString:checkoutName). |
|
1533 |
checkInRepaired := false. |
|
1534 |
]. |
|
1535 |
] |
|
1536 |
]. |
|
1537 |
||
1538 |
checkInRepaired ifTrue:[ |
|
1539 |
Transcript showCR:'checking in ' , containerFilename , ' (manually repaired version) ...' |
|
1540 |
] ifFalse:[ |
|
1541 |
'CVSSourceCodeManager [warning]: cannot (for now) checkin; conflicts found' infoPrintCR. |
|
1542 |
Transcript showCR:'checkin of ' , containerFilename , ' aborted (conflicting changes; repository unchanged)'. |
|
1543 |
tempdir recursiveRemove. |
|
1544 |
^ false. |
|
1545 |
] |
|
1546 |
] ifFalse:[ |
|
1547 |
(whatHappened startsWith:'U ') ifTrue:[ |
|
1548 |
"/ |
|
1549 |
"/ nothing changed here, but the repository already contains |
|
1550 |
"/ a newer version. |
|
1551 |
"/ |
|
1552 |
tempdir recursiveRemove. |
|
1553 |
||
1554 |
self information:'nothing changed in your ''' , containerFilename , '''; |
|
1555 |
but repository already contains a newer version (repository unchanged).'. |
|
1556 |
^ true. |
|
1557 |
] ifFalse:[ |
|
1558 |
"/ |
|
1559 |
"/ unexpected |
|
1560 |
"/ |
|
1561 |
self warn:'unexpected message from CVS: |
|
1562 |
' , whatHappened , ' |
|
1563 |
||
1564 |
No checkin performed.'. |
|
1565 |
Transcript showCR:'*** cannot checkin ' , containerFilename , ' (unexpected CVS response; repository unchanged)'. |
|
1566 |
tempdir recursiveRemove. |
|
1567 |
^ false. |
|
1568 |
] |
|
1569 |
] |
|
1570 |
]. |
|
1571 |
||
1572 |
||
1573 |
"/ |
|
1574 |
"/ now check it in again |
|
1575 |
"/ |
|
1576 |
self activityNotification:'saving ' , containerFilename , ' in repository ...'. |
|
1577 |
||
1578 |
logMsg := logMsg replChar:$" withString:'\"'. |
|
1579 |
||
1580 |
OperatingSystem isUNIXlike ifFalse:[ |
|
1581 |
"/ save the log message into another tempFile ... |
|
1582 |
logTmp := Filename newTemporaryIn:tempdir. |
|
1583 |
s := logTmp writeStream. |
|
1584 |
s nextPutAll:logMsg. |
|
1585 |
s close. |
|
1586 |
||
1587 |
cmd := 'commit -F "', logTmp baseName, '" ', checkoutName, ' >', '"' , cmdOut name , '"'. |
|
1588 |
] ifTrue:[ |
|
1589 |
"/ |
|
1590 |
"/ CVS up to V1.9.14 prints the 'new revision' to stderr, |
|
1591 |
"/ CVS V1.9.16 to stdout. |
|
1592 |
"/ |
|
1593 |
cmd := 'commit -m "', logMsg, '" ', checkoutName, ' >', '"' , cmdOut name , '"' , ' 2>&1'. |
|
1594 |
]. |
|
1595 |
||
1596 |
(self |
|
1597 |
executeCVSCommand:cmd |
|
1598 |
module:moduleDir |
|
1599 |
inDirectory:tempdir name |
|
1600 |
) ifFalse:[ |
|
1601 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
1602 |
||
1603 |
(cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[ |
|
1604 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
1605 |
] ifFalse:[ |
|
1606 |
whatHappened := '<< no message >>' |
|
1607 |
]. |
|
1608 |
self warn:'The following problem was reported by cvs: |
|
1609 |
||
1610 |
' , whatHappened , ' |
|
1611 |
||
1612 |
The class has NOT been checked into the repository.'. |
|
1613 |
||
1614 |
('CVSSourceCodeManager [error]: cvs: ' , whatHappened) errorPrintCR. |
|
1615 |
'CVSSourceCodeManager [error]: cannot checkin modified class source' errorPrintCR. |
|
1616 |
logTmp notNil ifTrue:[logTmp remove]. |
|
1617 |
cmdOut remove. |
|
1618 |
tempdir recursiveRemove. |
|
1619 |
^ false. |
|
1620 |
]. |
|
1621 |
logTmp notNil ifTrue:[logTmp remove]. |
|
1622 |
(cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[ |
|
1623 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
1624 |
] ifFalse:[ |
|
1625 |
whatHappened := nil |
|
1626 |
]. |
|
1627 |
||
1628 |
tempdir recursiveRemove. |
|
1629 |
cmdOut remove. |
|
1630 |
||
1631 |
"/ |
|
1632 |
"/ fetch the new revision nr as found in the commit commands output |
|
1633 |
"/ |
|
1634 |
||
1635 |
(whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[ |
|
1636 |
'CVSSourceCodeManager [error]: unexpected empty checkin command output' errorPrintCR. |
|
1637 |
] ifFalse:[ |
|
1638 |
whatHappened := whatHappened asCollectionOfLines asStringCollection. |
|
1639 |
idx := whatHappened indexOfLineStartingWith:'new revision:'. |
|
1640 |
idx == 0 ifTrue:[ |
|
1641 |
'CVSSourceCodeManager [error]: unexpected checkin command output (no new-revision info)' errorPrintCR. |
|
1642 |
] ifFalse:[ |
|
1643 |
l := whatHappened at:idx. |
|
1644 |
newRevision := (l copyFrom:14 to:(l indexOf:$; startingAt:14)-1) withoutSpaces. |
|
1645 |
] |
|
1646 |
]. |
|
1647 |
^ true |
|
1648 |
! |
|
1649 |
||
1650 |
checkinClass:cls fileName:classFileName directory:packageDir module:moduleDir source:sourceFileName logMessage:logMessage force:forceArg |
|
1651 |
"enter a classes source code (which has been already filed out into sourceFileName) |
|
1652 |
into the source repository. If the force argument is true, no merge is done; |
|
1653 |
instead, the code is checked in as given (Dangerous). |
|
1654 |
Return true if ok, false if not." |
|
1655 |
||
1656 |
|tempdir cmd checkoutName logMsg revision logTmp |
|
1657 |
cmdOut whatHappened s entry idx changeLog changesAsLogged l |
|
1658 |
newRevision newString binRevision className msg answer didMerge |
|
1659 |
mySource mergedSource modulePath time |
|
1660 |
editor checkInRepaired checkInNew didAccept emphasizedText repairedText out |
|
1661 |
emSep comment force| |
|
1662 |
||
1663 |
force := forceArg. |
|
1664 |
||
1665 |
className := cls name. |
|
1666 |
cls isPrivate ifTrue:[ |
|
1667 |
self error:'refuse to check in private classes.'. |
|
1668 |
]. |
|
1669 |
revision := cls revision. |
|
1670 |
(revision notNil |
|
1671 |
and:[revision endsWith:$m]) |
|
1672 |
ifTrue:[ |
|
1673 |
"/ this class has already been checked in with a merge, |
|
1674 |
"/ but not reloaded from the repository. |
|
1675 |
"/ must use the original revision string. |
|
1676 |
revision := revision copyWithoutLast:1. |
|
1677 |
]. |
|
1678 |
(binRevision := cls binaryRevision) notNil ifTrue:[ |
|
1679 |
revision ~= binRevision ifTrue:[ |
|
1680 |
('CVSSourceCodeManager [info]: class ' , className , ' is based upon ' , binRevision , ' but has revision ' , (revision ? '?')) infoPrintCR |
|
1681 |
] |
|
1682 |
]. |
|
1683 |
||
1684 |
revision isNil ifTrue:[ |
|
1685 |
revision := self newestRevisionOf:cls. |
|
1686 |
revision isNil ifTrue:[ |
|
1687 |
force ifTrue:[ |
|
1688 |
revision := self newestRevisionInFile:classFileName directory:packageDir module:moduleDir. |
|
1689 |
] ifFalse:[ |
|
1690 |
revision := '1.0' |
|
1691 |
] |
|
1692 |
] |
|
1693 |
]. |
|
1694 |
||
1373
65473183582d
Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents:
1365
diff
changeset
|
1695 |
logMessage isNil ifTrue:[ |
65473183582d
Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents:
1365
diff
changeset
|
1696 |
logMsg := ''. |
65473183582d
Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents:
1365
diff
changeset
|
1697 |
] ifFalse:[ |
65473183582d
Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents:
1365
diff
changeset
|
1698 |
logMsg := logMessage asSingleByteStringIfPossible. |
65473183582d
Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents:
1365
diff
changeset
|
1699 |
logMsg bitsPerCharacter ~~ 8 ifTrue:[ |
65473183582d
Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents:
1365
diff
changeset
|
1700 |
'CVSSourceCodeManager [error]: cvs cannot handle unicode in logMessage' errorPrintCR. |
65473183582d
Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents:
1365
diff
changeset
|
1701 |
^ false. |
65473183582d
Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents:
1365
diff
changeset
|
1702 |
]. |
1362 | 1703 |
]. |
1704 |
||
1705 |
cmdOut := Filename newTemporary. |
|
1706 |
cmdOut exists ifTrue:[ |
|
1707 |
cmdOut remove. |
|
1708 |
]. |
|
1709 |
||
1710 |
"/ |
|
1711 |
"/ in CVS, we have to checkout the file first, in order |
|
1712 |
"/ to get up-to-date CVS entries, and also to be able to merge in |
|
1713 |
"/ other users changes. |
|
1714 |
"/ |
|
1715 |
||
1716 |
"/ |
|
1717 |
"/ first, create a temporary work tree |
|
1718 |
"/ |
|
1719 |
tempdir := self createTempDirectory:nil forModule:nil. |
|
1720 |
tempdir isNil ifTrue:[ |
|
1721 |
('CVSSourceCodeManager [error]: no tempDir - cannot checkin ' , className) errorPrintCR. |
|
1722 |
^ false |
|
1723 |
]. |
|
1724 |
||
1725 |
"/ |
|
1726 |
"/ next, create CVS/Entries and CVS/Repository with version information of current version |
|
1727 |
"/ |
|
1728 |
modulePath := moduleDir , '/' , packageDir. |
|
1729 |
checkoutName := modulePath , '/' , classFileName. |
|
1730 |
||
1731 |
"/ |
|
1732 |
"/ correct our current time, so that converting it will give us UTC |
|
1733 |
"/ |
|
1388
6fae02877da5
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
1387
diff
changeset
|
1734 |
time := Timestamp now subtractSeconds:1. |
1362 | 1735 |
time := time addSeconds:(time utcOffset). |
1736 |
||
1737 |
self createEntryFor:checkoutName |
|
1738 |
module:moduleDir |
|
1739 |
in:(tempdir construct:modulePath) |
|
1740 |
revision:revision |
|
1741 |
date:(self cvsTimeString:time) |
|
1742 |
special:'' |
|
1743 |
overwrite:true. |
|
1744 |
||
1745 |
"/ |
|
1746 |
"/ copy-over our current version |
|
1747 |
"/ |
|
1748 |
Error handle:[:ex| |
|
1749 |
tempdir recursiveRemove. |
|
1750 |
'CVSSourceCodeManager [error]: cannot copy-over filedOut class source' errorPrintCR. |
|
1751 |
^ false. |
|
1752 |
] do:[ |
|
1753 |
sourceFileName asFilename copyTo:(tempdir construct:checkoutName). |
|
1754 |
]. |
|
1755 |
||
1756 |
"/ |
|
1757 |
"/ synchronize i.e. merge in any changes |
|
1758 |
"/ |
|
1759 |
self activityNotification:'merging ' , cls name , ' with repository version ...'. |
|
1760 |
||
1761 |
cmd := 'update ', classFileName, ' >', '"' , cmdOut name , '"'. |
|
1762 |
(self |
|
1763 |
executeCVSCommand:cmd |
|
1764 |
module:moduleDir |
|
1765 |
inDirectory:((tempdir construct:moduleDir) constructString:packageDir) |
|
1766 |
) ifFalse:[ |
|
1767 |
force ifFalse:[ |
|
1768 |
"/ someone fiddled around with repository ? |
|
1769 |
(cls binaryRevision notNil |
|
1770 |
and:[(self checkForExistingContainerInModule:moduleDir package:packageDir container:classFileName) not ]) |
|
1771 |
ifTrue:[ |
|
1772 |
(Dialog confirm:('Someone seems to have removed the source container for ' , cls name , '\\Force new checkin ?') withCRs) |
|
1773 |
ifTrue:[ |
|
1774 |
cls setBinaryRevision:nil. |
|
1373
65473183582d
Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents:
1365
diff
changeset
|
1775 |
^ self checkinClass:cls fileName:classFileName directory:packageDir module:moduleDir source:sourceFileName logMessage:logMsg force:force. |
1362 | 1776 |
]. |
1777 |
]. |
|
1778 |
]. |
|
1779 |
force ifFalse:[ |
|
1780 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
1781 |
tempdir recursiveRemove. |
|
1782 |
cmdOut remove. |
|
1783 |
'CVSSourceCodeManager [error]: cannot merge current source with repository version' errorPrintCR. |
|
1784 |
^ false. |
|
1785 |
]. |
|
1786 |
] ifTrue:[ |
|
1787 |
"/ |
|
1788 |
"/ check what happened - the contents of the cmdOut file may be: |
|
1789 |
"/ empty -> nothing changed |
|
1790 |
"/ M xxx -> merged-in changes from other users |
|
1791 |
"/ C xxx -> a conflict occured and the differences have been merged into the source |
|
1792 |
"/ needs special action |
|
1793 |
"/ |
|
1794 |
(cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[ |
|
1795 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
1796 |
]. |
|
1797 |
]. |
|
1798 |
cmdOut remove. |
|
1799 |
||
1800 |
(whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[ |
|
1801 |
"/ |
|
1802 |
"/ no change |
|
1803 |
"/ |
|
1804 |
"/ Transcript showCR:'no change in ' , className , ' (repository unchanged)'. |
|
1805 |
tempdir recursiveRemove. |
|
1806 |
||
1807 |
force ifFalse:[ |
|
1808 |
"/ (ChangeSet current includesChangeForClass:cls) ifTrue:[ |
|
1809 |
"/ (self confirm:('Nothing changed in %1 (repository unchanged).\\Remove entries from changeSet ?' bindWith:className) withCRs) ifTrue:[ |
|
1810 |
"/ ChangeSet current condenseChangesForClass:cls. |
|
1811 |
"/ ]. |
|
1812 |
"/ ] ifFalse:[ |
|
1813 |
self information:('Nothing changed in %1 (repository unchanged)' bindWith:className). |
|
1814 |
"/ ]. |
|
1815 |
self postCheckInClass:cls. |
|
1816 |
] ifTrue:[ |
|
1817 |
changeLog := self revisionLogOfContainer:classFileName directory:packageDir module:moduleDir. |
|
1818 |
(changeLog isNil or:[(changeLog at:#revisions) size ~~ 1]) ifTrue:[ |
|
1819 |
'CVSSourceCodeManager [error]: failed to update revisionString (no log)' errorPrintCR. |
|
1820 |
cls updateVersionMethodFor:'$' , 'Header' , '$'. "/ concatenated to avoid RCS expansion |
|
1821 |
] ifFalse:[ |
|
1822 |
entry := (changeLog at:#revisions) first. |
|
1823 |
newString := self revisionStringFromLog:changeLog entry:entry forClass:cls. |
|
1824 |
cls updateVersionMethodFor:newString. |
|
1825 |
cls revision ~= newRevision ifTrue:[ |
|
1826 |
'CVSSourceCodeManager [error]: failed to update revisionString' errorPrintCR |
|
1827 |
] |
|
1828 |
] |
|
1829 |
]. |
|
1830 |
||
1831 |
^ true |
|
1832 |
]. |
|
1833 |
||
1834 |
Verbose == true ifTrue:[ |
|
1835 |
('CVSMGR: result is: ' , whatHappened) infoPrintCR. |
|
1836 |
]. |
|
1837 |
||
1838 |
force ifFalse:[ |
|
1839 |
revision isNil ifTrue:[ |
|
1840 |
changeLog := self revisionLogOf:cls. |
|
1841 |
] ifFalse:[ |
|
1842 |
changeLog := self revisionLogOf:cls fromRevision:(self revisionAfter:revision) toRevision:nil. |
|
1843 |
]. |
|
1844 |
changeLog notNil ifTrue:[ |
|
1845 |
s := WriteStream on:String new. |
|
1846 |
self writeRevisionLogMessagesFrom:changeLog withHeader:false to:s. |
|
1847 |
changesAsLogged := s contents. |
|
1848 |
] ifFalse:[ |
|
1849 |
"/ mhmh - that should not happen |
|
1850 |
changesAsLogged := ''. |
|
1851 |
]. |
|
1852 |
]. |
|
1853 |
||
1854 |
didMerge := false. |
|
1855 |
checkInRepaired := checkInNew := false. |
|
1856 |
||
1857 |
"/ |
|
1858 |
"/ cvs above rel10 returns a multiline info ... |
|
1859 |
"/ we have to extract the one line which states what happened. |
|
1860 |
"/ |
|
1861 |
whatHappened := whatHappened asCollectionOfLines asStringCollection. |
|
1862 |
whatHappened := whatHappened select:[:line | |
|
1863 |
(line startsWith:'RCS file') not |
|
1864 |
and:[(line startsWith:'retrieving') not |
|
1865 |
and:[(line startsWith:'Merging') not |
|
1866 |
and:[line size > 0]]] |
|
1867 |
]. |
|
1868 |
whatHappened := whatHappened asString. |
|
1869 |
||
1870 |
(force or:[whatHappened startsWith:'M ']) ifTrue:[ |
|
1871 |
"/ |
|
1872 |
"/ merged in changes |
|
1873 |
"/ |
|
1874 |
(force |
|
1875 |
or:[changeLog isNil |
|
1876 |
or:[(changeLog at:#revisions) isEmpty]]) ifTrue:[ |
|
1877 |
"/ |
|
1878 |
"/ pretty good - nothing has changed in the meanwhile |
|
1879 |
"/ |
|
1880 |
Transcript showCR:'checking in ' , className , ' ...' |
|
1881 |
] ifFalse:[ |
|
1882 |
"/ |
|
1883 |
"/ someone else has changed things in the meanwhile, but there is no conflict |
|
1884 |
"/ and version have been merged. |
|
1885 |
"/ |
|
1886 |
didMerge := true. |
|
1887 |
changesAsLogged := changesAsLogged asCollectionOfLines. |
|
1888 |
||
1889 |
s := WriteStream on:String new. |
|
1890 |
cls fileOutOn:s withTimeStamp:false. |
|
1891 |
mySource := s contents asString. |
|
1892 |
mergedSource := (tempdir construct:checkoutName) readStream contents asString. |
|
1893 |
||
1894 |
mySource = mergedSource ifTrue:[ |
|
1895 |
msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below. |
|
1896 |
||
1897 |
I have merged your version with the newest repository version, |
|
1898 |
and found no differences between the result and your current version |
|
1899 |
(i.e. your version seemed up-to-date).'. |
|
1900 |
||
1901 |
self checkinTroubleDialog:'Merging versions' |
|
1902 |
message:msg |
|
1903 |
log:changesAsLogged |
|
1904 |
abortable:false |
|
1905 |
option:nil. |
|
1906 |
didMerge := false. |
|
1907 |
] ifFalse:[ |
|
1908 |
msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below. |
|
1909 |
||
1910 |
If you continue, your new changes (based upon rev. ' , revision printString , ') will be MERGED |
|
1911 |
into the newest revision. This will combine the other version with your changes |
|
1912 |
into a new common revision which may be different from both. |
|
1913 |
Although this is a nice feature, it may fail to create the expected result in certain situations. |
|
1914 |
||
1915 |
You should carefully check the result - by comparing the current version with the |
|
1916 |
most recent version in the repository. If that does not contain an acceptable version, |
|
1917 |
change methods as required and check in again. |
|
1918 |
Be aware, that after that, the actual repository version is different from your current classes, |
|
1919 |
and you should update your class from the repository. |
|
1920 |
||
1921 |
Continue ?'. |
|
1922 |
||
1923 |
answer := self checkinTroubleDialog:'Merging versions' |
|
1924 |
message:msg |
|
1925 |
log:changesAsLogged |
|
1926 |
abortable:true |
|
1927 |
option:'Stop - see first' |
|
1928 |
option2:'Do NOT Merge - Force my Code'. |
|
1929 |
||
1930 |
answer == #option2 ifTrue:[ |
|
1931 |
(Dialog confirm:'Are you certain that you want to suppress a merge and force your code to be checked in ?') |
|
1932 |
ifTrue:[ |
|
1933 |
s := (tempdir construct:checkoutName) writeStream. |
|
1934 |
cls fileOutOn:s withTimeStamp:false. |
|
1935 |
s close. |
|
1936 |
answer := true. |
|
1937 |
] |
|
1938 |
]. |
|
1939 |
||
1940 |
answer ~~ true ifTrue:[ |
|
1941 |
answer == #option ifTrue:[ |
|
1942 |
DiffTextView |
|
1943 |
openOn:mySource |
|
1944 |
label:'current version' |
|
1945 |
and:mergedSource |
|
1946 |
label:'merged version'. |
|
1947 |
||
1948 |
]. |
|
1949 |
Transcript showCR:'checkin aborted - (no merge; repository unchanged)'. |
|
1950 |
tempdir recursiveRemove. |
|
1951 |
^ false. |
|
1952 |
]. |
|
1953 |
]. |
|
1954 |
||
1955 |
"/ changesAsLogged := (changesAsLogged asStringCollection collect:[:line | line withTabsExpanded]) asString. |
|
1956 |
"/ msg := 'The source of ' , className , ' has been changed in the meanwhile as follows: |
|
1957 |
"/' , changesAsLogged , ' |
|
1958 |
"/ |
|
1959 |
"/If you continue, your new changes (based upon rev. ' , revision , ') will be MERGED |
|
1960 |
"/into the newest revision. This will combine the other version with your changes |
|
1961 |
"/into a new common revision which is different from both. |
|
1962 |
"/Although convenient, it may fail to create the expected result in certain situations. |
|
1963 |
"/ |
|
1964 |
"/You should carefully check the result - by comparing the current version with the |
|
1965 |
"/most recent version in the repository. If that does not contain an acceptable version, |
|
1966 |
"/change methods as required and check in again. Be aware, that the actual repository version |
|
1967 |
"/is different from your current classes. |
|
1968 |
"/ |
|
1969 |
"/Continue ?'. |
|
1970 |
"/ (self confirm:msg) ifFalse:[ |
|
1971 |
"/ Transcript showCR:'checkin aborted - (no merge; repository unchanged)'. |
|
1972 |
"/ tempdir recursiveRemove. |
|
1973 |
"/ ^ false. |
|
1974 |
"/ ]. |
|
1975 |
Transcript showCR:'checking in ' , className , ' (merged other changes) ...' |
|
1976 |
] |
|
1977 |
] ifFalse:[ |
|
1978 |
(whatHappened startsWith:'C ') ifTrue:[ |
|
1979 |
"/ |
|
1980 |
"/ conflict; someone else checked in something in the meanwhile, |
|
1981 |
"/ and there is a conflict between this version and the checked in version. |
|
1982 |
"/ |
|
1983 |
||
1984 |
changesAsLogged := changesAsLogged asCollectionOfLines. |
|
1985 |
||
1986 |
msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below. |
|
1987 |
||
1988 |
Your new changes (based upon rev. ' , revision printString , ') CONFLICT with those changes. |
|
1989 |
||
1990 |
You should fix things by comparing your class with the most recent repository version |
|
1991 |
and change your methods avoiding conflicts. The checkin again. |
|
1992 |
'. |
|
1993 |
||
1994 |
answer := self checkinTroubleDialog:'Version conflict' |
|
1995 |
message:msg |
|
1996 |
log:changesAsLogged |
|
1997 |
abortable:false |
|
1998 |
option:'Show conflicts' |
|
1999 |
option2:'Resolve conflicts' |
|
2000 |
option3:'Do NOT Merge - Force my Code'. |
|
2001 |
||
2002 |
answer == #option ifTrue:[ |
|
2003 |
"/ |
|
2004 |
"/ show conflicts in a 3-way DiffTextView ... |
|
2005 |
"/ |
|
2006 |
Diff3TextView |
|
2007 |
openOnMergedText:(tempdir construct:checkoutName) readStream contents |
|
2008 |
label:'your version (checkin attempt)' |
|
2009 |
label:'original (base version)' |
|
2010 |
label:'newest repository version'. |
|
2011 |
]. |
|
2012 |
||
2013 |
answer == #option2 ifTrue:[ |
|
2014 |
"/ |
|
2015 |
"/ allow checkin of repair version |
|
2016 |
"/ this is error prone ... |
|
2017 |
"/ |
|
2018 |
"/ |
|
2019 |
"/ show merged version in an editor ... |
|
2020 |
"/ ... accept will check it in. |
|
2021 |
"/ |
|
2022 |
emphasizedText := (tempdir construct:checkoutName) readStream contents. |
|
2023 |
emSep := (Array with:(#color->Color black) |
|
2024 |
with:(#backgroundColor->Color green)). |
|
2025 |
emphasizedText := Diff3TextView |
|
2026 |
emphasizeMergedDiff3Text:emphasizedText |
|
2027 |
emphasize1:(Array with:(#color->Color white) |
|
2028 |
with:(#backgroundColor->Color blue)) |
|
2029 |
emphasize2:(Array with:(#color->Color white) |
|
2030 |
with:(#backgroundColor->Color red)) |
|
2031 |
emphasizeSep:emSep. |
|
2032 |
||
2033 |
comment := |
|
2034 |
'"/ *************************************************************** |
|
2035 |
"/ This text contains your current versions code (blue) |
|
2036 |
"/ merged with the conflicting code as found in the repository (red) which resulted |
|
2037 |
"/ from some other checkin. |
|
2038 |
"/ Each such conflict is surrounded by green text (like this paragraph). |
|
2039 |
"/ |
|
2040 |
"/ Please have a look at ALL the conflicts and fix things as appropriate. |
|
2041 |
"/ Delete the green lines as a confirmation - I will not checkin the changed text, |
|
2042 |
"/ unless no more green parts are present. This includes this comment at the top. |
|
2043 |
"/ *************************************************************** |
|
2044 |
'. |
|
2045 |
comment := (Text string:comment emphasis:emSep) asStringCollection. |
|
2046 |
emphasizedText := comment , emphasizedText. |
|
2047 |
||
2048 |
didAccept := false. checkInRepaired := true. |
|
2049 |
[didAccept not and:[checkInRepaired]] whileTrue:[ |
|
2050 |
editor := RCSConflictEditTextView |
|
2051 |
setupWith:emphasizedText |
|
2052 |
title:'Resolve conflicts in ' , className , ', then accept & close to checkin'. |
|
2053 |
||
2054 |
editor acceptAction:[:dummy | |
|
2055 |
repairedText := editor list. |
|
2056 |
didAccept := true. |
|
2057 |
]. |
|
2058 |
didAccept := false. |
|
2059 |
editor topView openModal. |
|
2060 |
||
2061 |
didAccept ifFalse:[ |
|
2062 |
(Dialog confirm:'You did not accept the new text. Edit again ?') |
|
2063 |
ifFalse:[ |
|
2064 |
checkInRepaired := false. |
|
2065 |
] |
|
2066 |
] ifTrue:[ |
|
2067 |
"/ check if all green-stuff (separators) have been removed |
|
2068 |
(repairedText findFirst:[:line | line notNil and:[line notEmpty and:[(line emphasisAt:1) = emSep]]]) ~~ 0 ifTrue:[ |
|
2069 |
self warn:'You have to look at ALL conflicts, and remove ALL green lines as a confirmation !!'. |
|
2070 |
didAccept := false. |
|
2071 |
] |
|
2072 |
]. |
|
2073 |
||
2074 |
]. |
|
2075 |
||
2076 |
checkInRepaired ifTrue:[ |
|
2077 |
[ |
|
2078 |
out := (tempdir construct:checkoutName) writeStream. |
|
2079 |
out nextPutAll:(repairedText asString string). |
|
2080 |
didAccept := true. |
|
2081 |
out close. |
|
2082 |
] on:FileStream openErrorSignal do:[:ex| |
|
2083 |
self warn:'could not write file ' , (tempdir constructString:checkoutName). |
|
2084 |
checkInRepaired := false. |
|
2085 |
]. |
|
2086 |
] |
|
2087 |
]. |
|
2088 |
||
2089 |
answer == #option3 ifTrue:[ |
|
2090 |
"/ |
|
2091 |
"/ force checkin of new version |
|
2092 |
"/ |
|
2093 |
"/ |
|
2094 |
"/ show merged version in an editor ... |
|
2095 |
"/ ... accept will check it in. |
|
2096 |
"/ |
|
2097 |
[ |
|
2098 |
out := (tempdir construct:checkoutName) writeStream. |
|
2099 |
out nextPutAll:(mySource asString string). |
|
2100 |
didAccept := true. |
|
2101 |
out close. |
|
2102 |
checkInNew := checkInRepaired := true. |
|
2103 |
] on:FileStream openErrorSignal do:[:ex| |
|
2104 |
self warn:'could not write file ' , (tempdir constructString:checkoutName). |
|
2105 |
]. |
|
2106 |
]. |
|
2107 |
||
2108 |
checkInRepaired ifTrue:[ |
|
2109 |
checkInNew ifTrue:[ |
|
2110 |
Transcript showCR:'checking in ' , className , ' (force new version)...' |
|
2111 |
] ifFalse:[ |
|
2112 |
Transcript showCR:'checking in ' , className , ' (manually repaired version)...' |
|
2113 |
]. |
|
2114 |
] ifFalse:[ |
|
2115 |
'CVSSourceCodeManager [warning]: cannot (for now) checkin; conflicts found' infoPrintCR. |
|
2116 |
Transcript showCR:'checkin of ' , className , ' aborted (conflicting changes; repository unchanged)'. |
|
2117 |
tempdir recursiveRemove. |
|
2118 |
^ false. |
|
2119 |
] |
|
2120 |
] ifFalse:[ |
|
2121 |
((whatHappened startsWith:'U ') |
|
2122 |
or:[ (whatHappened startsWith:'P ') ]) ifTrue:[ |
|
2123 |
"/ |
|
2124 |
"/ nothing changed here, but the repository already contains |
|
2125 |
"/ a newer version. |
|
2126 |
"/ |
|
2127 |
tempdir recursiveRemove. |
|
2128 |
||
2129 |
self information:'nothing changed in your ''' , className , '''; |
|
2130 |
but repository already contains a newer version (repository unchanged).'. |
|
2131 |
^ true. |
|
2132 |
] ifFalse:[ |
|
2133 |
"/ |
|
2134 |
"/ unexpected |
|
2135 |
"/ |
|
2136 |
self warn:'unexpected message from CVS: |
|
2137 |
' , whatHappened , ' |
|
2138 |
||
2139 |
No checkin performed.'. |
|
2140 |
Transcript showCR:'*** cannot checkin ' , className , ' (unexpected CVS response; repository unchanged)'. |
|
2141 |
tempdir recursiveRemove. |
|
2142 |
^ false. |
|
2143 |
] |
|
2144 |
] |
|
2145 |
]. |
|
2146 |
||
2147 |
||
2148 |
"/ |
|
2149 |
"/ now check it in again |
|
2150 |
"/ |
|
2151 |
self activityNotification:'saving ' , cls name , ' in repository ...'. |
|
2152 |
||
2153 |
logMsg := logMsg replChar:$" withString:'\"'. |
|
2154 |
||
2155 |
OperatingSystem isUNIXlike ifFalse:[ |
|
2156 |
"/ save the log message into another tempFile ... |
|
2157 |
logTmp := Filename newTemporaryIn:tempdir. |
|
2158 |
s := logTmp writeStream. |
|
2159 |
s nextPutAll:logMsg. |
|
2160 |
s close. |
|
2161 |
||
2162 |
cmd := 'commit -F "', logTmp baseName, '" ', checkoutName, ' >', '"' , cmdOut name , '"'. |
|
2163 |
] ifTrue:[ |
|
2164 |
"/ |
|
2165 |
"/ CVS up to V1.9.14 prints the 'new revision' to stderr, |
|
2166 |
"/ CVS V1.9.16 to stdout. |
|
2167 |
"/ |
|
2168 |
cmd := 'commit -m "', logMsg, '" ', checkoutName, ' >', '"', cmdOut name, '"' , ' 2>&1'. |
|
2169 |
]. |
|
2170 |
(self |
|
2171 |
executeCVSCommand:cmd |
|
2172 |
module:moduleDir |
|
2173 |
inDirectory:tempdir name |
|
2174 |
) ifFalse:[ |
|
2175 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
2176 |
||
2177 |
(cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[ |
|
2178 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
2179 |
] ifFalse:[ |
|
2180 |
whatHappened := '<< no message >>' |
|
2181 |
]. |
|
2182 |
self warn:'The following problem was reported by cvs: |
|
2183 |
||
2184 |
' , whatHappened , ' |
|
2185 |
||
2186 |
The class has NOT been checked into the repository.'. |
|
2187 |
||
2188 |
'CVSSourceCodeManager [error]: cannot checkin modified class source' errorPrintCR. |
|
2189 |
logTmp notNil ifTrue:[logTmp remove]. |
|
2190 |
cmdOut remove. |
|
2191 |
tempdir recursiveRemove. |
|
2192 |
^ false. |
|
2193 |
]. |
|
2194 |
logTmp notNil ifTrue:[logTmp remove]. |
|
2195 |
(cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[ |
|
2196 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
2197 |
] ifFalse:[ |
|
2198 |
whatHappened := nil |
|
2199 |
]. |
|
2200 |
||
2201 |
tempdir recursiveRemove. |
|
2202 |
cmdOut remove. |
|
2203 |
||
2204 |
"/ |
|
2205 |
"/ fetch the new revision nr as found in the commit commands output |
|
2206 |
"/ |
|
2207 |
||
2208 |
(whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[ |
|
2209 |
'CVSSourceCodeManager [error]: unexpected empty checkin command output' errorPrintCR. |
|
2210 |
] ifFalse:[ |
|
2211 |
whatHappened := whatHappened asCollectionOfLines asStringCollection. |
|
2212 |
idx := whatHappened indexOfLineStartingWith:'new revision:'. |
|
2213 |
idx == 0 ifTrue:[ |
|
2214 |
'CVSSourceCodeManager [error]: unexpected checkin command output (no new-revision info)' errorPrintCR. |
|
2215 |
] ifFalse:[ |
|
2216 |
l := whatHappened at:idx. |
|
2217 |
newRevision := (l copyFrom:14 to:(l indexOf:$; startingAt:14)-1) withoutSpaces. |
|
2218 |
] |
|
2219 |
]. |
|
2220 |
||
2221 |
"/ |
|
2222 |
"/ if there was no merge (i.e. the current version has been checked in unchanged): |
|
2223 |
"/ patch the classes revisionInfo (but keep binaryRevision unchanged) to the new revision |
|
2224 |
"/ this makes everyone here believe, that the incore version of the class is based upon |
|
2225 |
"/ the newly checked in version. |
|
2226 |
"/ (however, the binaryRevision must remain as it is - we will need it to fetch the sourceCode |
|
2227 |
"/ correctly for all unchanged methodss) |
|
2228 |
"/ |
|
2229 |
"/ if there was a merge (i.e. the repository now contains a merge of the current and some |
|
2230 |
"/ other version): |
|
2231 |
"/ patch the classes revisionInfo (again, keep the binaryRevision) to the old revision |
|
2232 |
"/ and add a 'm' (for merged). |
|
2233 |
"/ If we later checkin again, the new checkin will be again based on the current revision |
|
2234 |
"/ |
|
2235 |
newRevision notNil ifTrue:[ |
|
2236 |
didMerge ifFalse:[ |
|
2237 |
self activityNotification:'fetch new revision number of ', cls name. |
|
2238 |
||
2239 |
changeLog := self revisionLogOf:cls fromRevision:newRevision toRevision:newRevision. |
|
2240 |
(changeLog isNil or:[(changeLog at:#revisions) size ~~ 1]) ifTrue:[ |
|
2241 |
force ifTrue:[ |
|
2242 |
changeLog := self revisionLogOfContainer:classFileName directory:packageDir module:moduleDir. |
|
2243 |
]. |
|
2244 |
]. |
|
2245 |
(changeLog isNil or:[(changeLog at:#revisions) size ~~ 1]) ifTrue:[ |
|
2246 |
'CVSSourceCodeManager [error]: failed to update revisionString (no log)' errorPrintCR. |
|
2247 |
cls updateVersionMethodFor:'$' , 'Header' , '$'. "/ concatenated to avoid RCS expansion |
|
2248 |
] ifFalse:[ |
|
2249 |
entry := (changeLog at:#revisions) first. |
|
2250 |
newString := self revisionStringFromLog:changeLog entry:entry forClass:cls. |
|
2251 |
cls updateVersionMethodFor:newString. |
|
2252 |
cls revision ~= newRevision ifTrue:[ |
|
2253 |
'CVSSourceCodeManager [error]: failed to update revisionString' errorPrintCR |
|
2254 |
] |
|
2255 |
] |
|
2256 |
] ifTrue:[ |
|
2257 |
newString := self updatedRevisionStringOf:cls forRevision:nil with:cls revisionString. |
|
2258 |
cls updateVersionMethodFor:newString. |
|
2259 |
]. |
|
2260 |
]. |
|
2261 |
||
2262 |
Class addChangeRecordForClassCheckIn:cls. |
|
2263 |
self postCheckInClass:cls. |
|
2264 |
||
2265 |
(checkInRepaired and:[checkInNew not]) ifTrue:[ |
|
2266 |
self information:'Now the repository contains a merge between your and the other changes. |
|
2267 |
However, the class in your image does NOT contain the other changes. |
|
2268 |
This will lead to more conflict-resolving whenever you check this class in again later, |
|
2269 |
unless you load the newest (merged) version of the class from the repository. |
|
2270 |
||
2271 |
I recommend doing this as soon as possible via your browsers checkout function.' |
|
2272 |
]. |
|
2273 |
^ true |
|
2274 |
||
2275 |
" |
|
2276 |
SourceCodeManager checkinClass:Array logMessage:'testing only' |
|
2277 |
" |
|
2278 |
||
2279 |
"Created: / 11.9.1996 / 16:16:11 / cg" |
|
2280 |
"Modified: / 26.2.1998 / 17:34:16 / stefan" |
|
2281 |
"Modified: / 5.11.2001 / 14:35:38 / cg" |
|
130 | 2282 |
! |
2283 |
||
1362 | 2284 |
checkoutModule:aModule package:aPackage andDo:aBlock |
2285 |
"check out everything from a package into a temporary directory. |
|
2286 |
Then evaluate aBlock, passing the name of that temp-directory. |
|
2287 |
Afterwards, the tempDir is removed. |
|
2288 |
Return true, if OK, false if any error occurred." |
|
2289 |
||
2290 |
|cvsRoot packageDir tempdir cmdOut cmd dirName| |
|
2291 |
||
2292 |
cvsRoot := self getCVSROOTForModule:aModule. |
|
2293 |
cvsRoot isNil ifTrue:[^ false ]. |
|
2294 |
||
2295 |
aPackage notNil ifTrue:[ |
|
2296 |
dirName := aModule , '/' , aPackage. |
|
2297 |
] ifFalse:[ |
|
2298 |
dirName := aModule. |
|
2299 |
]. |
|
2300 |
||
2301 |
self activityNotification:'checking out everything in ' , dirName , ' ...'. |
|
2302 |
||
2303 |
tempdir := self createTempDirectory:nil forModule:nil. |
|
2304 |
tempdir isNil ifTrue:[ |
|
2305 |
('CVSSourceCodeManager [error]: no tempDir - cannot checkout') errorPrintCR. |
|
2306 |
^ false |
|
2307 |
]. |
|
2308 |
||
1393
28d04a5111c6
cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents:
1390
diff
changeset
|
2309 |
cmd := 'checkout ', dirName. |
1362 | 2310 |
OperatingSystem isUNIXlike ifTrue:[ |
2311 |
"/ can redirect output |
|
2312 |
cmdOut := Filename newTemporary. |
|
2313 |
cmdOut exists ifTrue:[ |
|
2314 |
cmdOut remove. |
|
2315 |
]. |
|
2316 |
cmd := cmd , ' > ', '"' , cmdOut name, '"' . |
|
2317 |
]. |
|
2318 |
||
2319 |
(self |
|
2320 |
executeCVSCommand:cmd |
|
2321 |
module:aModule |
|
2322 |
inDirectory:tempdir name |
|
2323 |
) ifFalse:[ |
|
2324 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
2325 |
cmdOut notNil ifTrue:[cmdOut remove]. |
|
2326 |
tempdir recursiveRemove. |
|
2327 |
^ false |
|
2328 |
]. |
|
2329 |
||
2330 |
cmdOut notNil ifTrue:[ |
|
2331 |
"/ listOfFiles := cmdOut contents. |
|
2332 |
cmdOut remove |
|
2333 |
]. |
|
2334 |
||
2335 |
packageDir := (tempdir construct:dirName). |
|
2336 |
(packageDir isDirectory) ifFalse:[ |
|
2337 |
'CVSSourceCodeManager [error]: checkout failed (no dir)' errorPrintCR. |
|
2338 |
tempdir recursiveRemove. |
|
2339 |
^ false |
|
2340 |
]. |
|
2341 |
||
2342 |
"/ now, invoke the block ... |
|
2343 |
[ |
|
2344 |
aBlock value:packageDir |
|
2345 |
] ensure:[ |
|
2346 |
tempdir recursiveRemove. |
|
2347 |
]. |
|
2348 |
||
2349 |
^ true |
|
2350 |
||
2351 |
"Modified: / 28.4.1999 / 12:21:10 / cg" |
|
2352 |
! |
|
2353 |
||
1405 | 2354 |
streamForClass:cls fileName:fileName revision:revision directory:packageDir module:moduleDir cache:cacheItArg |
1362 | 2355 |
"extract a source file and return an open readStream on it, |
2356 |
or nil if the extract failed. If revision is nil or (#newest), take |
|
2357 |
the latest; otherwise, a specific revisions source is extracted. |
|
2358 |
The cls argument is currently ignored, but may be used in future versions, |
|
2359 |
to validate the correct container against the class. |
|
2360 |
To check out a file (i.e. not a classes file), leave it nil." |
|
2361 |
||
2362 |
|dir cachedSourceFilename cachedFile cmd fullName revisionArg stream |
|
2363 |
checkoutName checkoutNameLocal fullTempName fullCachedName tempdir cmdOut |
|
1405 | 2364 |
classFileName cvsRoot tempFile revMsg cacheIt| |
2365 |
||
2366 |
cacheIt := cacheItArg. |
|
1362 | 2367 |
|
2368 |
(DisabledModules notNil and:[DisabledModules includes:moduleDir]) ifTrue:[ |
|
2369 |
Transcript showCR:'cvs access for module ' , moduleDir , ' has been disabled (due to previous failure)'. |
|
2370 |
Transcript showCR:'reenable using the launchers source&debugger dialog'. |
|
2371 |
||
2372 |
^ nil |
|
2373 |
]. |
|
2374 |
||
2375 |
cvsRoot := self getCVSROOTForModule:moduleDir. |
|
2376 |
cvsRoot isNil ifTrue:[^ nil]. |
|
2377 |
||
2378 |
"/ if not already existing, create a cache directory |
|
2379 |
"/ where we deposit sources. |
|
2380 |
"/ this is used as a cache for further requests, since |
|
2381 |
"/ accessing the repository may be slow. |
|
2382 |
"/ (if cvs uses a remote connection via ppp, for example) |
|
2383 |
"/ |
|
2384 |
||
2385 |
revision ~~ #newest ifTrue:[ |
|
2386 |
(dir := self sourceCacheDirectory) isNil ifTrue:[ |
|
2387 |
'CVSSourceCodeManager [warning]: no source cache directory' errorPrintCR. |
|
2388 |
] |
|
2389 |
]. |
|
2390 |
||
2391 |
classFileName := fileName. |
|
2392 |
(classFileName endsWith:',v') ifTrue:[ |
|
2393 |
classFileName := classFileName copyWithoutLast:2. |
|
2394 |
]. |
|
2395 |
(classFileName endsWith:'.st') ifTrue:[ |
|
2396 |
cls notNil ifTrue:[ |
|
2397 |
classFileName := classFileName copyWithoutLast:3. |
|
2398 |
] |
|
2399 |
]. |
|
2400 |
fullName := moduleDir , '/' , packageDir , '/' , classFileName. |
|
2401 |
cls notNil ifTrue:[ |
|
2402 |
fullName := fullName , '.st'. |
|
2403 |
]. |
|
2404 |
||
2405 |
(revision isNil or:[revision == #newest]) ifTrue:[ |
|
2406 |
cachedSourceFilename := classFileName. |
|
2407 |
] ifFalse:[ |
|
2408 |
cachedSourceFilename := classFileName , '_' , revision. |
|
2409 |
]. |
|
2410 |
||
2411 |
dir notNil ifTrue:[ |
|
2412 |
cachedFile := dir construct:cachedSourceFilename. |
|
2413 |
cachedFile exists ifTrue:[ |
|
2414 |
"/ cachedFile fileSize < 10 ifTrue:[ |
|
2415 |
"/ ('CVSSourceCodeManager [warning]: existing: ', cachedFile name , ' seems corrupted.') errorPrintCR. |
|
2416 |
"/ cachedFile remove |
|
2417 |
"/ ] ifFalse:[ |
|
2418 |
"/ ('CVSSourceCodeManager [info]: found existing: ', cachedFile name) infoPrintCR. |
|
2419 |
^ cachedFile readStream |
|
2420 |
"/ ] |
|
2421 |
]. |
|
2422 |
]. |
|
2423 |
||
2424 |
"/ |
|
2425 |
"/ first, create a temporary work tree |
|
2426 |
"/ Do not make module and package directories, their existence cause cvs checkout to fail in server mode |
|
2427 |
"/ |
|
2428 |
tempdir := self createTempDirectory:nil forModule:nil. |
|
2429 |
tempdir isNil ifTrue:[ |
|
2430 |
('CVSSourceCodeManager [error]: no tempDir - cannot checkout ' , classFileName) errorPrintCR. |
|
2431 |
^ nil |
|
2432 |
]. |
|
2433 |
||
2434 |
"/ tempdir := Filename newTemporaryIn:nil. |
|
2435 |
"/ tempdir exists ifTrue:[ |
|
2436 |
"/ tempdir recursiveRemove. |
|
2437 |
"/ ]. |
|
2438 |
"/ tempdir makeDirectory. |
|
2439 |
"/ dir := tempdir construct:moduleDir. |
|
2440 |
"/ dir makeDirectory. |
|
2441 |
"/ dir := dir construct:packageDir. |
|
2442 |
"/ dir recursiveMakeDirectory. |
|
2443 |
"/ dir exists ifFalse:[ |
|
2444 |
"/ tempdir recursiveRemove. |
|
2445 |
"/ 'CVSMGR: cannot create temporary directory' infoPrintCR. |
|
2446 |
"/ ^ nil. |
|
2447 |
"/ ]. |
|
2448 |
||
2449 |
"/ |
|
2450 |
"/ check it out there |
|
2451 |
"/ |
|
2452 |
checkoutName := fullName. |
|
2453 |
||
2454 |
checkoutNameLocal := (moduleDir asFilename construct:packageDir) constructString:(fullName asFilename baseName). |
|
2455 |
||
2456 |
(revision isNil or:[revision == #newest]) ifTrue:[ |
|
2457 |
cachedSourceFilename := classFileName. |
|
2458 |
revisionArg := ''. |
|
2459 |
revMsg := ''. |
|
2460 |
] ifFalse:[ |
|
2461 |
cachedSourceFilename := classFileName , '_' , revision. |
|
2462 |
revisionArg := ' -r ' , revision. |
|
2463 |
revMsg := ' (' , revision , ')'. |
|
2464 |
]. |
|
2465 |
||
2466 |
self activityNotification:'checking out source ' , checkoutName , revMsg. |
|
2467 |
OperatingSystem isUNIXlike ifTrue:[ |
|
2468 |
"/ can redirect output |
|
2469 |
cmdOut := Filename newTemporary. |
|
2470 |
cmdOut exists ifTrue:[ |
|
2471 |
cmdOut remove. |
|
2472 |
]. |
|
1393
28d04a5111c6
cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents:
1390
diff
changeset
|
2473 |
cmd := 'checkout' , revisionArg , ' ', checkoutName , ' > ' , '"' , cmdOut name, '"' . |
1362 | 2474 |
] ifFalse:[ |
1393
28d04a5111c6
cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents:
1390
diff
changeset
|
2475 |
cmd := 'checkout' , revisionArg , ' ', checkoutName. |
1362 | 2476 |
]. |
2477 |
||
2478 |
(self |
|
2479 |
executeCVSCommand:cmd |
|
2480 |
module:moduleDir |
|
2481 |
inDirectory:tempdir name |
|
2482 |
) ifFalse:[ |
|
2483 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
2484 |
cmdOut notNil ifTrue:[cmdOut remove]. |
|
2485 |
tempdir recursiveRemove. |
|
2486 |
('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR. |
|
2487 |
"/ see if there is CVS access at all ... |
|
2488 |
(self checkForExistingModule:moduleDir) ifFalse:[ |
|
2489 |
"/ disable |
|
2490 |
DisabledModules isNil ifTrue:[ |
|
2491 |
DisabledModules := Set new. |
|
2492 |
]. |
|
2493 |
DisabledModules add:moduleDir. |
|
2494 |
('CVSSourceCodeManager [warning]: disabled repository access for module ' , moduleDir) errorPrintCR. |
|
2495 |
]. |
|
2496 |
^ nil. |
|
2497 |
]. |
|
2498 |
||
2499 |
cmdOut notNil ifTrue:[cmdOut remove]. |
|
2500 |
fullTempName := tempdir construct:checkoutNameLocal. |
|
1405 | 2501 |
CacheDirectoryName isNil ifTrue:[ |
2502 |
cacheIt := false |
|
2503 |
] ifFalse:[ |
|
2504 |
fullCachedName := CacheDirectoryName asFilename constructString:cachedSourceFilename. |
|
2505 |
]. |
|
1362 | 2506 |
fullTempName exists ifFalse:[ |
2507 |
('CVSSourceCodeManager [error]: failed to checkout ', fullTempName pathName, ' (file does not exist after cvs co)') errorPrintCR. |
|
2508 |
tempdir recursiveRemove. |
|
2509 |
^ nil |
|
2510 |
]. |
|
2511 |
||
2512 |
(cacheIt |
|
2513 |
and:[cachedFile notNil |
|
2514 |
and:[fullTempName exists]]) |
|
2515 |
ifTrue:[ |
|
2516 |
(OperatingSystem errorSignal catch:[ |
|
2517 |
fullTempName moveTo:fullCachedName |
|
2518 |
]) ifTrue:[ |
|
2519 |
('CVSSourceCodeManager [error]: failed to rename ', fullTempName pathName, ' to ', cachedSourceFilename) errorPrintCR. |
|
2520 |
tempdir recursiveRemove. |
|
2521 |
^ nil |
|
2522 |
]. |
|
2523 |
fullCachedName asFilename exists ifTrue:[ |
|
2524 |
stream := fullCachedName asFilename readStream. |
|
2525 |
]. |
|
2526 |
] ifFalse:[ |
|
2527 |
OperatingSystem isUNIXlike ifFalse:[ |
|
2528 |
"/ cannot remove files which are still open ... |
|
2529 |
"/ sigh - need a delete-on-close flag in FileStream. |
|
2530 |
"/ |
|
2531 |
tempFile := Filename newTemporary. |
|
2532 |
fullTempName copyTo:tempFile. |
|
2533 |
stream := tempFile readStream. |
|
2534 |
stream notNil ifTrue:[ |
|
2535 |
stream removeOnClose:true. |
|
2536 |
]. |
|
2537 |
] ifTrue:[ |
|
2538 |
stream := fullTempName readStream. |
|
2539 |
] |
|
2540 |
]. |
|
2541 |
||
2542 |
self releaseAndRemove:tempdir module:moduleDir outputTo:nil. |
|
2543 |
^ stream |
|
2544 |
||
2545 |
"Created: / 4.11.1995 / 19:46:20 / cg" |
|
2546 |
"Modified: / 20.8.1997 / 16:37:11 / stefan" |
|
2547 |
"Modified: / 23.8.2001 / 12:28:59 / cg" |
|
2548 |
! ! |
|
2549 |
||
2550 |
!CVSSourceCodeManager class methodsFor:'source code administration'! |
|
2551 |
||
2552 |
checkForExistingContainerInModule:moduleDir package:packageDir container:fileName |
|
2553 |
"check for a container to exist" |
|
2554 |
||
2555 |
|fullName ret cvsRoot cmd tempDir| |
|
2556 |
||
2557 |
cvsRoot := self getCVSROOTForModule:moduleDir. |
|
2558 |
||
2559 |
fullName := moduleDir , '/' , packageDir , '/' , fileName. |
|
2560 |
||
2561 |
RemoteCVS ifFalse:[ |
|
2562 |
cvsRoot asFilename exists ifTrue:[ |
|
2563 |
"/ |
|
2564 |
"/ with local CVS - simply check if that file exists |
|
2565 |
"/ |
|
2566 |
(fullName endsWith:',v') ifFalse:[ |
|
2567 |
fullName := fullName , ',v'. |
|
2568 |
]. |
|
2569 |
^ (cvsRoot , '/' , fullName) asFilename exists. |
|
2570 |
]. |
|
2571 |
]. |
|
2572 |
||
2573 |
tempDir := self createTempDirectory:nil forModule:nil. |
|
2574 |
||
2575 |
"With remote CVS, do a no-op rtag command, which doesn't |
|
2576 |
need a working directory, but reports missing files" |
|
2577 |
||
2578 |
(fullName endsWith:',v') ifTrue:[ |
|
2579 |
fullName := fullName copyWithoutLast:2. |
|
2580 |
]. |
|
2581 |
||
2582 |
cmd := '-n rtag -l -F dummy '. |
|
1390
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2583 |
[ |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2584 |
|errorStream| |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2585 |
errorStream := '' writeStream. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2586 |
|
1362 | 2587 |
ret := self |
2588 |
executeCVSCommand:cmd , fullName |
|
2589 |
module:moduleDir |
|
2590 |
"/ cg; cannot do it in current dir, in case it contains a CVS subDirectory, |
|
2591 |
"/ with a different CVSRoot in its CVS/Root file ... |
|
2592 |
"/ cvs would complain then. |
|
2593 |
inDirectory:(tempDir pathName) |
|
1390
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2594 |
log:false |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2595 |
errorTo:errorStream. |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2596 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2597 |
"cannot check for exit status starting at cvs 1.11.5, because an exit status 0 |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2598 |
is returned even if the file does not exist" |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2599 |
|
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2600 |
"But: if there is any output, the command failed and the container does not exist" |
5ca713ed160e
Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents:
1388
diff
changeset
|
2601 |
ret := errorStream size == 0. |
1362 | 2602 |
] ensure:[ |
2603 |
tempDir recursiveRemove. |
|
2604 |
]. |
|
2605 |
^ ret |
|
2606 |
||
2607 |
" |
|
2608 |
CVSSourceCodeManager |
|
2609 |
checkForExistingContainerInModule:'stx' |
|
2610 |
package:'libbasic' |
|
2611 |
container:'Integer.st' |
|
2612 |
||
2613 |
CVSSourceCodeManager |
|
2614 |
checkForExistingContainerInModule:'stx' |
|
2615 |
package:'libtool' |
|
2616 |
container:'AboutBox.st' |
|
2617 |
||
2618 |
CVSSourceCodeManager |
|
2619 |
checkForExistingContainerInModule:'stx' |
|
2620 |
package:'libtool' |
|
2621 |
container:'AboutBox.st,v' |
|
2622 |
||
2623 |
CVSSourceCodeManager |
|
2624 |
checkForExistingContainerInModule:'stx' |
|
2625 |
package:'libtool' |
|
2626 |
container:'FooBar.st' |
|
2627 |
||
2628 |
CVSSourceCodeManager |
|
2629 |
checkForExistingContainerInModule:'DPU' |
|
2630 |
package:'test' |
|
2631 |
container:'marks' |
|
2632 |
" |
|
2633 |
||
2634 |
"Created: / 9.12.1995 / 19:13:37 / cg" |
|
2635 |
"Modified: / 1.3.1999 / 19:32:55 / cg" |
|
2636 |
"Modified: / 23.7.1999 / 17:36:58 / stefan" |
|
2637 |
! |
|
2638 |
||
2639 |
checkForExistingModule:moduleDir |
|
2640 |
"check for a module to exist" |
|
2641 |
||
2642 |
|ret cvsRoot cmd tempDir| |
|
2643 |
||
2644 |
self activityNotification:'checking for existing module ' , moduleDir. |
|
2645 |
||
2646 |
cvsRoot := self getCVSROOTForModule:moduleDir. |
|
2647 |
cvsRoot isNil ifTrue:[^ false]. |
|
2648 |
||
2649 |
RemoteCVS ifFalse:[ |
|
2650 |
cvsRoot asFilename exists ifTrue:[ |
|
2651 |
"/ |
|
2652 |
"/ with local CVS - simply check if that directory exists |
|
2653 |
"/ |
|
2654 |
^ (cvsRoot , '/' , moduleDir) asFilename isDirectory. |
|
2655 |
] |
|
2656 |
]. |
|
2657 |
||
2658 |
tempDir := self createTempDirectory:nil forModule:nil. |
|
2659 |
||
2660 |
"With remote CVS, do a no-op rtag command, which doesn't |
|
2661 |
need a working directory, but reports missing files" |
|
2662 |
||
2663 |
cmd := '-n rtag -l dummy '. |
|
2664 |
[ |
|
2665 |
ret := self |
|
2666 |
executeCVSCommand:cmd , moduleDir |
|
2667 |
module:moduleDir |
|
2668 |
"/ cg; cannot do it in current dir, in case it contains a CVS subDirectory, |
|
2669 |
"/ with a different CVSRoot in its CVS/Root file ... |
|
2670 |
"/ cvs would complain then. |
|
2671 |
inDirectory:(tempDir pathName) |
|
2672 |
log:false. |
|
2673 |
] ensure:[ |
|
2674 |
tempDir recursiveRemove. |
|
2675 |
]. |
|
2676 |
^ ret |
|
2677 |
||
2678 |
" |
|
2679 |
CVSSourceCodeManager checkForExistingModule:'stx' |
|
2680 |
CVSSourceCodeManager checkForExistingModule:'DPU' |
|
2681 |
CVSSourceCodeManager checkForExistingModule:'cg' |
|
2682 |
CVSSourceCodeManager checkForExistingModule:'aeg' |
|
2683 |
CVSSourceCodeManager checkForExistingModule:'foo' |
|
2684 |
" |
|
2685 |
||
2686 |
"Created: / 9.12.1995 / 19:13:37 / cg" |
|
2687 |
"Modified: / 1.3.1999 / 19:32:59 / cg" |
|
2688 |
"Modified: / 23.7.1999 / 17:38:59 / stefan" |
|
2689 |
! |
|
2690 |
||
2691 |
checkForExistingModule:moduleDir package:packageDir |
|
2692 |
"check for a package to exist" |
|
2693 |
||
2694 |
|ret cvsRoot cmd tempDir fullName | |
|
2695 |
||
2696 |
self activityNotification:'checking for existing package ' , packageDir. |
|
2697 |
||
1365 | 2698 |
cvsRoot := self getCVSROOTForModule:moduleDir. |
2699 |
cvsRoot isNil ifTrue:[^ false]. |
|
2700 |
||
1362 | 2701 |
fullName := moduleDir , '/' , packageDir. |
2702 |
||
2703 |
RemoteCVS ifFalse:[ |
|
2704 |
cvsRoot asFilename exists ifTrue:[ |
|
2705 |
"/ |
|
2706 |
"/ with local CVS - simply check if that directory exists |
|
2707 |
"/ |
|
2708 |
^ (cvsRoot , '/' , fullName) asFilename isDirectory. |
|
2709 |
]. |
|
2710 |
]. |
|
2711 |
||
2712 |
tempDir := self createTempDirectory:nil forModule:nil. |
|
2713 |
||
2714 |
"With remote CVS, do a no-op rtag command, which doesn't |
|
2715 |
need a working directory, but reports missing files" |
|
2716 |
||
2717 |
cmd := '-n rtag -l -F dummy '. |
|
2718 |
[ |
|
2719 |
ret := self |
|
2720 |
executeCVSCommand:cmd, fullName |
|
2721 |
module:moduleDir |
|
2722 |
"/ cg; cannot do it in current dir, in case it contains a CVS subDirectory, |
|
2723 |
"/ with a different CVSRoot in its CVS/Root file ... |
|
2724 |
"/ cvs would complain then. |
|
2725 |
inDirectory:(tempDir pathName) |
|
2726 |
log:false. |
|
2727 |
||
2728 |
] ensure:[ |
|
2729 |
tempDir recursiveRemove. |
|
2730 |
]. |
|
2731 |
^ ret |
|
2732 |
||
2733 |
" |
|
2734 |
CVSSourceCodeManager checkForExistingModule:'stx' package:'libbasic' |
|
2735 |
CVSSourceCodeManager checkForExistingModule:'aeg' package:'libProgram' |
|
2736 |
CVSSourceCodeManager checkForExistingModule:'foo' package:'libbasic' |
|
2737 |
CVSSourceCodeManager checkForExistingModule:'foo' package:'bar' |
|
2738 |
CVSSourceCodeManager checkForExistingModule:'cg' package:'private' |
|
2739 |
" |
|
2740 |
||
2741 |
"Created: / 9.12.1995 / 19:13:37 / cg" |
|
2742 |
"Modified: / 1.3.1999 / 19:33:04 / cg" |
|
2743 |
"Modified: / 23.7.1999 / 17:39:21 / stefan" |
|
2744 |
! |
|
2745 |
||
2746 |
createContainerFor:aClass inModule:moduleDir package:packageDir container:fileName |
|
2747 |
"create a container - this does an initial checkin |
|
2748 |
(i.e. cvs add & cvs commit)" |
|
2749 |
||
2750 |
|fullName tempdir checkoutName cmdOut cmd tempFile idx aStream whatHappened l newRevision |
|
2751 |
changeLog entry newString startIdx endIdx checkInDir logTmp s| |
|
2752 |
||
2753 |
||
2754 |
cmdOut := Filename newTemporary. |
|
2755 |
cmdOut exists ifTrue:[ |
|
2756 |
cmdOut remove. |
|
2757 |
]. |
|
2758 |
||
2759 |
fullName := moduleDir , '/' , packageDir , '/' , fileName. |
|
2760 |
checkoutName := moduleDir , '/' , packageDir. |
|
2761 |
||
2762 |
"/ |
|
2763 |
"/ first, check out everything there - this creates the CVS helpfiles |
|
2764 |
"/ required later. |
|
2765 |
"/ |
|
2766 |
||
2767 |
self activityNotification:'checking for directory ' , checkoutName. |
|
2768 |
tempdir := self createLocalDirectory:packageDir inModule:moduleDir. |
|
2769 |
tempdir isNil ifTrue:[ |
|
2770 |
('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR. |
|
2771 |
^ false. |
|
2772 |
]. |
|
2773 |
||
2774 |
"/ |
|
2775 |
"/ create the source there |
|
2776 |
"/ |
|
2777 |
tempFile := (tempdir construct:checkoutName) construct:fileName. |
|
2778 |
[ |
|
2779 |
aStream := tempFile writeStream. |
|
2780 |
] on:FileStream openErrorSignal do:[:ex| |
|
2781 |
('CVSSourceCodeManager [error]: temporary fileout failed -> ', tempFile name) errorPrintCR. |
|
2782 |
tempdir recursiveRemove. |
|
2783 |
^ false |
|
2784 |
]. |
|
2785 |
||
2786 |
Class fileOutErrorSignal handle:[:ex | |
|
2787 |
'CVSSourceCodeManager [error]: fileout failed' errorPrintCR. |
|
2788 |
aStream close. |
|
2789 |
tempdir recursiveRemove. |
|
2790 |
^ false |
|
2791 |
] do:[ |
|
2792 |
aClass fileOutOn:aStream withTimeStamp:false. |
|
2793 |
]. |
|
2794 |
aStream close. |
|
2795 |
||
2796 |
tempFile exists ifFalse:[ |
|
2797 |
'CVSSourceCodeManager [error]: temporary fileout failed' errorPrintCR. |
|
2798 |
tempdir recursiveRemove. |
|
2799 |
^ false |
|
2800 |
]. |
|
2801 |
||
2802 |
"/ |
|
2803 |
"/ and add it to the repository |
|
2804 |
"/ |
|
2805 |
self activityNotification:'adding ' , fileName. |
|
2806 |
||
2807 |
OperatingSystem isUNIXlike ifTrue:[ |
|
2808 |
checkInDir := tempdir constructString:checkoutName. |
|
2809 |
] ifFalse:[ |
|
2810 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
2811 |
checkInDir := tempdir constructString:(checkoutName copyReplaceAll:$/ with:$\). |
|
2812 |
] ifFalse:[ |
|
2813 |
self error:'VMS case not yet implemented'. "/ add code for VMS ... |
|
2814 |
] |
|
2815 |
]. |
|
2816 |
cmd := 'add ' , fileName , ' > ', '"' , cmdOut name, '"'. |
|
2817 |
(self |
|
2818 |
executeCVSCommand:cmd |
|
2819 |
module:moduleDir |
|
2820 |
inDirectory:checkInDir |
|
2821 |
) ifFalse:[ |
|
2822 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
2823 |
||
2824 |
cmdOut remove. |
|
2825 |
tempdir recursiveRemove. |
|
2826 |
('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR. |
|
2827 |
^ false. |
|
2828 |
]. |
|
2829 |
cmdOut remove. |
|
2830 |
||
2831 |
"/ |
|
2832 |
"/ commit |
|
2833 |
"/ |
|
2834 |
self activityNotification:'committing ' , fileName. |
|
2835 |
||
2836 |
OperatingSystem isUNIXlike ifFalse:[ |
|
2837 |
"/ save the log message into another tempFile ... |
|
2838 |
logTmp := Filename newTemporaryIn:checkInDir. |
|
2839 |
s := logTmp writeStream. |
|
2840 |
s nextPutAll:'initial checkin'. |
|
2841 |
s close. |
|
2842 |
||
2843 |
cmd := 'commit -F "', logTmp baseName, '" ', fileName, ' > ', '"', cmdOut name, '"'. |
|
2844 |
] ifTrue:[ |
|
2845 |
"/ |
|
2846 |
"/ CVS up to V1.9.14 prints the 'new revision' to stderr, |
|
2847 |
"/ CVS V1.9.16 to stdout. |
|
2848 |
"/ |
|
2849 |
cmd := 'commit -m "initial checkin" ' , fileName , ' > ', '"' , cmdOut name, '"', ' 2>&1'. |
|
2850 |
]. |
|
2851 |
||
2852 |
(self |
|
2853 |
executeCVSCommand:cmd |
|
2854 |
module:moduleDir |
|
2855 |
inDirectory:checkInDir "tempdir name" |
|
2856 |
) ifFalse:[ |
|
2857 |
Verbose == true ifTrue:[ |
|
2858 |
'CVSMGR: failed to execute: ' infoPrint. cmd infoPrintCR. |
|
2859 |
]. |
|
2860 |
cmdOut fileSize > 0 ifTrue:[ |
|
2861 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
2862 |
] ifFalse:[ |
|
2863 |
whatHappened := '<< no message >>' |
|
2864 |
]. |
|
2865 |
self warn:'The following problem was reported by cvs: |
|
2866 |
||
2867 |
' , whatHappened , ' |
|
2868 |
||
2869 |
The class has NOT been checked into the repository.'. |
|
2870 |
||
2871 |
'CVSSourceCodeManager [error]: cannot checkin modified class source' errorPrintCR. |
|
2872 |
cmdOut remove. |
|
2873 |
tempdir recursiveRemove. |
|
2874 |
^ false. |
|
2875 |
]. |
|
2876 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
2877 |
cmdOut remove. |
|
2878 |
||
2879 |
"/ |
|
2880 |
"/ release it towards cvs |
|
2881 |
"/ |
|
2882 |
self releaseAndRemove:tempdir module:moduleDir outputTo:nil. |
|
2883 |
||
2884 |
"/ |
|
2885 |
"/ good - its in the CVS repository; now, we need the updated RCS header |
|
2886 |
"/ |
|
2887 |
(whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[ |
|
2888 |
'CVSSourceCodeManager [warning]: unexpected empty commit command output' errorPrintCR. |
|
2889 |
"/ TODO: scan the file for $Header ... |
|
2890 |
"/ and extract the revision manually |
|
2891 |
||
2892 |
] ifFalse:[ |
|
2893 |
whatHappened := whatHappened asCollectionOfLines asStringCollection. |
|
2894 |
idx := whatHappened indexOfLineStartingWith:'initial revision:'. |
|
2895 |
idx ~~ 0 ifTrue:[ |
|
2896 |
startIdx := 18 |
|
2897 |
] ifFalse:[ |
|
2898 |
idx := whatHappened indexOfLineStartingWith:'new revision:'. |
|
2899 |
idx ~~ 0 ifTrue:[ |
|
2900 |
'CVSSourceCodeManager [warning]: container existed before' errorPrintCR. |
|
2901 |
startIdx := 14. |
|
2902 |
] ifFalse:[ |
|
2903 |
'CVSSourceCodeManager [warning]: unexpected commit command output (no new-revision info)' errorPrintCR. |
|
2904 |
] |
|
2905 |
]. |
|
2906 |
idx ~~ 0 ifTrue:[ |
|
2907 |
l := whatHappened at:idx. |
|
2908 |
endIdx := (l indexOf:$; startingAt:startIdx) - 1. |
|
2909 |
endIdx < 0 ifTrue:[ |
|
2910 |
endIdx := l size |
|
2911 |
]. |
|
2912 |
newRevision := (l copyFrom:startIdx to:endIdx) withoutSpaces. |
|
2913 |
(Number fromString:newRevision onError:nil) isNil ifTrue:[ |
|
2914 |
newRevision := '1.1' |
|
2915 |
] |
|
2916 |
] |
|
2917 |
]. |
|
2918 |
||
2919 |
Transcript showCR:'created new sourceContainer for ' , aClass name , '.'. |
|
2920 |
||
2921 |
"/ |
|
2922 |
"/ patch the classes revisionInfo (but keep binaryRevision unchanged) |
|
2923 |
"/ this makes everyone here believe, that the incore version of the class is based upon |
|
2924 |
"/ the newly checked in version. |
|
2925 |
"/ (however, the binaryRevision must remain as it is - we will need it to fetch the sourceCode |
|
2926 |
"/ correctly for all unchanged methodss) |
|
2927 |
"/ |
|
2928 |
||
2929 |
newRevision notNil ifTrue:[ |
|
2930 |
changeLog := self |
|
2931 |
revisionLogOf:aClass |
|
2932 |
fromRevision:newRevision |
|
2933 |
toRevision:newRevision |
|
2934 |
fileName:fileName |
|
2935 |
directory:packageDir |
|
2936 |
module:moduleDir. |
|
2937 |
||
2938 |
(changeLog isNil or:[(changeLog at:#revisions) size ~~ 1]) ifTrue:[ |
|
2939 |
'CVSSourceCodeManager [error]: failed to update revisionString (no log)' errorPrintCR |
|
2940 |
] ifFalse:[ |
|
2941 |
entry := (changeLog at:#revisions) first. |
|
2942 |
newString := self revisionStringFromLog:changeLog entry:entry forClass:aClass. |
|
2943 |
aClass updateVersionMethodFor:newString. |
|
2944 |
('CVSSourceCodeManager [info]: updated revisionString to:',newString) infoPrintCR |
|
2945 |
] |
|
2946 |
]. |
|
2947 |
||
2948 |
tempdir recursiveRemove. |
|
2949 |
||
2950 |
Class addChangeRecordForClassCheckIn:aClass. |
|
2951 |
self postCheckInClass:aClass. |
|
2952 |
^ true |
|
2953 |
||
2954 |
"Created: / 9.12.1995 / 19:13:37 / cg" |
|
2955 |
"Modified: / 23.7.1999 / 19:47:59 / stefan" |
|
2956 |
"Modified: / 5.11.2001 / 14:22:56 / cg" |
|
2957 |
! |
|
2958 |
||
2959 |
createContainerForText:someText inModule:moduleDir package:packageDir container:fileName |
|
2960 |
"create a container - this does an initial checkin |
|
2961 |
(i.e. cvs add & cvs commit)" |
|
2962 |
||
2963 |
|fullName tempdir checkoutName cmdOut cmd tempFile idx aStream whatHappened l newRevision |
|
2964 |
startIdx endIdx checkInDir logTmp s| |
|
2965 |
||
2966 |
cmdOut := Filename newTemporary. |
|
2967 |
cmdOut exists ifTrue:[ |
|
2968 |
cmdOut remove. |
|
2969 |
]. |
|
2970 |
||
2971 |
fullName := moduleDir , '/' , packageDir , '/' , fileName. |
|
2972 |
checkoutName := moduleDir , '/' , packageDir. |
|
2973 |
||
2974 |
"/ |
|
2975 |
"/ first, check out everything there - this creates the CVS helpfiles |
|
2976 |
"/ required later. |
|
2977 |
"/ |
|
2978 |
||
2979 |
self activityNotification:'checking for directory ' , checkoutName. |
|
2980 |
tempdir := self createLocalDirectory:packageDir inModule:moduleDir. |
|
2981 |
tempdir isNil ifTrue:[ |
|
2982 |
('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR. |
|
2983 |
^ false. |
|
2984 |
]. |
|
2985 |
||
2986 |
[ |
|
2987 |
"/ |
|
2988 |
"/ create the source there |
|
2989 |
"/ |
|
2990 |
tempFile := (tempdir construct:checkoutName) construct:fileName. |
|
2991 |
[ |
|
2992 |
aStream := tempFile writeStream. |
|
2993 |
] on:FileStream openErrorSignal do:[:ex| |
|
2994 |
('CVSSourceCodeManager [error]: temporary fileout failed -> ', tempFile name) errorPrintCR. |
|
2995 |
^ false |
|
2996 |
]. |
|
2997 |
||
2998 |
aStream nextPutAll:someText. |
|
2999 |
aStream close. |
|
3000 |
||
3001 |
tempFile exists ifFalse:[ |
|
3002 |
'CVSSourceCodeManager [error]: temporary fileout failed' errorPrintCR. |
|
3003 |
^ false |
|
3004 |
]. |
|
3005 |
||
3006 |
"/ |
|
3007 |
"/ and add it to the repository |
|
3008 |
"/ |
|
3009 |
self activityNotification:'adding ' , fileName. |
|
3010 |
||
3011 |
OperatingSystem isUNIXlike ifTrue:[ |
|
3012 |
checkInDir := tempdir constructString:checkoutName. |
|
3013 |
] ifFalse:[ |
|
3014 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
3015 |
checkInDir := tempdir constructString:(checkoutName copyReplaceAll:$/ with:$\). |
|
3016 |
] ifFalse:[ |
|
3017 |
self error:'VMS case not yet implemented'. "/ add code for VMS ... |
|
3018 |
] |
|
3019 |
]. |
|
3020 |
cmd := 'add ' , fileName , ' > ', '"' , cmdOut name, '"'. |
|
3021 |
(self |
|
3022 |
executeCVSCommand:cmd |
|
3023 |
module:moduleDir |
|
3024 |
inDirectory:checkInDir |
|
3025 |
) ifFalse:[ |
|
3026 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
3027 |
||
3028 |
cmdOut remove. |
|
3029 |
('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR. |
|
3030 |
^ false. |
|
3031 |
]. |
|
3032 |
cmdOut remove. |
|
3033 |
||
3034 |
"/ |
|
3035 |
"/ commit |
|
3036 |
"/ |
|
3037 |
self activityNotification:'committing ' , fileName. |
|
3038 |
||
3039 |
OperatingSystem isUNIXlike ifFalse:[ |
|
3040 |
"/ save the log message into another tempFile ... |
|
3041 |
logTmp := Filename newTemporaryIn:checkInDir. |
|
3042 |
s := logTmp writeStream. |
|
3043 |
s nextPutAll:'initial checkin'. |
|
3044 |
s close. |
|
3045 |
||
3046 |
cmd := 'commit -F "', logTmp baseName, '" ', fileName, ' >', '"', cmdOut name, '"'. |
|
3047 |
] ifTrue:[ |
|
3048 |
"/ |
|
3049 |
"/ CVS up to V1.9.14 prints the 'new revision' to stderr, |
|
3050 |
"/ CVS V1.9.16 to stdout. |
|
3051 |
"/ |
|
3052 |
cmd := 'commit -m "initial checkin" ' , fileName , ' > ', '"' , cmdOut name, '"', ' 2>&1'. |
|
3053 |
]. |
|
3054 |
||
3055 |
(self |
|
3056 |
executeCVSCommand:cmd |
|
3057 |
module:moduleDir |
|
3058 |
inDirectory:checkInDir "tempdir name" |
|
3059 |
) ifFalse:[ |
|
3060 |
Verbose == true ifTrue:[ |
|
3061 |
'CVSMGR: failed to execute: ' infoPrint. cmd infoPrintCR. |
|
3062 |
]. |
|
3063 |
cmdOut fileSize > 0 ifTrue:[ |
|
3064 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
3065 |
] ifFalse:[ |
|
3066 |
whatHappened := '<< no message >>' |
|
3067 |
]. |
|
3068 |
self warn:'The following problem was reported by cvs: |
|
3069 |
||
3070 |
' , whatHappened , ' |
|
3071 |
||
3072 |
The class has NOT been checked into the repository.'. |
|
3073 |
||
3074 |
'CVSSourceCodeManager [error]: cannot checkin modified class source' errorPrintCR. |
|
3075 |
cmdOut remove. |
|
3076 |
^ false. |
|
3077 |
]. |
|
3078 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
3079 |
cmdOut remove. |
|
3080 |
||
3081 |
"/ |
|
3082 |
"/ release it towards cvs |
|
3083 |
"/ |
|
3084 |
self releaseAndRemove:tempdir module:moduleDir outputTo:nil. |
|
3085 |
||
3086 |
"/ |
|
3087 |
"/ good - its in the CVS repository; now, we need the updated RCS header |
|
3088 |
"/ |
|
3089 |
(whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[ |
|
3090 |
'CVSSourceCodeManager [warning]: unexpected empty commit command output' errorPrintCR. |
|
3091 |
"/ TODO: scan the file for $Header ... |
|
3092 |
"/ and extract the revision manually |
|
3093 |
||
3094 |
] ifFalse:[ |
|
3095 |
whatHappened := whatHappened asCollectionOfLines asStringCollection. |
|
3096 |
idx := whatHappened indexOfLineStartingWith:'initial revision:'. |
|
3097 |
idx ~~ 0 ifTrue:[ |
|
3098 |
startIdx := 18 |
|
3099 |
] ifFalse:[ |
|
3100 |
idx := whatHappened indexOfLineStartingWith:'new revision:'. |
|
3101 |
idx ~~ 0 ifTrue:[ |
|
3102 |
'CVSSourceCodeManager [warning]: container existed before' errorPrintCR. |
|
3103 |
startIdx := 14. |
|
3104 |
] ifFalse:[ |
|
3105 |
'CVSSourceCodeManager [warning]: unexpected commit command output (no new-revision info)' errorPrintCR. |
|
3106 |
] |
|
3107 |
]. |
|
3108 |
idx ~~ 0 ifTrue:[ |
|
3109 |
l := whatHappened at:idx. |
|
3110 |
endIdx := (l indexOf:$; startingAt:startIdx) - 1. |
|
3111 |
endIdx < 0 ifTrue:[ |
|
3112 |
endIdx := l size |
|
3113 |
]. |
|
3114 |
newRevision := (l copyFrom:startIdx to:endIdx) withoutSpaces. |
|
3115 |
(Number fromString:newRevision onError:nil) isNil ifTrue:[ |
|
3116 |
newRevision := '1.1' |
|
3117 |
] |
|
3118 |
] |
|
3119 |
]. |
|
3120 |
||
3121 |
Transcript showCR:'created new sourceContainer for ' , fileName , '.'. |
|
3122 |
] ensure:[ |
|
3123 |
tempdir recursiveRemove. |
|
3124 |
]. |
|
3125 |
^ true |
|
3126 |
! |
|
3127 |
||
3128 |
createModule:moduleName |
|
3129 |
"create a module directory" |
|
3130 |
||
3131 |
|tempdir moduleDir cmdOut cmd| |
|
3132 |
||
3133 |
"/ |
|
3134 |
"/ first, create a temporary work tree |
|
3135 |
"/ |
|
3136 |
tempdir := self createTempDirectory:nil forModule:moduleName. |
|
3137 |
tempdir isNil ifTrue:[ |
|
3138 |
('CVSSourceCodeManager [error]: no tempDir - cannot create moduleDirectory') errorPrintCR. |
|
3139 |
^ false |
|
3140 |
]. |
|
3141 |
||
3142 |
cmdOut := Filename newTemporary. |
|
3143 |
cmdOut exists ifTrue:[ |
|
3144 |
cmdOut remove. |
|
3145 |
]. |
|
3146 |
||
3147 |
"/ |
|
3148 |
"/ create the module directory |
|
3149 |
"/ |
|
3150 |
moduleDir := tempdir construct:moduleName. |
|
3151 |
moduleDir exists ifFalse:[ |
|
3152 |
'CVSSourceCodeManager [error]: failed to create: ' errorPrint. moduleDir name errorPrintCR. |
|
3153 |
tempdir recursiveRemove. |
|
3154 |
^ false. |
|
3155 |
]. |
|
3156 |
||
3157 |
"/ |
|
3158 |
"/ then import it into CVS |
|
3159 |
"/ |
|
3160 |
||
3161 |
cmd := 'import -m "created from browser" ' , moduleName , ' initialV initialR > ' , cmdOut name. |
|
3162 |
(self |
|
3163 |
executeCVSCommand:cmd |
|
3164 |
module:moduleName |
|
3165 |
inDirectory:tempdir name |
|
3166 |
) ifFalse:[ |
|
3167 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
3168 |
||
3169 |
cmdOut remove. |
|
3170 |
tempdir recursiveRemove. |
|
3171 |
^ false. |
|
3172 |
]. |
|
3173 |
||
3174 |
'CVSSourceCodeManager [info]: created new module: ' infoPrint. moduleName infoPrintCR. |
|
3175 |
tempdir recursiveRemove. |
|
3176 |
cmdOut remove. |
|
3177 |
^ true |
|
3178 |
||
3179 |
"Created: / 9.12.1995 / 19:53:51 / cg" |
|
3180 |
"Modified: / 7.1.1998 / 14:18:57 / stefan" |
|
3181 |
"Modified: / 6.6.1998 / 16:15:34 / cg" |
|
3182 |
! |
|
3183 |
||
3184 |
createModule:moduleDirName package:packageDirName |
|
3185 |
"create a package directory" |
|
3186 |
||
3187 |
|tempdir cmdOut cmd packageDir moduleDir relativePath idx parentPackage| |
|
3188 |
||
3189 |
"/ any parent package required ? |
|
3190 |
idx := packageDirName lastIndexOf:$/. |
|
3191 |
idx ~~ 0 ifTrue:[ |
|
3192 |
parentPackage := packageDirName copyTo:idx-1. |
|
3193 |
(self checkForExistingModule:moduleDirName package:parentPackage) ifFalse:[ |
|
3194 |
(self createModule:moduleDirName package:parentPackage) ifFalse:[ |
|
3195 |
^ false. |
|
3196 |
]. |
|
3197 |
]. |
|
3198 |
]. |
|
3199 |
||
3200 |
(moduleDirName asFilename components includes:'core') ifTrue:[ |
|
3201 |
('CVSSourceCodeManager [error]: cvs does not allow for a module to be named ''core'' - cannot create moduleDirectory') errorPrintCR. |
|
3202 |
^ false |
|
3203 |
]. |
|
3204 |
||
3205 |
"/ |
|
3206 |
"/ first, create a temporary work tree |
|
3207 |
"/ |
|
3208 |
tempdir := self createTempDirectory:packageDirName forModule:moduleDirName. |
|
3209 |
tempdir isNil ifTrue:[ |
|
3210 |
('CVSSourceCodeManager [error]: no tempDir - cannot create moduleDirectory') errorPrintCR. |
|
3211 |
^ false |
|
3212 |
]. |
|
3213 |
||
3214 |
cmdOut := Filename newTemporary. |
|
3215 |
cmdOut exists ifTrue:[ |
|
3216 |
cmdOut remove. |
|
3217 |
]. |
|
3218 |
||
3219 |
moduleDir := tempdir construct:moduleDirName. |
|
3220 |
moduleDir isDirectory ifFalse:[ |
|
3221 |
'CVSSourceCodeManager [error]: command failed: ' errorPrint. cmd errorPrintCR. |
|
3222 |
||
3223 |
tempdir recursiveRemove. |
|
3224 |
^ false. |
|
3225 |
]. |
|
3226 |
||
3227 |
"/ |
|
3228 |
"/ create the package directory there |
|
3229 |
"/ |
|
3230 |
packageDir := moduleDir construct:packageDirName. |
|
3231 |
OperatingSystem errorSignal catch:[ |
|
3232 |
packageDir recursiveMakeDirectory. |
|
3233 |
]. |
|
3234 |
packageDir isDirectory ifFalse:[ |
|
3235 |
tempdir recursiveRemove. |
|
3236 |
('CVSSourceCodeManager [error]: cannot create new directory: ' , packageDir pathName) errorPrintCR. |
|
3237 |
^ false. |
|
3238 |
]. |
|
3239 |
||
3240 |
"/ |
|
3241 |
"/ then import it into CVS |
|
3242 |
"/ |
|
3243 |
||
3244 |
relativePath := moduleDirName asFilename constructString:packageDirName. |
|
3245 |
cmd := 'import -m "created from browser" . initialV initialR > ' , cmdOut name. |
|
3246 |
(self |
|
3247 |
executeCVSCommand:cmd |
|
3248 |
module:moduleDirName |
|
3249 |
inDirectory:tempdir name |
|
3250 |
) ifFalse:[ |
|
3251 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
3252 |
'CVSSourceCodeManager [error]: output from cvs:' errorPrintCR. |
|
3253 |
(cmdOut contentsOfEntireFile) errorPrint. |
|
3254 |
||
3255 |
cmdOut remove. |
|
3256 |
tempdir recursiveRemove. |
|
3257 |
^ false. |
|
3258 |
]. |
|
3259 |
||
3260 |
tempdir recursiveRemove. |
|
3261 |
cmdOut remove. |
|
3262 |
^ true |
|
3263 |
||
3264 |
" |
|
3265 |
self createModule:'stefan' package:'dummy1' |
|
3266 |
" |
|
3267 |
||
3268 |
"Created: / 9.12.1995 / 20:09:33 / cg" |
|
3269 |
"Modified: / 23.7.1999 / 18:40:49 / stefan" |
|
3270 |
"Modified: / 18.1.2000 / 20:14:01 / cg" |
|
3271 |
! |
|
3272 |
||
3273 |
getExistingContainersInModule:aModule package:aPackage |
|
3274 |
"return a list of existing containers. |
|
3275 |
This does not work with remote-CVS" |
|
3276 |
||
3277 |
|cvsRoot containers moduleDir packageDir tempdir cmdOut cmd dirName| |
|
3278 |
||
3279 |
cvsRoot := self getCVSROOTForModule:aModule. |
|
3280 |
cvsRoot isNil ifTrue:[^ #() ]. |
|
3281 |
||
3282 |
dirName := aModule , '/' , aPackage. |
|
3283 |
||
3284 |
self activityNotification:'getting list of containers in ' , dirName , ' ...'. |
|
3285 |
||
3286 |
(RemoteCVS |
|
3287 |
or:[cvsRoot asFilename exists not]) ifTrue:[ |
|
3288 |
"/ remote CVS |
|
3289 |
"/ filter the output of the history command |
|
3290 |
"/ (sigh - there ought to be some cvs-command for that) |
|
3291 |
"/ |
|
3292 |
||
3293 |
tempdir := self createTempDirectory:nil forModule:nil. |
|
3294 |
tempdir isNil ifTrue:[ |
|
3295 |
('CVSSourceCodeManager [error]: no tempDir - cannot checkout') errorPrintCR. |
|
3296 |
^ #() |
|
3297 |
]. |
|
3298 |
||
1393
28d04a5111c6
cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents:
1390
diff
changeset
|
3299 |
cmd := 'checkout ', dirName. |
1362 | 3300 |
OperatingSystem isUNIXlike ifTrue:[ |
3301 |
"/ can redirect output |
|
3302 |
cmdOut := Filename newTemporary. |
|
3303 |
cmdOut exists ifTrue:[ |
|
3304 |
cmdOut remove. |
|
3305 |
]. |
|
3306 |
cmd := cmd , ' > ' , cmdOut name. |
|
3307 |
]. |
|
3308 |
||
3309 |
(self |
|
3310 |
executeCVSCommand:cmd |
|
3311 |
module:aModule |
|
3312 |
inDirectory:tempdir name |
|
3313 |
) ifFalse:[ |
|
3314 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
3315 |
cmdOut notNil ifTrue:[cmdOut remove]. |
|
3316 |
tempdir recursiveRemove. |
|
3317 |
^ #() |
|
3318 |
]. |
|
3319 |
||
3320 |
cmdOut notNil ifTrue:[cmdOut remove]. |
|
3321 |
||
3322 |
packageDir := (tempdir construct:dirName). |
|
3323 |
(packageDir isDirectory) ifFalse:[ |
|
3324 |
'CVSSourceCodeManager [error]: checkout failed (no dir)' errorPrintCR. |
|
3325 |
tempdir recursiveRemove. |
|
3326 |
^ #() |
|
3327 |
]. |
|
3328 |
||
3329 |
"/ |
|
3330 |
"/ enumerate the checkedOut directory, looking for plain files |
|
3331 |
"/ |
|
3332 |
containers := OrderedCollection new. |
|
3333 |
packageDir directoryContents do:[:aFilenameString | |
|
3334 |
|fn| |
|
3335 |
||
3336 |
(packageDir construct:aFilenameString) isDirectory ifFalse:[ |
|
3337 |
containers add:aFilenameString |
|
3338 |
] |
|
3339 |
]. |
|
3340 |
tempdir recursiveRemove. |
|
3341 |
] ifFalse:[ |
|
3342 |
(cvsRoot := cvsRoot asFilename) exists ifFalse:[ |
|
3343 |
^ #() |
|
3344 |
]. |
|
3345 |
((moduleDir := cvsRoot construct:aModule) exists |
|
3346 |
and:[moduleDir isDirectory]) ifFalse:[ |
|
3347 |
self warn:'No such module'. |
|
3348 |
^ #() |
|
3349 |
]. |
|
3350 |
((packageDir := moduleDir construct:aPackage) exists |
|
3351 |
and:[packageDir isDirectory]) ifFalse:[ |
|
3352 |
self warn:'No such package'. |
|
3353 |
^ #() |
|
3354 |
]. |
|
3355 |
||
3356 |
"/ |
|
3357 |
"/ enumerate the package directory, looking for container files |
|
3358 |
"/ strip off the ,v ending. |
|
3359 |
"/ |
|
3360 |
containers := OrderedCollection new. |
|
3361 |
packageDir directoryContents do:[:aFilenameString | |
|
3362 |
|fn| |
|
3363 |
||
3364 |
(aFilenameString endsWith:',v') ifTrue:[ |
|
3365 |
containers add:(aFilenameString copyWithoutLast:2) |
|
3366 |
] |
|
3367 |
]. |
|
3368 |
]. |
|
3369 |
^ containers sort |
|
3370 |
||
3371 |
" |
|
3372 |
CVSSourceCodeManager getExistingContainersInModule:'stx' package:'libhtml' |
|
3373 |
CVSSourceCodeManager getExistingContainersInModule:'cg' package:'java' |
|
3374 |
CVSSourceCodeManager getExistingContainersInModule:'sel' package:'bmti' |
|
3375 |
" |
|
3376 |
||
3377 |
"Created: / 20.5.1998 / 19:48:59 / cg" |
|
3378 |
"Modified: / 20.5.1998 / 22:08:29 / cg" |
|
3379 |
! |
|
3380 |
||
3381 |
getExistingModules |
|
3382 |
"return a list of existing modules. |
|
3383 |
This does not work with remote-CVS" |
|
3384 |
||
3385 |
|cvsRoot modules inStream list| |
|
3386 |
||
3387 |
cvsRoot := self getCVSROOTForModule:nil. |
|
3388 |
cvsRoot isNil ifTrue:[^ #() ]. |
|
3389 |
||
3390 |
self activityNotification:'getting list of modules...'. |
|
3391 |
||
3392 |
(RemoteCVS |
|
3393 |
or:[cvsRoot asFilename exists not]) ifTrue:[ |
|
3394 |
"/ remote CVS |
|
3395 |
"/ filter the output of the history command |
|
3396 |
"/ (sigh - there ought to be some cvs-command for that) |
|
3397 |
"/ |
|
3398 |
inStream := PipeStream readingFrom:'cvs -d ' , cvsRoot , ' history -x A'. |
|
3399 |
inStream isNil ifTrue:[ |
|
3400 |
self warn:'This operation is not possible with this remoteCVS server'. |
|
3401 |
^ #(). |
|
3402 |
]. |
|
3403 |
list := inStream contents asStringCollection. |
|
3404 |
inStream close. |
|
3405 |
||
3406 |
modules := Set new. |
|
3407 |
list do:[:line | |
|
3408 |
|idx items entry| |
|
3409 |
||
3410 |
items := line asCollectionOfWords. |
|
3411 |
"/ #( 'A' '10/29' '17:47' '+0000' 'cg' '1.1' '.cvsignore' 'stx' '==' '~/work/stx' ) |
|
3412 |
"/ fetch the word before '==' |
|
3413 |
||
3414 |
idx := items indexOf:'=='. |
|
3415 |
idx > 1 ifTrue:[ |
|
3416 |
entry := items at:idx-1. |
|
3417 |
||
3418 |
"/ extract the first directory component ... |
|
3419 |
idx := entry indexOf:$/. |
|
3420 |
idx ~~ 0 ifTrue:[ |
|
3421 |
entry := entry copyTo:idx-1 |
|
3422 |
]. |
|
3423 |
modules add:entry. |
|
3424 |
] |
|
3425 |
]. |
|
3426 |
modules := modules asArray |
|
3427 |
] ifFalse:[ |
|
3428 |
"/ local CVS |
|
3429 |
"/ |
|
3430 |
"/ enumerate the root directory, looking for subdirs |
|
3431 |
"/ which contain a CVS subdir. |
|
3432 |
"/ |
|
3433 |
(cvsRoot := cvsRoot asFilename) exists ifFalse:[ |
|
3434 |
^ #() |
|
3435 |
]. |
|
3436 |
||
3437 |
modules := OrderedCollection new. |
|
3438 |
cvsRoot directoryContents do:[:aFilenameString | |
|
3439 |
|fn| |
|
3440 |
||
3441 |
(aFilenameString endsWith:',v') ifFalse:[ |
|
3442 |
(#('CVS' 'CVSROOT' 'Attic') includes:aFilenameString) ifFalse:[ |
|
3443 |
(fn := (cvsRoot construct:aFilenameString)) isDirectory ifTrue:[ |
|
3444 |
modules add:aFilenameString |
|
3445 |
] |
|
3446 |
] |
|
3447 |
] |
|
3448 |
]. |
|
3449 |
]. |
|
3450 |
||
3451 |
^ modules sort |
|
3452 |
||
3453 |
" |
|
3454 |
CVSSourceCodeManager getExistingModules |
|
3455 |
" |
|
3456 |
||
3457 |
"Created: / 20.5.1998 / 19:28:43 / cg" |
|
3458 |
"Modified: / 20.5.1998 / 22:07:07 / cg" |
|
3459 |
! |
|
3460 |
||
3461 |
getExistingPackagesInModule:aModule |
|
3462 |
"return a list of existing packages. |
|
3463 |
This does not work with remote-CVS" |
|
3464 |
||
3465 |
|cvsRoot packages moduleDir inStream list| |
|
3466 |
||
3467 |
cvsRoot := self getCVSROOTForModule:aModule. |
|
3468 |
||
3469 |
self activityNotification:'getting list of packages in ' , aModule , ' ...'. |
|
3470 |
||
3471 |
(RemoteCVS |
|
3472 |
or:[cvsRoot asFilename exists not]) ifTrue:[ |
|
3473 |
"/ remote CVS |
|
3474 |
"/ filter the output of the history command |
|
3475 |
"/ (sigh - there ought to be some cvs-command for that) |
|
3476 |
"/ |
|
3477 |
inStream := PipeStream readingFrom:'cvs -d ' , cvsRoot , ' history -x A'. |
|
3478 |
inStream isNil ifTrue:[ |
|
3479 |
self warn:'This operation is not possible with this remoteCVS server'. |
|
3480 |
^ #(). |
|
3481 |
]. |
|
3482 |
list := inStream contents asStringCollection. |
|
3483 |
inStream close. |
|
3484 |
||
3485 |
packages := Set new. |
|
3486 |
list do:[:line | |
|
3487 |
|items idx entry| |
|
3488 |
||
3489 |
items := line asCollectionOfWords. |
|
3490 |
"/ #( 'A' '10/29' '17:47' '+0000' 'cg' '1.1' '.cvsignore' 'stx' '==' '~/work/stx' ) |
|
3491 |
"/ fetch the word before '==' |
|
3492 |
||
3493 |
idx := items indexOf:'=='. |
|
3494 |
idx > 1 ifTrue:[ |
|
3495 |
entry := items at:idx-1. |
|
3496 |
||
3497 |
"/ extract the first directory component ... |
|
3498 |
(entry startsWith:aModule) ifTrue:[ |
|
3499 |
idx := entry indexOf:$/. |
|
3500 |
idx ~~ 0 ifTrue:[ |
|
3501 |
(entry copyTo:idx-1) = aModule ifTrue:[ |
|
3502 |
packages add:(entry copyFrom:idx+1). |
|
3503 |
] |
|
3504 |
]. |
|
3505 |
] |
|
3506 |
] |
|
3507 |
]. |
|
3508 |
packages := packages asArray |
|
3509 |
] ifFalse:[ |
|
3510 |
"/ local CVS |
|
3511 |
"/ |
|
3512 |
"/ enumerate the module directory, looking for subdirs |
|
3513 |
"/ which contain a CVS subdir. |
|
3514 |
"/ |
|
3515 |
||
3516 |
(cvsRoot := cvsRoot asFilename) exists ifFalse:[ |
|
3517 |
^ #() |
|
3518 |
]. |
|
3519 |
(moduleDir := cvsRoot construct:aModule) isDirectory ifFalse:[ |
|
3520 |
self warn:'No such module'. |
|
3521 |
^ #() |
|
3522 |
]. |
|
3523 |
||
3524 |
packages := OrderedCollection new. |
|
3525 |
moduleDir directoryContents do:[:aFilenameString | |
|
3526 |
|fn| |
|
3527 |
||
3528 |
(aFilenameString endsWith:',v') ifFalse:[ |
|
3529 |
(#('CVS' 'CVSROOT' 'Attic') includes:aFilenameString) ifFalse:[ |
|
3530 |
(fn := (moduleDir construct:aFilenameString)) isDirectory ifTrue:[ |
|
3531 |
packages add:aFilenameString |
|
3532 |
] |
|
3533 |
] |
|
3534 |
] |
|
3535 |
]. |
|
3536 |
]. |
|
3537 |
^ packages sort |
|
3538 |
||
3539 |
" |
|
3540 |
CVSSourceCodeManager getExistingPackagesInModule:'stx' |
|
3541 |
CVSSourceCodeManager getExistingPackagesInModule:'cg' |
|
3542 |
CVSSourceCodeManager getExistingPackagesInModule:'sel' |
|
3543 |
" |
|
3544 |
||
3545 |
"Created: / 20.5.1998 / 19:28:43 / cg" |
|
3546 |
"Modified: / 20.5.1998 / 22:07:13 / cg" |
|
3547 |
! |
|
3548 |
||
3549 |
initialRevisionStringFor:aClass inModule:moduleDir package:packageDir container:fileName |
|
3550 |
"return a string usable as initial revision string" |
|
3551 |
||
3552 |
|cvsRoot| |
|
3553 |
||
3554 |
cvsRoot := self getCVSROOTForModule:moduleDir. |
|
3555 |
cvsRoot := self repositoryTopDirectory:cvsRoot. |
|
3556 |
^ self |
|
3557 |
initialRCSRevisionStringFor:aClass |
|
3558 |
in:(cvsRoot , '/' , moduleDir , '/' , packageDir) |
|
3559 |
container:fileName |
|
3560 |
||
3561 |
"Modified: / 19.9.1997 / 06:34:10 / cg" |
|
3562 |
"Modified: / 16.1.1998 / 17:34:13 / stefan" |
|
3563 |
! |
|
3564 |
||
3565 |
newestRevisionInFile:classFileName directory:packageDir module:moduleDir |
|
3566 |
"return the newest revision found in a container. |
|
3567 |
Return nil on failure. |
|
3568 |
Uses 'cvs status', which is much faster than 'cvs log'" |
|
3569 |
||
3570 |
|info| |
|
3571 |
||
3572 |
info := self |
|
3573 |
statusOf:nil |
|
3574 |
fileName:classFileName |
|
3575 |
directory:packageDir |
|
3576 |
module:moduleDir. |
|
3577 |
||
3578 |
info isNil ifTrue:[^ nil]. |
|
3579 |
^ info at:#newestRevision ifAbsent:nil |
|
3580 |
||
3581 |
" |
|
3582 |
SourceCodeManager newestRevisionInFile:'Array.st' directory:'libbasic' module:'stx' |
|
3583 |
" |
|
3584 |
! |
|
3585 |
||
3586 |
readRevisionLogEntryFromStream:inStream |
|
3587 |
"read and parse a single revision info-entry from the cvs log output. |
|
3588 |
Return nil on end. |
|
3589 |
||
3590 |
The returned information is a structure (IdentityDictionary) |
|
3591 |
filled with: |
|
3592 |
#revision -> the revision string |
|
3593 |
#author -> who checked that revision into the repository |
|
3594 |
#date -> when was it checked in |
|
3595 |
#state -> the RCS state |
|
3596 |
#numberOfChangedLines -> the number of changed line w.r.t the previous |
|
3597 |
#logMessage -> the checkIn log message |
|
3598 |
" |
|
3599 |
||
3600 |
|revLine1 revLine2 record s line atEnd| |
|
3601 |
||
3602 |
atEnd := false. |
|
3603 |
||
3604 |
revLine1 := inStream nextLine. |
|
3605 |
[revLine1 notNil and:[(revLine1 startsWith:'revision ') not]] |
|
3606 |
whileTrue:[inStream atEnd ifTrue:[ |
|
3607 |
revLine1 := nil |
|
3608 |
] ifFalse:[ |
|
3609 |
revLine1 := inStream nextLine. |
|
3610 |
] |
|
3611 |
]. |
|
3612 |
revLine2 := inStream nextLine. |
|
3613 |
(revLine1 notNil and:[revLine2 notNil]) ifTrue:[ |
|
3614 |
record := IdentityDictionary new. |
|
3615 |
record at:#revision put:(revLine1 asCollectionOfWords at:2). |
|
3616 |
"/ decompose date/author/state etc. |
|
3617 |
(revLine2 asCollectionOfSubstringsSeparatedBy:$;) do:[:info | |
|
3618 |
|subEntry| |
|
3619 |
subEntry := info withoutSeparators. |
|
3620 |
#('date:' #date |
|
3621 |
'author:' #author |
|
3622 |
'state:' #state |
|
3623 |
'lines:' #numberOfChangedLines |
|
3624 |
) pairWiseDo:[:word :key | |
|
3625 |
s := subEntry restAfter:word withoutSeparators:true. |
|
3626 |
s notNil ifTrue:[record at:key put:s.]. |
|
3627 |
]. |
|
3628 |
]. |
|
3629 |
||
3630 |
"first revision does not hav a 'lines:' entry" |
|
3631 |
(record includesKey:#numberOfChangedLines) ifFalse:[ |
|
3632 |
record at:#numberOfChangedLines put:'' |
|
3633 |
]. |
|
3634 |
||
3635 |
s := nil. |
|
3636 |
line := inStream nextLine. |
|
3637 |
[atEnd or:[line isNil or:[line startsWith:'--------']]] whileFalse:[ |
|
3638 |
(line startsWith:'==========') ifTrue:[ |
|
3639 |
atEnd := true. |
|
3640 |
] ifFalse:[ |
|
3641 |
(line withoutSpaces = '.') ifTrue:[ |
|
3642 |
line := '*** empty log message ***' |
|
3643 |
]. |
|
3644 |
s isNil ifTrue:[ |
|
3645 |
s := line |
|
3646 |
] ifFalse:[ |
|
3647 |
s := s , Character cr asString , line. |
|
3648 |
]. |
|
3649 |
line := inStream nextLine. |
|
3650 |
] |
|
3651 |
]. |
|
3652 |
record at:#logMessage put:s. |
|
3653 |
]. |
|
3654 |
^record. |
|
3655 |
||
3656 |
! |
|
3657 |
||
3658 |
removeContainerFor:aClass inModule:moduleDir package:packageDir container:fileName |
|
3659 |
"remove a container" |
|
3660 |
||
3661 |
(self removeContainerInModule:moduleDir package:packageDir container:fileName) ifFalse:[ |
|
3662 |
^ false |
|
3663 |
]. |
|
3664 |
||
3665 |
"/ |
|
3666 |
"/ patch the classes revisionInfo (but keep binaryRevision unchanged) |
|
3667 |
"/ this makes everyone here believe, that the incore version of the class is based upon |
|
3668 |
"/ some container-less class. |
|
3669 |
"/ (however, the binaryRevision must remain as it is - we will need it to fetch the sourceCode |
|
3670 |
"/ correctly for all unchanged methodss) |
|
3671 |
"/ |
|
3672 |
||
3673 |
aClass updateVersionMethodFor:'no longer in repository'. |
|
3674 |
Class addChangeRecordForClassContainerRemove:aClass. |
|
3675 |
^ true |
|
3676 |
! |
|
3677 |
||
3678 |
removeContainerInModule:moduleDir package:packageDir container:fileName |
|
3679 |
"remove a container" |
|
3680 |
||
3681 |
|fullName tempdir checkoutName cmdOut cmd tempFile whatHappened| |
|
3682 |
||
3683 |
fullName := moduleDir , '/' , packageDir , '/' , fileName. |
|
3684 |
checkoutName := moduleDir , '/' , packageDir. |
|
3685 |
||
3686 |
(tempdir := self createLocalDirectory:packageDir inModule:moduleDir with:fileName) isNil ifTrue:[ |
|
3687 |
'CVSSourceCodeManager [error]: failed to checkout: ' errorPrint. checkoutName errorPrintCR. |
|
3688 |
tempdir recursiveRemove. |
|
3689 |
('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR. |
|
3690 |
^ false. |
|
3691 |
]. |
|
3692 |
||
3693 |
"/ |
|
3694 |
"/ and remove it to the repository |
|
3695 |
"/ |
|
3696 |
self activityNotification:'removing ' , fileName. |
|
3697 |
||
3698 |
"/ |
|
3699 |
"/ check presence of source there |
|
3700 |
"/ |
|
3701 |
tempFile := (tempdir construct:checkoutName) construct:fileName. |
|
3702 |
tempFile exists ifFalse:[ |
|
3703 |
'CVSSourceCodeManager [error]: temporary fileout failed' errorPrintCR. |
|
3704 |
tempdir recursiveRemove. |
|
3705 |
^ false |
|
3706 |
]. |
|
3707 |
||
3708 |
tempFile exists ifTrue:[ |
|
3709 |
tempFile remove. |
|
3710 |
]. |
|
3711 |
||
3712 |
cmdOut := Filename newTemporary. |
|
3713 |
cmdOut exists ifTrue:[ |
|
3714 |
cmdOut remove. |
|
3715 |
]. |
|
3716 |
||
3717 |
cmd := 'remove ' , fileName , ' > ' , cmdOut name. |
|
3718 |
(self |
|
3719 |
executeCVSCommand:cmd |
|
3720 |
module:moduleDir |
|
3721 |
inDirectory:(tempdir constructString:checkoutName) |
|
3722 |
) ifFalse:[ |
|
3723 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
3724 |
||
3725 |
cmdOut remove. |
|
3726 |
tempdir recursiveRemove. |
|
3727 |
('CVSSourceCodeManager [error]: cannot remove ' , checkoutName) errorPrintCR. |
|
3728 |
^ false. |
|
3729 |
]. |
|
3730 |
cmdOut remove. |
|
3731 |
||
3732 |
"/ |
|
3733 |
"/ commit |
|
3734 |
"/ |
|
3735 |
self activityNotification:'committing removal of ' , fileName. |
|
3736 |
||
3737 |
cmd := 'commit -m "removed container" -l ' , fileName , ' 2> ' , cmdOut name. |
|
3738 |
(self |
|
3739 |
executeCVSCommand:cmd |
|
3740 |
module:moduleDir |
|
3741 |
inDirectory:(tempdir constructString:checkoutName) |
|
3742 |
) ifFalse:[ |
|
3743 |
'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR. |
|
3744 |
||
3745 |
cmdOut fileSize > 0 ifTrue:[ |
|
3746 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
3747 |
] ifFalse:[ |
|
3748 |
whatHappened := '<< no message >>' |
|
3749 |
]. |
|
3750 |
self warn:'The following problem was reported by cvs: |
|
3751 |
||
3752 |
' , whatHappened , ' |
|
3753 |
||
3754 |
The container has NOT been removed into the repository.'. |
|
3755 |
||
3756 |
'CVSSourceCodeManager [error]: cannot remove container' errorPrintCR. |
|
3757 |
cmdOut remove. |
|
3758 |
tempdir recursiveRemove. |
|
3759 |
^ false. |
|
3760 |
]. |
|
3761 |
cmdOut remove. |
|
3762 |
||
3763 |
"/ |
|
3764 |
"/ release the temporary tree towards cvs |
|
3765 |
"/ |
|
3766 |
self releaseAndRemove:tempdir module:moduleDir outputTo:nil. |
|
3767 |
||
3768 |
tempdir recursiveRemove. |
|
3769 |
^ true |
|
3770 |
||
3771 |
" |
|
3772 |
CVSSourceCodeManager removeContainerInModule:'stx' package:'private' container:'WorldPO.st' |
|
3773 |
" |
|
3774 |
||
3775 |
"Modified: / 26.2.1998 / 17:33:57 / stefan" |
|
3776 |
"Modified: / 18.1.2000 / 21:02:30 / cg" |
|
3777 |
! |
|
3778 |
||
3779 |
reportHistoryLogSince:timeGoal filterSTSources:filter filterUser:userFilter filterRepository:filterRep filterModules:filterModules inTo:aBlock |
|
3780 |
"process a full historyLog, evaluate aBlock for each entry, passing |
|
3781 |
the logs info in a dictionary. |
|
3782 |
This walks over all possible repositories. |
|
3783 |
filterRep may be a collection of repository names |
|
3784 |
(i.e. 'stc', 'exept', 'phx' etc.) to only report changes made to one |
|
3785 |
of those repositories. |
|
3786 |
filterUser, if non-nil, will filter only changes made by that user." |
|
3787 |
||
3788 |
|inStream line words recordType fileName user date time rev pkgDir module idx |
|
3789 |
clsName cls clsRev roots info tempDir endReached| |
|
3790 |
||
3791 |
CVSRoot isNil ifTrue:[ |
|
3792 |
'CVSSourceCodeManager [info]: CVSROOT not set' infoPrintCR. |
|
3793 |
^ nil |
|
3794 |
]. |
|
3795 |
||
3796 |
CVSModuleRoots notNil ifTrue:[ |
|
3797 |
roots := Set withAll:(CVSModuleRoots values) |
|
3798 |
] ifFalse:[ |
|
3799 |
roots := Set new. |
|
3800 |
]. |
|
3801 |
roots add:CVSRoot. |
|
3802 |
||
3803 |
"/ must do it in a tempDir, to avoid cvs validating the -D arg |
|
3804 |
"/ against any info found in CVS/Root |
|
3805 |
||
3806 |
tempDir := self createTempDirectory:nil forModule:nil. |
|
3807 |
tempDir isNil ifTrue:[ |
|
3808 |
('CVSSourceCodeManager [error]: no tempDir - cannot extract log') errorPrintCR. |
|
3809 |
^ nil. |
|
3810 |
]. |
|
3811 |
||
3812 |
roots do:[:aCVSRoot | |
|
3813 |
|root host cmd| |
|
3814 |
||
3815 |
cmd := 'cvs -d ' , aCVSRoot. |
|
3816 |
||
3817 |
"/ workaround a CVS bug ... |
|
3818 |
"/ cvs crashes with: |
|
3819 |
"/ cvs -d exept:/files/CVS history -x WARM -a -D "yesterday" |
|
3820 |
"/ |
|
3821 |
"/ but works ok, when doing: |
|
3822 |
"/ rsh exept cvs -d /files/CVS history -x WARM -a -D "yesterday" |
|
3823 |
"/ |
|
3824 |
(aCVSRoot startsWith:':') ifFalse:[ |
|
3825 |
OperatingSystem isUNIXlike ifTrue:[ |
|
3826 |
host := aCVSRoot copyTo:(aCVSRoot indexOf:$:)-1. |
|
3827 |
(host size > 0 and:[(host includes:Character space) not]) ifTrue:[ |
|
3828 |
root := aCVSRoot copyFrom:(aCVSRoot indexOf:$:)+1. |
|
3829 |
cmd := 'rsh ' , host , ' cvs -d ' , root |
|
3830 |
] |
|
3831 |
] |
|
3832 |
]. |
|
3833 |
||
3834 |
cmd := cmd , ' history -x WARM -a'. |
|
3835 |
(timeGoal notNil and:[timeGoal notEmpty]) ifTrue:[ |
|
3836 |
cmd := cmd , ' -D "' , timeGoal , '"'. |
|
3837 |
]. |
|
3838 |
filterRep notNil ifTrue:[ |
|
3839 |
filterRep do:[:aRepository | |
|
3840 |
cmd := cmd , ' -p "' , aRepository , '"'. |
|
3841 |
]. |
|
3842 |
]. |
|
3843 |
userFilter notNil ifTrue:[ |
|
3844 |
userFilter isString ifTrue:[ |
|
3845 |
cmd := cmd , ' -u "' , userFilter , '"'. |
|
3846 |
] ifFalse:[ |
|
3847 |
userFilter do:[:user | |
|
3848 |
cmd := cmd , ' -u "' , user , '"'. |
|
3849 |
]. |
|
3850 |
]. |
|
3851 |
]. |
|
3852 |
||
3853 |
"/ either I dont understand CVS, or it does not work correctly... |
|
3854 |
"/ in any case, the -m option does NOT filter modules. (sigh) |
|
3855 |
"/ |
|
3856 |
"/ filterModules notNil ifTrue:[ |
|
3857 |
"/ filterModules do:[:aModule | |
|
3858 |
"/ cmd := cmd , ' -m "' , aModule , '"'. |
|
3859 |
"/ ]. |
|
3860 |
"/ ]. |
|
3861 |
||
3862 |
Transcript showCR:cmd. |
|
3863 |
||
3864 |
inStream := PipeStream readingFrom:cmd inDirectory:tempDir. |
|
3865 |
inStream isNil ifTrue:[ |
|
3866 |
('CVSSourceCodeManager [error]: cannot open pipe to ''cvs history''') errorPrintCR. |
|
3867 |
] ifFalse:[ |
|
3868 |
||
3869 |
inStream class streamErrorSignal handle:[:ex | |
|
3870 |
('CVSSourceCodeManager [error]: pipe read error (''cvs history'')') errorPrintCR. |
|
3871 |
ex return. |
|
3872 |
] do:[ |
|
3873 |
"/ |
|
3874 |
"/ read the commands pipe output and reformat the lines |
|
3875 |
"/ |
|
3876 |
endReached := false. |
|
3877 |
[endReached] whileFalse:[ |
|
3878 |
inStream readWait. |
|
3879 |
line := inStream nextLine. |
|
3880 |
(endReached := line isNil) ifFalse:[ |
|
3881 |
||
3882 |
"/ cvs history line is of the following format: |
|
3883 |
"/ [Ma] date time +xxx user rev name module/package .... |
|
3884 |
words := line asCollectionOfWords. |
|
3885 |
words size >= 8 ifFalse:[ |
|
3886 |
"/ something like 'No records selected' ... |
|
3887 |
||
3888 |
] ifTrue:[ |
|
3889 |
recordType := words at:1. |
|
3890 |
fileName := words at:7. |
|
3891 |
user := words at:5. |
|
3892 |
||
3893 |
(filter not |
|
3894 |
or:[fileName endsWith:'.st']) ifTrue:[ |
|
3895 |
(userFilter isNil |
|
3896 |
or:[userFilter = user]) ifTrue:[ |
|
3897 |
||
3898 |
date := words at:2. |
|
3899 |
time := words at:3. |
|
3900 |
rev := words at:6. |
|
3901 |
pkgDir := words at:8. |
|
3902 |
||
3903 |
module := pkgDir copy. |
|
3904 |
(module startsWith:'./') ifTrue:[ |
|
3905 |
module := module copyFrom:3. |
|
3906 |
]. |
|
3907 |
idx := module indexOf:$/. |
|
3908 |
idx ~~ 0 ifTrue:[ |
|
3909 |
module at:idx put:$: |
|
3910 |
]. |
|
3911 |
||
3912 |
(filterModules isNil |
|
3913 |
or:[filterModules includes:module]) ifTrue:[ |
|
3914 |
||
3915 |
recordType = 'M' ifTrue:[ |
|
3916 |
recordType := ' ' |
|
3917 |
] ifFalse:[ |
|
3918 |
recordType = 'A' ifTrue:[ |
|
3919 |
recordType := '+' |
|
3920 |
] ifFalse:[ |
|
3921 |
(recordType = 'R' or:[recordType = 'W']) ifTrue:[ |
|
3922 |
recordType := '-' |
|
3923 |
] |
|
3924 |
] |
|
3925 |
]. |
|
3926 |
||
3927 |
info := Dictionary new. |
|
3928 |
info at:#cvsRecordType put:recordType. |
|
3929 |
info at:#date put:date. |
|
3930 |
info at:#time put:time. |
|
3931 |
info at:#user put:user. |
|
3932 |
info at:#fileName put:fileName. |
|
3933 |
info at:#revision put:rev. |
|
3934 |
info at:#directory put:pkgDir. |
|
3935 |
info at:#className put:(Smalltalk classNameForFile:fileName). |
|
3936 |
||
3937 |
"/ |
|
3938 |
"/ for your convenience: |
|
3939 |
"/ check what the actual version is in the image |
|
3940 |
"/ |
|
3941 |
clsName := Smalltalk classNameForFile:fileName. |
|
3942 |
clsName notNil ifTrue:[ |
|
3943 |
cls := Smalltalk classNamed:clsName. |
|
3944 |
(cls notNil and:[(clsRev := cls revision) notNil]) ifTrue:[ |
|
3945 |
info at:#classesRevision put:clsRev. |
|
3946 |
]. |
|
3947 |
]. |
|
3948 |
aBlock value:info |
|
3949 |
] |
|
3950 |
] |
|
3951 |
] |
|
3952 |
] |
|
3953 |
] |
|
3954 |
]. |
|
3955 |
]. |
|
3956 |
inStream close. |
|
3957 |
] |
|
3958 |
]. |
|
3959 |
||
3960 |
tempDir recursiveRemove. |
|
3961 |
||
3962 |
"Created: / 17.1.2001 / 13:11:20 / cg" |
|
3963 |
"Modified: / 17.1.2001 / 13:41:22 / cg" |
|
3964 |
! |
|
3965 |
||
3966 |
reportHistoryLogSince:timeGoal filterSTSources:filter filterUser:userFilter filterRepository:filterRep inTo:aBlock |
|
3967 |
"process a full historyLog, evaluate aBlock for each entry, passing |
|
3968 |
the logs info in a dictionary. |
|
3969 |
This walks over all possible repositories. |
|
3970 |
filterRep may be a collection of repository names |
|
3971 |
(i.e. 'stc', 'exept', 'phx' etc.) to only report changes made to one |
|
3972 |
of those repositories. |
|
3973 |
filterUser, if non-nil, will filter only changes made by that user." |
|
3974 |
||
3975 |
^self |
|
3976 |
reportHistoryLogSince:timeGoal |
|
3977 |
filterSTSources:filter |
|
3978 |
filterUser:userFilter |
|
3979 |
filterRepository:filterRep |
|
3980 |
filterModules:nil |
|
3981 |
inTo:aBlock |
|
3982 |
||
3983 |
"Modified: / 17.1.2001 / 13:12:15 / cg" |
|
3984 |
! |
|
3985 |
||
3986 |
revisionInfoFromString:aString |
|
3987 |
"{ Pragma: +optSpace }" |
|
3988 |
||
3989 |
"return a dictionary filled with revision info. |
|
3990 |
This extracts the relevant info from aString." |
|
3991 |
||
3992 |
^ self revisionInfoFromRCSString:aString |
|
3993 |
||
3994 |
" |
|
3995 |
self revisionInfoFromString:(Array version) |
|
3996 |
" |
|
3997 |
||
3998 |
"Modified: 29.1.1997 / 19:00:35 / cg" |
|
3999 |
! |
|
4000 |
||
4001 |
revisionLogOf:clsOrNil fromRevision:rev1 toRevision:rev2 fileName:classFileName directory:packageDir module:moduleDir |
|
4002 |
"return info about the repository container and |
|
4003 |
(part of) the revisionlog as a collection of revision entries. |
|
4004 |
Return nil on failure. |
|
4005 |
||
4006 |
The returned information is a structure (IdentityDictionary) |
|
4007 |
filled with: |
|
4008 |
#container -> the RCS/CVS container file name |
|
4009 |
#cvsRoot -> the CVS root (repository) |
|
4010 |
#filename -> the actual source file name |
|
4011 |
#newestRevision -> the revisionString of the newest revision |
|
4012 |
#numberOfRevisions -> the number of revisions in the container (nil for all) |
|
4013 |
#revisions -> collection of per-revision info (see below) |
|
4014 |
||
4015 |
rev1 / rev2 specify from which revisions a logEntry is wanted: |
|
4016 |
-If rev1 is nil, the first revision is the initial revision |
|
4017 |
otherwise, the log starts with that revision. |
|
4018 |
-If rev2 is nil, the last revision is the newest revision |
|
4019 |
otherwise, the log ends with that revision. |
|
4020 |
||
4021 |
-If both are nil, all logEntries are extracted. |
|
4022 |
-If both are 0 (not nil), no logEntries are extracted (i.e. only the header). |
|
4023 |
||
4024 |
per revision info consists of one record per revision: |
|
4025 |
||
4026 |
#revision -> the revision string |
|
4027 |
#author -> who checked that revision into the repository |
|
4028 |
#date -> when was it checked in |
|
4029 |
#state -> the RCS state |
|
4030 |
#numberOfChangedLines -> the number of changed line w.r.t the previous |
|
4031 |
||
4032 |
revisions are ordered newest first |
|
4033 |
(i.e. the last entry is for the initial revision; the first for the most recent one) |
|
4034 |
" |
|
4035 |
||
4036 |
|tempDir fullName modulePath inStream inHeaderInfo atEnd line revArg idx |
|
4037 |
info record revisionRecords s headerOnly msg | |
|
4038 |
||
4039 |
modulePath := moduleDir , '/' , packageDir. |
|
4040 |
fullName := modulePath , '/' , classFileName. |
|
4041 |
tempDir := self createTempDirectory:nil forModule:nil. |
|
4042 |
tempDir isNil ifTrue:[ |
|
4043 |
('CVSSourceCodeManager [error]: no tempDir - cannot extract log') errorPrintCR. |
|
4044 |
^ nil. |
|
4045 |
]. |
|
4046 |
||
4047 |
[ |
|
4048 |
self createEntryFor:fullName |
|
4049 |
module:moduleDir |
|
4050 |
in:(tempDir construct:modulePath) |
|
4051 |
revision:'1.1' |
|
4052 |
date:'dummy' |
|
4053 |
special:'' |
|
4054 |
overwrite:false. |
|
4055 |
||
4056 |
revArg := ''. |
|
4057 |
headerOnly := false. |
|
4058 |
(rev1 notNil or:[rev2 notNil]) ifTrue:[ |
|
4059 |
(rev1 == 0 and:[rev2 == 0]) ifTrue:[ |
|
4060 |
revArg := '-h'. |
|
4061 |
headerOnly := true. |
|
4062 |
] ifFalse:[ |
|
4063 |
revArg := '-r'. |
|
4064 |
rev1 notNil ifTrue:[ |
|
4065 |
revArg := revArg , rev1 |
|
4066 |
]. |
|
4067 |
revArg := revArg , ':'. |
|
4068 |
rev2 notNil ifTrue:[ |
|
4069 |
revArg := revArg , rev2 |
|
4070 |
]. |
|
4071 |
] |
|
4072 |
]. |
|
4073 |
||
4074 |
headerOnly ifTrue:[ |
|
4075 |
msg := 'fetching revision info ' |
|
4076 |
] ifFalse:[ |
|
4077 |
msg := 'reading revision log ' |
|
4078 |
]. |
|
4079 |
clsOrNil isNil ifTrue:[ |
|
4080 |
msg := msg , 'in ' , fullName. |
|
4081 |
] ifFalse:[ |
|
4082 |
msg := msg , 'of ', clsOrNil name. |
|
4083 |
]. |
|
4084 |
self activityNotification:msg. |
|
4085 |
||
4086 |
inStream := self |
|
4087 |
executeCVSCommand:('log ' , revArg , ' ' , fullName) |
|
4088 |
module:moduleDir |
|
4089 |
inDirectory:tempDir |
|
4090 |
log:true |
|
4091 |
pipe:true. |
|
4092 |
||
4093 |
inStream isNil ifTrue:[ |
|
4094 |
('CVSSourceCodeManager [error]: cannot open pipe to cvs log ', fullName) errorPrintCR. |
|
4095 |
^ nil |
|
4096 |
]. |
|
4097 |
||
4098 |
"/ |
|
4099 |
"/ read the commands pipe output and extract the container info |
|
4100 |
"/ |
|
4101 |
info := IdentityDictionary new. |
|
4102 |
inHeaderInfo := true. |
|
4103 |
[inHeaderInfo and:[inStream atEnd not]] whileTrue:[ |
|
4104 |
line:= inStream nextLine. |
|
4105 |
line notNil ifTrue:[ |
|
4106 |
|gotIt| |
|
4107 |
||
4108 |
gotIt := false. |
|
4109 |
#('RCS file:' #container |
|
4110 |
'Working file:' #filename |
|
4111 |
'head:' #newestRevision |
|
4112 |
'total revisions:' #numberOfRevisions |
|
4113 |
) pairWiseDo:[:word :key | |
|
4114 |
gotIt ifFalse:[ |
|
4115 |
s := line restAfter:word withoutSeparators:true. |
|
4116 |
s notNil ifTrue:[info at:key put:s. gotIt := true]. |
|
4117 |
] |
|
4118 |
]. |
|
4119 |
gotIt ifFalse:[ |
|
4120 |
(line startsWith:'description:') ifTrue:[inHeaderInfo := false]. |
|
4121 |
] |
|
4122 |
] |
|
4123 |
]. |
|
4124 |
inStream nextLine. "/ skip separating line after description. |
|
4125 |
||
4126 |
info isEmpty ifTrue:[ |
|
4127 |
('CVSSourceCodeManager [warning]: no log for ', fullName) errorPrintCR. |
|
4128 |
^ nil |
|
4129 |
]. |
|
4130 |
||
4131 |
"/ strip selected revisions from the total-revisions entry |
|
4132 |
s := info at:#numberOfRevisions. |
|
4133 |
(idx := s indexOf:$;) ~~ 0 ifTrue:[ |
|
4134 |
info at:#numberOfRevisions put:(Integer readFrom:(s copyTo:idx - 1)) |
|
4135 |
] ifFalse:[ |
|
4136 |
info at:#numberOfRevisions put:(Integer readFrom:s onError:[1]) |
|
4137 |
]. |
|
4138 |
headerOnly ifFalse:[ |
|
4139 |
"/ |
|
4140 |
"/ continue to read the commands pipe output |
|
4141 |
"/ and extract revision info records |
|
4142 |
"/ |
|
4143 |
revisionRecords := OrderedCollection new:(info at:#numberOfRevisions). |
|
4144 |
info at:#revisions put:revisionRecords. |
|
4145 |
||
4146 |
atEnd := false. |
|
4147 |
[atEnd or:[inStream atEnd]] whileFalse:[ |
|
4148 |
record := self readRevisionLogEntryFromStream:inStream. |
|
4149 |
||
4150 |
"/ revLine1 := inStream nextLine. |
|
4151 |
"/ [revLine1 notNil and:[(revLine1 startsWith:'revision ') not]] |
|
4152 |
"/ whileTrue:[inStream atEnd ifTrue:[ |
|
4153 |
"/ revLine1 := nil |
|
4154 |
"/ ] ifFalse:[ |
|
4155 |
"/ revLine1 := inStream nextLine.]]. |
|
4156 |
"/ revLine2 := inStream nextLine. |
|
4157 |
"/ (revLine1 notNil and:[revLine2 notNil]) ifTrue:[ |
|
4158 |
"/ record := IdentityDictionary new. |
|
4159 |
"/ record at:#revision put:(revLine1 asCollectionOfWords at:2). |
|
4160 |
"/ "/ decompose date/author/state etc. |
|
4161 |
"/ (revLine2 asCollectionOfSubstringsSeparatedBy:$;) do:[:info | |
|
4162 |
"/ |subEntry| |
|
4163 |
"/ subEntry := info withoutSeparators. |
|
4164 |
"/ #('date:' #date |
|
4165 |
"/ 'author:' #author |
|
4166 |
"/ 'state:' #state |
|
4167 |
"/ 'lines:' #numberOfChangedLines |
|
4168 |
"/ ) pairWiseDo:[:word :key | |
|
4169 |
"/ s := subEntry restAfter:word withoutSeparators:true. |
|
4170 |
"/ s notNil ifTrue:[record at:key put:s.]. |
|
4171 |
"/ ]. |
|
4172 |
"/ ]. |
|
4173 |
"/ |
|
4174 |
"/ "first revision does not hav a 'lines:' entry" |
|
4175 |
"/ (record includesKey:#numberOfChangedLines) ifFalse:[ |
|
4176 |
"/ record at:#numberOfChangedLines put:'' |
|
4177 |
"/ ]. |
|
4178 |
"/ |
|
4179 |
"/ s := nil. |
|
4180 |
"/ line := inStream nextLine. |
|
4181 |
"/ [atEnd or:[line isNil or:[line startsWith:'--------']]] whileFalse:[ |
|
4182 |
"/ (line startsWith:'==========') ifTrue:[ |
|
4183 |
"/ atEnd := true. |
|
4184 |
"/ ] ifFalse:[ |
|
4185 |
"/ (line withoutSpaces = '.') ifTrue:[ |
|
4186 |
"/ line := '*** empty log message ***' |
|
4187 |
"/ ]. |
|
4188 |
"/ s isNil ifTrue:[ |
|
4189 |
"/ s := line |
|
4190 |
"/ ] ifFalse:[ |
|
4191 |
"/ s := s , Character cr asString , line. |
|
4192 |
"/ ]. |
|
4193 |
"/ line := inStream nextLine. |
|
4194 |
"/ ] |
|
4195 |
"/ ]. |
|
4196 |
"/ record at:#logMessage put:s. |
|
4197 |
"/ revisionRecords add:record. |
|
4198 |
"/ ] |
|
4199 |
record isNil ifTrue:[ |
|
4200 |
atEnd := true. |
|
4201 |
] ifFalse:[ |
|
4202 |
revisionRecords add:record. |
|
4203 |
] |
|
4204 |
]. |
|
4205 |
]. |
|
4206 |
] ensure:[ |
|
4207 |
inStream notNil ifTrue:[inStream close]. |
|
4208 |
tempDir recursiveRemove |
|
4209 |
]. |
|
4210 |
^ info |
|
4211 |
||
4212 |
" |
|
4213 |
SourceCodeManager revisionLogOf:Array |
|
4214 |
SourceCodeManager revisionLogOf:Array fromRevision:'1.40' toRevision:'1.43' |
|
4215 |
SourceCodeManager revisionLogOf:Array fromRevision:'1.40' toRevision:nil |
|
4216 |
SourceCodeManager revisionLogOf:Array fromRevision:nil toRevision:'1.3' |
|
4217 |
SourceCodeManager revisionLogOf:Array fromRevision:nil toRevision:nil |
|
4218 |
SourceCodeManager revisionLogOf:Array fromRevision:0 toRevision:0 |
|
4219 |
" |
|
4220 |
||
4221 |
"Created: / 16.11.1995 / 13:25:30 / cg" |
|
4222 |
"Modified: / 29.1.1997 / 16:51:30 / stefan" |
|
4223 |
"Modified: / 27.8.1998 / 12:40:59 / cg" |
|
4224 |
! |
|
4225 |
||
4226 |
revisionLogOf:clsOrNil numberOfRevisions:numRevisions fileName:classFileName directory:packageDir module:moduleDir |
|
4227 |
"return info about the repository container and |
|
4228 |
(part of) the revisionlog (numRevisions newest revisions) |
|
4229 |
as a collection of revision entries. |
|
4230 |
Return nil on failure. |
|
4231 |
||
4232 |
The returned information is a structure (IdentityDictionary) |
|
4233 |
filled with: |
|
4234 |
#container -> the RCS container file name |
|
4235 |
#filename -> the actual source file name |
|
4236 |
#newestRevision -> the revisionString of the newest revision |
|
4237 |
#numberOfRevisions -> the number of revisions in the container (nil for all) |
|
4238 |
#revisions -> collection of per-revision info (see below) |
|
4239 |
||
4240 |
rev1 / rev2 specify from which revisions a logEntry is wanted: |
|
4241 |
-If rev1 is nil, the first revision is the initial revision |
|
4242 |
otherwise, the log starts with that revision. |
|
4243 |
-If rev2 is nil, the last revision is the newest revision |
|
4244 |
otherwise, the log ends with that revision. |
|
4245 |
||
4246 |
-If both are nil, all logEntries are extracted. |
|
4247 |
-If both are 0 (not nil), no logEntries are extracted (i.e. only the header). |
|
4248 |
||
4249 |
per revision info consists of one record per revision: |
|
4250 |
||
4251 |
#revision -> the revision string |
|
4252 |
#author -> who checked that revision into the repository |
|
4253 |
#date -> when was it checked in |
|
4254 |
#state -> the RCS state |
|
4255 |
#numberOfChangedLines -> the number of changed line w.r.t the previous |
|
4256 |
#logMessage -> the checkIn log message |
|
4257 |
||
4258 |
revisions are ordered newest first |
|
4259 |
(i.e. the last entry is for the initial revision; the first for the most recent one) |
|
4260 |
" |
|
4261 |
||
4262 |
|tempDir fullName modulePath inStream inHeaderInfo atEnd line revArg idx |
|
4263 |
info record revisionRecords s msg| |
|
4264 |
||
4265 |
modulePath := moduleDir , '/' , packageDir. |
|
4266 |
fullName := modulePath , '/' , classFileName. |
|
4267 |
tempDir := self createTempDirectory:nil forModule:nil. |
|
4268 |
tempDir isNil ifTrue:[ |
|
4269 |
('CVSSourceCodeManager [error]: no tempDir - cannot extract log') errorPrintCR. |
|
4270 |
^ nil. |
|
4271 |
]. |
|
4272 |
||
4273 |
[ |
|
4274 |
self createEntryFor:fullName |
|
4275 |
module:moduleDir |
|
4276 |
in:(tempDir construct:modulePath) |
|
4277 |
revision:'1.1' |
|
4278 |
date:'dummy' |
|
4279 |
special:'' |
|
4280 |
overwrite:false. |
|
4281 |
||
4282 |
revArg := ''. |
|
4283 |
||
4284 |
msg := 'reading revision log '. |
|
4285 |
clsOrNil isNil ifTrue:[ |
|
4286 |
msg := msg , 'in ' , fullName. |
|
4287 |
] ifFalse:[ |
|
4288 |
msg := msg , 'of ', clsOrNil name. |
|
4289 |
]. |
|
4290 |
self activityNotification:msg. |
|
4291 |
||
4292 |
inStream := self |
|
4293 |
executeCVSCommand:('log ' , revArg , ' ' , fullName) |
|
4294 |
module:moduleDir |
|
4295 |
inDirectory:tempDir |
|
4296 |
log:true |
|
4297 |
pipe:true. |
|
4298 |
||
4299 |
inStream isNil ifTrue:[ |
|
4300 |
('CVSSourceCodeManager [error]: cannot open pipe to cvs log ', fullName) errorPrintCR. |
|
4301 |
^ nil |
|
4302 |
]. |
|
4303 |
||
4304 |
"/ |
|
4305 |
"/ read the commands pipe output and extract the container info |
|
4306 |
"/ |
|
4307 |
info := IdentityDictionary new. |
|
4308 |
inHeaderInfo := true. |
|
4309 |
[inHeaderInfo and:[inStream atEnd not]] whileTrue:[ |
|
4310 |
line:= inStream nextLine. |
|
4311 |
line notNil ifTrue:[ |
|
4312 |
|gotIt| |
|
4313 |
||
4314 |
gotIt := false. |
|
4315 |
#('RCS file:' #container |
|
4316 |
'Working file:' #filename |
|
4317 |
'head:' #newestRevision |
|
4318 |
'total revisions:' #numberOfRevisions |
|
4319 |
) pairWiseDo:[:word :key | |
|
4320 |
gotIt ifFalse:[ |
|
4321 |
s := line restAfter:word withoutSeparators:true. |
|
4322 |
s notNil ifTrue:[info at:key put:s. gotIt := true]. |
|
4323 |
] |
|
4324 |
]. |
|
4325 |
gotIt ifFalse:[ |
|
4326 |
(line startsWith:'description:') ifTrue:[inHeaderInfo := false]. |
|
4327 |
] |
|
4328 |
] |
|
4329 |
]. |
|
4330 |
inStream nextLine. "/ skip separating line after description. |
|
4331 |
||
4332 |
info isEmpty ifTrue:[ |
|
4333 |
('CVSSourceCodeManager [warning]: no log for ', fullName) errorPrintCR. |
|
4334 |
^ nil |
|
4335 |
]. |
|
4336 |
||
4337 |
"/ strip selected revisions from the total-revisions entry |
|
4338 |
s := info at:#numberOfRevisions. |
|
4339 |
(idx := s indexOf:$;) ~~ 0 ifTrue:[ |
|
4340 |
info at:#numberOfRevisions put:(Integer readFrom:(s copyTo:idx - 1)) |
|
4341 |
] ifFalse:[ |
|
4342 |
info at:#numberOfRevisions put:(Integer readFrom:s onError:[1]) |
|
4343 |
]. |
|
4344 |
||
4345 |
"/ |
|
4346 |
"/ continue to read the commands pipe output |
|
4347 |
"/ and extract revision-info records |
|
4348 |
"/ |
|
4349 |
revisionRecords := OrderedCollection new:(info at:#numberOfRevisions). |
|
4350 |
info at:#revisions put:revisionRecords. |
|
4351 |
||
4352 |
atEnd := false. |
|
4353 |
[atEnd or:[inStream atEnd]] whileFalse:[ |
|
4354 |
record := self readRevisionLogEntryFromStream:inStream. |
|
4355 |
record isNil ifTrue:[ |
|
4356 |
atEnd := true. |
|
4357 |
] ifFalse:[ |
|
4358 |
revisionRecords add:record. |
|
4359 |
]. |
|
4360 |
(numRevisions notNil and:[revisionRecords size >= numRevisions]) ifTrue:[ |
|
4361 |
atEnd := true |
|
4362 |
] |
|
4363 |
]. |
|
4364 |
] ensure:[ |
|
4365 |
inStream notNil ifTrue:[inStream shutDown "close"]. |
|
4366 |
tempDir recursiveRemove |
|
4367 |
]. |
|
4368 |
^ info |
|
4369 |
||
4370 |
" |
|
4371 |
SourceCodeManager revisionLogOf:Array |
|
4372 |
SourceCodeManager revisionLogOf:Array numberOfRevisions:5 |
|
4373 |
||
4374 |
" |
|
4375 |
! |
|
4376 |
||
4377 |
statusOf:clsOrNil fileName:classFileName directory:packageDir module:moduleDir |
|
4378 |
"return info about the status repository container. |
|
4379 |
Return nil on failure. |
|
4380 |
||
4381 |
The returned information is a structure (IdentityDictionary) |
|
4382 |
filled with: |
|
4383 |
#newestRevision -> the revisionString of the newest revision |
|
4384 |
||
4385 |
This is much faster than revisionLog info (especially, if there are many revisions), |
|
4386 |
and all we need is a classes newest version number. |
|
4387 |
" |
|
4388 |
||
4389 |
|tempDir fullName modulePath inStream line |
|
4390 |
info s msg| |
|
4391 |
||
4392 |
modulePath := moduleDir , '/' , packageDir. |
|
4393 |
fullName := modulePath , '/' , classFileName. |
|
4394 |
tempDir := self createTempDirectory:nil forModule:nil. |
|
4395 |
tempDir isNil ifTrue:[ |
|
4396 |
('CVSSourceCodeManager [error]: no tempDir - cannot extract log') errorPrintCR. |
|
4397 |
^ nil. |
|
4398 |
]. |
|
4399 |
||
4400 |
[ |
|
4401 |
self createEntryFor:fullName |
|
4402 |
module:moduleDir |
|
4403 |
in:(tempDir construct:modulePath) |
|
4404 |
revision:'1.1' |
|
4405 |
date:'dummy' |
|
4406 |
special:'' |
|
4407 |
overwrite:false. |
|
4408 |
||
4409 |
msg := 'fetching status info of '. |
|
4410 |
clsOrNil isNil ifTrue:[ |
|
4411 |
msg := msg , fullName. |
|
4412 |
] ifFalse:[ |
|
4413 |
msg := msg , clsOrNil name. |
|
4414 |
]. |
|
4415 |
self activityNotification:msg. |
|
4416 |
||
4417 |
inStream := self |
|
4418 |
executeCVSCommand:('status ' , fullName) |
|
4419 |
module:moduleDir |
|
4420 |
inDirectory:tempDir |
|
4421 |
log:true |
|
4422 |
pipe:true. |
|
4423 |
||
4424 |
inStream isNil ifTrue:[ |
|
4425 |
('CVSSourceCodeManager [error]: cannot open pipe to cvs log ', fullName) errorPrintCR. |
|
4426 |
^ nil |
|
4427 |
]. |
|
4428 |
||
4429 |
"/ |
|
4430 |
"/ read the commands pipe output and extract the container info |
|
4431 |
"/ |
|
4432 |
info := IdentityDictionary new. |
|
4433 |
[inStream atEnd] whileFalse:[ |
|
4434 |
line:= inStream nextLine. |
|
4435 |
line notNil ifTrue:[ |
|
4436 |
line := line withoutSeparators. |
|
4437 |
]. |
|
4438 |
line size > 0 ifTrue:[ |
|
4439 |
|gotIt i| |
|
4440 |
||
4441 |
gotIt := false. |
|
4442 |
#( |
|
4443 |
'Repository revision:' #newestRevision |
|
4444 |
) pairWiseDo:[:word :key | |
|
4445 |
gotIt ifFalse:[ |
|
4446 |
s := line restAfter:word withoutSeparators:true. |
|
4447 |
s notNil ifTrue:[ |
|
4448 |
i := s indexOfSeparator. |
|
4449 |
i ~~ 0 ifTrue:[ |
|
4450 |
s := s copyTo:i-1 |
|
4451 |
]. |
|
4452 |
info at:key put:s. |
|
4453 |
gotIt := true. |
|
4454 |
]. |
|
4455 |
] |
|
4456 |
]. |
|
4457 |
] |
|
4458 |
]. |
|
4459 |
info isEmpty ifTrue:[ |
|
4460 |
('CVSSourceCodeManager [warning]: no status for ', fullName) errorPrintCR. |
|
4461 |
^ nil |
|
4462 |
]. |
|
4463 |
] ensure:[ |
|
4464 |
inStream notNil ifTrue:[inStream close]. |
|
4465 |
tempDir recursiveRemove |
|
4466 |
]. |
|
4467 |
^ info |
|
4468 |
||
4469 |
" |
|
4470 |
SourceCodeManager statusOf:Array |
|
4471 |
SourceCodeManager statusOf:Array fileName:'Array.st' directory:'libbasic' module:'stx' |
|
4472 |
SourceCodeManager statusOf:Filename fileName:'Filename.st' directory:'libbasic' module:'stx' |
|
4473 |
SourceCodeManager statusOf:NewSystemBrowser fileName:'NewSystemBrowser.st' directory:'libtool' module:'stx' |
|
4474 |
" |
|
4475 |
! ! |
|
4476 |
||
4477 |
!CVSSourceCodeManager class methodsFor:'documentation'! |
|
4478 |
||
4479 |
version |
|
1407 | 4480 |
^ '$Header: /cvs/stx/stx/libbasic3/CVSSourceCodeManager.st,v 1.289 2004-12-15 10:32:43 penk Exp $' |
1362 | 4481 |
! ! |
1170 | 4482 |
|
130 | 4483 |
CVSSourceCodeManager initialize! |