author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sun, 10 May 2015 06:09:15 +0100 | |
branch | jv |
changeset 996 | ab948c69360b |
parent 913 | 224fedf76aa7 |
child 1099 | df7f9c846b88 |
permissions | -rw-r--r-- |
32 | 1 |
"{ Package: 'stx:goodies/monticello' }" |
2 |
||
996
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
3 |
"{ NameSpace: Smalltalk }" |
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
4 |
|
32 | 5 |
MCVersionReader subclass:#MCMczReader |
6 |
instanceVariableNames:'zip infoCache' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
638 | 9 |
category:'SCM-Monticello-Storing' |
32 | 10 |
! |
11 |
||
12 |
||
13 |
!MCMczReader class methodsFor:'accessing'! |
|
14 |
||
15 |
extension |
|
16 |
^ 'mcz' |
|
17 |
! ! |
|
18 |
||
19 |
!MCMczReader class methodsFor:'testing'! |
|
20 |
||
996
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
21 |
canReadFileNamed: fileName |
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
22 |
"Hack to use MCStXMczReader on Smalltalk/X" |
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
23 |
|
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
24 |
^ ((Smalltalk respondsTo: #isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) |
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
25 |
ifTrue:[ self == MCStXMczReader and: [ super canReadFileNamed: fileName ] ] |
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
26 |
ifFalse:[ super canReadFileNamed: fileName ]. |
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
27 |
|
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
28 |
"Created: / 10-05-2015 / 06:05:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
29 |
! |
ab948c69360b
Transfrom snapshot using MCStXSnapshotPostReadTransformation after reading .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
913
diff
changeset
|
30 |
|
32 | 31 |
supportsDependencies |
32 |
^ true |
|
33 |
! |
|
34 |
||
35 |
supportsVersions |
|
36 |
^ true |
|
37 |
! ! |
|
38 |
||
208 | 39 |
!MCMczReader methodsFor:'as yet unclassified'! |
32 | 40 |
|
41 |
associate: tokens |
|
208 | 42 |
|
43 |
^MCLazyPropertyDictionary withTokens: tokens. |
|
44 |
||
45 |
" |
|
32 | 46 |
| result | |
208 | 47 |
result := Dictionary new. |
48 |
tokens pairWiseDo: [:key :value | |
|
49 |
| tmp | |
|
50 |
tmp := value. |
|
51 |
value isString ifFalse: [tmp := value collect: [:ea | self associate: ea]]. |
|
52 |
value = 'nil' ifTrue: [tmp := '']. |
|
53 |
result at: key put: tmp]. |
|
32 | 54 |
^ result |
208 | 55 |
" |
32 | 56 |
|
208 | 57 |
"Modified: / 28-10-2010 / 15:25:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
58 |
! |
|
32 | 59 |
|
60 |
extractDefinitionsFrom: member |
|
208 | 61 |
| reader rc | |
62 |
(rc := (MCSnapshotReader readerClassForFileNamed: member fileName)) |
|
63 |
ifNotNil: |
|
64 |
[ reader := rc on: (self zip contentsOf: member fileName). |
|
65 |
definitions addAll: reader definitions] |
|
66 |
||
67 |
"Modified: / 11-09-2010 / 21:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
32 | 68 |
! |
69 |
||
70 |
extractDependencyFrom: zipMember |
|
71 |
^ MCVersionDependency |
|
72 |
package: (MCPackage named: (zipMember fileName copyAfterLast: $/)) |
|
73 |
info: (self extractInfoFrom: (self parseMember: zipMember fileName)) |
|
74 |
! |
|
75 |
||
76 |
extractInfoFrom: dict |
|
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
77 |
^ self infoCache at: (dict at: #id) ifAbsentPut: |
208 | 78 |
[MCLazyVersionInfo withProperties: dict] |
79 |
" |
|
80 |
[MCVersionInfo |
|
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
81 |
name: (dict at: #name ifAbsent: ['']) |
208 | 82 |
id: (UUID fromString: (dict at: #id)) |
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
83 |
message: (dict at: #message ifAbsent: ['']) |
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
84 |
date: ([Date fromString: (dict at: #date) ] on: Error do: [ :ex | ex return: nil ]) |
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
85 |
time: ([ Time fromString:(dict at: #time)] on: Error do: [ :ex | ex return: nil ]) |
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
86 |
author: (dict at: #author ifAbsent: ['']) |
208 | 87 |
ancestors: ((dict at: #ancestors ifAbsent:#()) collect: [:ea | self extractInfoFrom: ea]) |
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
88 |
stepChildren: ((dict at: #stepChildren ifAbsent: [#()]) collect: [:ea | self extractInfoFrom: ea])] |
208 | 89 |
" |
90 |
||
91 |
"Modified: / 28-10-2010 / 17:53:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
32 | 92 |
! |
93 |
||
94 |
infoCache |
|
208 | 95 |
^ infoCache ifNil: [infoCache := Dictionary new] |
32 | 96 |
! |
97 |
||
98 |
loadDefinitions |
|
913 | 99 |
|doNotShowAgainHolder| |
100 |
||
101 |
doNotShowAgainHolder := false asValue. |
|
102 |
||
208 | 103 |
definitions := OrderedCollection new. |
913 | 104 |
(self zip isValidPath: 'snapshot.bin') ifTrue:[ |
105 |
[ |
|
106 |
^ definitions := (DataStream on: (self zip contentsOf: 'snapshot.bin') |
|
107 |
asByteArray readStream) next definitions |
|
108 |
] on: Error do: [:fallThrough| |
|
109 |
doNotShowAgainHolder value ifTrue:[fallThrough proceed]. |
|
110 |
||
111 |
"/ self halt:fallThrough description |
|
112 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
|
113 |
ex box addCheckBoxAtBottom:'Do not show this dialog again.' on:doNotShowAgainHolder. |
|
114 |
] do:[ |
|
115 |
|answer| |
|
116 |
||
117 |
answer := Dialog confirmWithCancel:(fallThrough description,'\\Try proceeding with binary? (if NO, source is loaded)') withCRs. |
|
118 |
answer isNil ifTrue:[AbortOperationRequest raise]. |
|
119 |
answer ifTrue:[ |
|
120 |
fallThrough proceed |
|
121 |
]. |
|
122 |
]. |
|
123 |
] |
|
124 |
]. |
|
125 |
"otherwise (binay broken), try source" |
|
522 | 126 |
|
208 | 127 |
self breakPoint:#jv. |
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
128 |
(self zip membersMatching: 'snapshot/*') |
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
129 |
do: [:m | self extractDefinitionsFrom: m]. |
208 | 130 |
|
131 |
"Modified: / 14-09-2010 / 21:22:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
522 | 132 |
"Modified: / 25-11-2011 / 16:55:00 / cg" |
32 | 133 |
! |
134 |
||
135 |
loadDependencies |
|
208 | 136 |
dependencies := (self zip membersMatching: 'dependencies/*') collect: [:m | self extractDependencyFrom: m]. |
137 |
dependencies := dependencies asArray. |
|
138 |
||
32 | 139 |
! |
140 |
||
141 |
loadPackage |
|
142 |
| dict | |
|
208 | 143 |
dict := self parseMember: 'package'. |
144 |
package := MCPackage named: (dict at: #name) |
|
32 | 145 |
! |
146 |
||
147 |
loadVersionInfo |
|
208 | 148 |
info := self extractInfoFrom: (self parseMember: 'version') |
32 | 149 |
! |
150 |
||
151 |
parseMember: fileName |
|
208 | 152 |
| tokens | |
153 |
tokens := (self scanner scanTokens: (self zip contentsOf: fileName)) first. |
|
154 |
^ self associate: tokens |
|
32 | 155 |
! |
156 |
||
157 |
scanner |
|
158 |
^ MCScanner |
|
159 |
! |
|
160 |
||
161 |
zip |
|
483 | 162 |
(zip isNil or:[zip fileSize == 0]) ifTrue:[ |
163 |
zip := ZipArchive readingFrom:stream |
|
164 |
]. |
|
165 |
^ zip |
|
166 |
||
167 |
"Modified: / 07-09-2011 / 14:55:18 / cg" |
|
32 | 168 |
! ! |
169 |
||
170 |
!MCMczReader class methodsFor:'documentation'! |
|
171 |
||
172 |
version |
|
913 | 173 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCMczReader.st,v 1.8 2014-02-12 17:30:06 cg Exp $' |
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
174 |
! |
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
175 |
|
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
176 |
version_CVS |
913 | 177 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCMczReader.st,v 1.8 2014-02-12 17:30:06 cg Exp $' |
208 | 178 |
! |
179 |
||
180 |
version_SVN |
|
913 | 181 |
^ '$Id: MCMczReader.st,v 1.8 2014-02-12 17:30:06 cg Exp $' |
32 | 182 |
! ! |
913 | 183 |