author | Claus Gittinger <cg@exept.de> |
Fri, 25 Nov 2011 17:46:33 +0100 | |
changeset 522 | 50d3c41be619 |
parent 483 | 58521a30b56f |
child 638 | bf4c7c62a28f |
permissions | -rw-r--r-- |
32 | 1 |
"{ Package: 'stx:goodies/monticello' }" |
2 |
||
3 |
MCVersionReader subclass:#MCMczReader |
|
4 |
instanceVariableNames:'zip infoCache' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
7 |
category:'Monticello-Storing' |
|
8 |
! |
|
9 |
||
10 |
||
11 |
!MCMczReader class methodsFor:'accessing'! |
|
12 |
||
13 |
extension |
|
14 |
^ 'mcz' |
|
15 |
! ! |
|
16 |
||
17 |
!MCMczReader class methodsFor:'testing'! |
|
18 |
||
19 |
supportsDependencies |
|
20 |
^ true |
|
21 |
! |
|
22 |
||
23 |
supportsVersions |
|
24 |
^ true |
|
25 |
! ! |
|
26 |
||
208 | 27 |
!MCMczReader methodsFor:'as yet unclassified'! |
32 | 28 |
|
29 |
associate: tokens |
|
208 | 30 |
|
31 |
^MCLazyPropertyDictionary withTokens: tokens. |
|
32 |
||
33 |
" |
|
32 | 34 |
| result | |
208 | 35 |
result := Dictionary new. |
36 |
tokens pairWiseDo: [:key :value | |
|
37 |
| tmp | |
|
38 |
tmp := value. |
|
39 |
value isString ifFalse: [tmp := value collect: [:ea | self associate: ea]]. |
|
40 |
value = 'nil' ifTrue: [tmp := '']. |
|
41 |
result at: key put: tmp]. |
|
32 | 42 |
^ result |
208 | 43 |
" |
32 | 44 |
|
208 | 45 |
"Modified: / 28-10-2010 / 15:25:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
46 |
! |
|
32 | 47 |
|
48 |
extractDefinitionsFrom: member |
|
208 | 49 |
| reader rc | |
50 |
(rc := (MCSnapshotReader readerClassForFileNamed: member fileName)) |
|
51 |
ifNotNil: |
|
52 |
[ reader := rc on: (self zip contentsOf: member fileName). |
|
53 |
definitions addAll: reader definitions] |
|
54 |
||
55 |
"Modified: / 11-09-2010 / 21:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
32 | 56 |
! |
57 |
||
58 |
extractDependencyFrom: zipMember |
|
59 |
^ MCVersionDependency |
|
60 |
package: (MCPackage named: (zipMember fileName copyAfterLast: $/)) |
|
61 |
info: (self extractInfoFrom: (self parseMember: zipMember fileName)) |
|
62 |
! |
|
63 |
||
64 |
extractInfoFrom: dict |
|
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
65 |
^ self infoCache at: (dict at: #id) ifAbsentPut: |
208 | 66 |
[MCLazyVersionInfo withProperties: dict] |
67 |
" |
|
68 |
[MCVersionInfo |
|
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
69 |
name: (dict at: #name ifAbsent: ['']) |
208 | 70 |
id: (UUID fromString: (dict at: #id)) |
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
71 |
message: (dict at: #message ifAbsent: ['']) |
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
72 |
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
|
73 |
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
|
74 |
author: (dict at: #author ifAbsent: ['']) |
208 | 75 |
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
|
76 |
stepChildren: ((dict at: #stepChildren ifAbsent: [#()]) collect: [:ea | self extractInfoFrom: ea])] |
208 | 77 |
" |
78 |
||
79 |
"Modified: / 28-10-2010 / 17:53:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
32 | 80 |
! |
81 |
||
82 |
infoCache |
|
208 | 83 |
^ infoCache ifNil: [infoCache := Dictionary new] |
32 | 84 |
! |
85 |
||
86 |
loadDefinitions |
|
208 | 87 |
definitions := OrderedCollection new. |
522 | 88 |
(self zip isValidPath: 'snapshot.bin') ifTrue: |
208 | 89 |
[ [^ definitions := (DataStream on: (self zip contentsOf: 'snapshot.bin') asByteArray readStream) next definitions] |
90 |
on: Error do: [:fallThrough|self halt ]]. |
|
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
91 |
"otherwise" |
522 | 92 |
|
208 | 93 |
self breakPoint:#jv. |
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
94 |
(self zip membersMatching: 'snapshot/*') |
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
95 |
do: [:m | self extractDefinitionsFrom: m]. |
208 | 96 |
|
97 |
"Modified: / 14-09-2010 / 21:22:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
522 | 98 |
"Modified: / 25-11-2011 / 16:55:00 / cg" |
32 | 99 |
! |
100 |
||
101 |
loadDependencies |
|
208 | 102 |
dependencies := (self zip membersMatching: 'dependencies/*') collect: [:m | self extractDependencyFrom: m]. |
103 |
dependencies := dependencies asArray. |
|
104 |
||
32 | 105 |
! |
106 |
||
107 |
loadPackage |
|
108 |
| dict | |
|
208 | 109 |
dict := self parseMember: 'package'. |
110 |
package := MCPackage named: (dict at: #name) |
|
32 | 111 |
! |
112 |
||
113 |
loadVersionInfo |
|
208 | 114 |
info := self extractInfoFrom: (self parseMember: 'version') |
32 | 115 |
! |
116 |
||
117 |
parseMember: fileName |
|
208 | 118 |
| tokens | |
119 |
tokens := (self scanner scanTokens: (self zip contentsOf: fileName)) first. |
|
120 |
^ self associate: tokens |
|
32 | 121 |
! |
122 |
||
123 |
scanner |
|
124 |
^ MCScanner |
|
125 |
! |
|
126 |
||
127 |
zip |
|
483 | 128 |
(zip isNil or:[zip fileSize == 0]) ifTrue:[ |
129 |
zip := ZipArchive readingFrom:stream |
|
130 |
]. |
|
131 |
^ zip |
|
132 |
||
133 |
"Modified: / 07-09-2011 / 14:55:18 / cg" |
|
32 | 134 |
! ! |
135 |
||
136 |
!MCMczReader class methodsFor:'documentation'! |
|
137 |
||
138 |
version |
|
522 | 139 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCMczReader.st,v 1.6 2011-11-25 16:46:33 cg Exp $' |
141
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
140 |
! |
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
141 |
|
0f1d8459da84
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
32
diff
changeset
|
142 |
version_CVS |
522 | 143 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCMczReader.st,v 1.6 2011-11-25 16:46:33 cg Exp $' |
208 | 144 |
! |
145 |
||
146 |
version_SVN |
|
147 |
^ '§Id: MCMczReader.st 23 2010-10-29 14:41:24Z vranyj1 §' |
|
32 | 148 |
! ! |