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