author | Claus Gittinger <cg@exept.de> |
Mon, 14 May 2018 02:21:18 +0200 | |
changeset 1048 | 582b3a028cbc |
parent 1014 | 8e77e7bafd66 |
permissions | -rw-r--r-- |
33 | 1 |
"{ Package: 'stx:goodies/monticello' }" |
2 |
||
1014 | 3 |
"{ NameSpace: Smalltalk }" |
4 |
||
33 | 5 |
MCWriter subclass:#MCMczWriter |
6 |
instanceVariableNames:'zip infoWriter' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
639 | 9 |
category:'SCM-Monticello-Storing' |
33 | 10 |
! |
11 |
||
12 |
||
199 | 13 |
!MCMczWriter class methodsFor:'initialization'! |
14 |
||
15 |
new |
|
16 |
^self basicNew initialize |
|
17 |
! ! |
|
18 |
||
33 | 19 |
!MCMczWriter class methodsFor:'as yet unclassified'! |
20 |
||
21 |
fileOut: aVersion on: aStream |
|
199 | 22 |
| inst | |
23 |
inst := self on: aStream. |
|
24 |
inst writeVersion: aVersion. |
|
25 |
inst flush. |
|
26 |
||
142
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
27 |
|
33 | 28 |
! |
29 |
||
30 |
readerClass |
|
31 |
^ MCMczReader |
|
32 |
! ! |
|
33 |
||
34 |
!MCMczWriter methodsFor:'accessing'! |
|
35 |
||
36 |
format |
|
37 |
^ '1' |
|
38 |
! |
|
39 |
||
40 |
snapshotWriterClass |
|
41 |
^ MCStWriter |
|
42 |
! |
|
43 |
||
199 | 44 |
stream: aStream |
45 |
||
46 |
super stream: aStream. |
|
47 |
self zip. |
|
48 |
||
49 |
"Created: / 11-09-2010 / 14:18:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
50 |
! |
|
51 |
||
33 | 52 |
zip |
199 | 53 |
|
54 |
zip ifNil:[zip := ZipArchive writingTo: stream]. |
|
55 |
^ zip |
|
56 |
||
57 |
"Modified: / 11-09-2010 / 14:17:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
33 | 58 |
! ! |
59 |
||
60 |
!MCMczWriter methodsFor:'initializing'! |
|
61 |
||
62 |
initialize |
|
199 | 63 |
super initialize. |
64 |
"/zip := ZipArchive new. |
|
65 |
||
66 |
"Modified: / 11-09-2010 / 14:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
33 | 67 |
! ! |
68 |
||
69 |
!MCMczWriter methodsFor:'serializing'! |
|
70 |
||
71 |
serializeDefinitions: aCollection |
|
142
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
72 |
| writer s | |
564
e90d2909c9ae
variable renamed in: #serializeDefinitions:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
295
diff
changeset
|
73 |
s := CharacterWriteStream on: (String new: 64). |
199 | 74 |
writer := self snapshotWriterClass on: s. |
142
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
75 |
writer writeDefinitions: aCollection. |
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
76 |
^ s contents |
199 | 77 |
|
564
e90d2909c9ae
variable renamed in: #serializeDefinitions:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
295
diff
changeset
|
78 |
"Modified: / 05-05-2012 / 19:38:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
33 | 79 |
! |
80 |
||
199 | 81 |
serializeInBinary:aSnapshot |
82 |
|writer s| |
|
142
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
83 |
|
199 | 84 |
s := ReadWriteStream on:ByteArray new. |
85 |
writer := DataStream on:s. |
|
86 |
writer nextPut:aSnapshot. |
|
87 |
^ s contents |
|
142
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
88 |
|
199 | 89 |
"Modified: / 11-09-2010 / 19:24:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
33 | 90 |
! |
91 |
||
92 |
serializePackage: aPackage |
|
841
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
93 |
^ '(name ''', aPackage monticelloName, ''')' |
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
94 |
|
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
95 |
"Modified: / 29-05-2013 / 02:10:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
33 | 96 |
! |
97 |
||
98 |
serializeVersionInfo: aVersionInfo |
|
199 | 99 |
infoWriter ifNil: [infoWriter := MCVersionInfoWriter new]. |
33 | 100 |
^ String streamContents: |
101 |
[:s | |
|
102 |
infoWriter stream: s. |
|
103 |
infoWriter writeVersionInfo: aVersionInfo] |
|
104 |
! ! |
|
105 |
||
106 |
!MCMczWriter methodsFor:'visiting'! |
|
107 |
||
108 |
writeDefinitions: aVersion |
|
760 | 109 |
self writeSnapshot: aVersion snapshot forVersion: aVersion |
33 | 110 |
! |
111 |
||
112 |
writeFormat |
|
113 |
" self addString: self format at: 'format'." |
|
114 |
! |
|
115 |
||
116 |
writePackage: aPackage |
|
117 |
self addString: (self serializePackage: aPackage) at: 'package' |
|
118 |
! |
|
119 |
||
120 |
writeSnapshot: aSnapshot |
|
841
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
121 |
self addString: (self serializeDefinitions: aSnapshot definitions) at: 'snapshot/source.', self snapshotWriterClass extension. |
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
122 |
self addString: (self serializeInBinary: aSnapshot) at: 'snapshot.bin' |
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
123 |
|
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
124 |
"Created: / 29-05-2013 / 12:01:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
125 |
! |
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
126 |
|
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
127 |
writeSnapshot: aSnapshot forVersion: aVersion |
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
128 |
self writeSnapshot: aSnapshot |
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
129 |
|
0961973abe97
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
760
diff
changeset
|
130 |
"Created: / 29-05-2013 / 12:04:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
33 | 131 |
! |
132 |
||
133 |
writeVersion: aVersion |
|
134 |
self writeFormat. |
|
135 |
self writePackage: aVersion package. |
|
136 |
self writeVersionInfo: aVersion info. |
|
137 |
self writeDefinitions: aVersion. |
|
138 |
aVersion dependencies do: [:ea | self writeVersionDependency: ea] |
|
139 |
! |
|
140 |
||
141 |
writeVersionDependency: aVersionDependency |
|
142 |
| string | |
|
199 | 143 |
string := (self serializeVersionInfo: aVersionDependency versionInfo). |
33 | 144 |
self addString: string at: 'dependencies/', aVersionDependency package name |
145 |
! |
|
146 |
||
147 |
writeVersionInfo: aVersionInfo |
|
148 |
| string | |
|
199 | 149 |
string := self serializeVersionInfo: aVersionInfo. |
33 | 150 |
self addString: string at: 'version'. |
199 | 151 |
|
33 | 152 |
! ! |
153 |
||
154 |
!MCMczWriter methodsFor:'writing'! |
|
155 |
||
156 |
addString: string at: path |
|
142
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
157 |
| member | |
199 | 158 |
member := zip addString: string as: path. |
159 |
"/member desiredCompressionMethod: ZipArchive compressionDeflated |
|
142
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
160 |
|
199 | 161 |
"Modified: / 11-09-2010 / 14:19:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
33 | 162 |
! |
163 |
||
164 |
flush |
|
199 | 165 |
"zip writeTo: stream." |
1014 | 166 |
zip close. |
199 | 167 |
stream close |
142
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
168 |
|
199 | 169 |
"Modified: / 11-09-2010 / 19:36:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
33 | 170 |
! ! |
171 |
||
172 |
!MCMczWriter class methodsFor:'documentation'! |
|
173 |
||
295 | 174 |
version |
1014 | 175 |
^ '$Header$' |
295 | 176 |
! |
177 |
||
199 | 178 |
version_CVS |
1014 | 179 |
^ '$Header$' |
142
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
180 |
! |
4a05a68fe582
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
33
diff
changeset
|
181 |
|
199 | 182 |
version_SVN |
1014 | 183 |
^ '$Id$' |
33 | 184 |
! ! |
760 | 185 |