author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 01 Feb 2013 12:02:22 +0000 | |
changeset 210 | 54a73fa50d40 |
parent 150 | 1813913f6106 |
child 335 | 7e19ab19148b |
permissions | -rw-r--r-- |
210 | 1 |
" |
2 |
COPYRIGHT (c) 2012-2013 by Jan Vrany |
|
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 |
" |
|
145 | 12 |
"{ Package: 'stx:libscm/mercurial' }" |
13 |
||
14 |
HGRepositoryObject subclass:#HGConfig |
|
146
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
15 |
instanceVariableNames:'root timestamp' |
145 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'SCM-Mercurial-Core' |
|
19 |
! |
|
20 |
||
21 |
Object subclass:#Entry |
|
22 |
instanceVariableNames:'name value' |
|
23 |
classVariableNames:'' |
|
24 |
poolDictionaries:'' |
|
25 |
privateIn:HGConfig |
|
26 |
! |
|
27 |
||
28 |
Dictionary subclass:#Section |
|
29 |
instanceVariableNames:'name entries' |
|
30 |
classVariableNames:'' |
|
31 |
poolDictionaries:'' |
|
32 |
privateIn:HGConfig |
|
33 |
! |
|
34 |
||
210 | 35 |
!HGConfig class methodsFor:'documentation'! |
36 |
||
37 |
copyright |
|
38 |
" |
|
39 |
COPYRIGHT (c) 2012-2013 by Jan Vrany |
|
40 |
All Rights Reserved |
|
41 |
||
42 |
This software is furnished under a license and may be used |
|
43 |
only in accordance with the terms of that license and with the |
|
44 |
inclusion of the above copyright notice. This software may not |
|
45 |
be provided or otherwise made available to, or used by, any |
|
46 |
other person. No title to or ownership of the software is |
|
47 |
hereby transferred. |
|
48 |
" |
|
49 |
! ! |
|
145 | 50 |
|
51 |
!HGConfig class methodsFor:'accessing-files'! |
|
52 |
||
53 |
userConfigFiles |
|
54 |
"Return a list of per-user config files" |
|
55 |
||
56 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
57 |
^{ |
|
58 |
Filename homeDirectory / '.hgrc' . |
|
59 |
Filename homeDirectory / 'Mercurial.ini' |
|
60 |
} |
|
61 |
]. |
|
62 |
||
63 |
OperatingSystem isUNIXlike ifTrue:[ |
|
64 |
^{ |
|
65 |
Filename homeDirectory / '.hgrc' . |
|
66 |
} |
|
67 |
]. |
|
68 |
||
69 |
self error:'Unsupported operating system' |
|
70 |
||
71 |
"Created: / 06-12-2012 / 20:30:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
72 |
"Modified (format): / 06-12-2012 / 21:34:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
73 |
! ! |
|
74 |
||
75 |
!HGConfig methodsFor:'accessing'! |
|
76 |
||
77 |
at: key |
|
78 |
^self root at:key |
|
79 |
||
80 |
"Created: / 06-12-2012 / 20:22:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
81 |
! |
|
82 |
||
83 |
at: key ifAbsent: block |
|
84 |
^self root at:key ifAbsent: block |
|
85 |
||
86 |
"Created: / 06-12-2012 / 20:23:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
87 |
! |
|
88 |
||
89 |
at: key ifAbsentPut: block |
|
90 |
^self root at:key ifAbsentPut: block |
|
91 |
||
92 |
"Created: / 06-12-2012 / 20:23:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
93 |
! |
|
94 |
||
95 |
at: key put: val |
|
96 |
^self root at:key put: val |
|
97 |
||
98 |
"Created: / 06-12-2012 / 20:23:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
99 |
! |
|
100 |
||
101 |
get: key |
|
102 |
^self root get:key |
|
103 |
||
104 |
"Created: / 06-12-2012 / 20:22:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
146
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
105 |
! |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
106 |
|
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
107 |
get: key default: default |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
108 |
^self root get:key default: default |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
109 |
|
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
110 |
"Created: / 07-12-2012 / 15:46:07 / jv" |
145 | 111 |
! ! |
112 |
||
113 |
!HGConfig methodsFor:'private'! |
|
114 |
||
115 |
mustReload |
|
116 |
root isNil ifTrue:[ ^ true ]. |
|
146
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
117 |
|
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
118 |
(self mustReloadBecauseOf: repository path / '.hg' / 'hgrc') ifTrue:[ |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
119 |
^true |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
120 |
]. |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
121 |
HGConfig userConfigFiles do:[:e| |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
122 |
(self mustReloadBecauseOf: e) ifTrue:[ ^ true ]. |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
123 |
]. |
145 | 124 |
^false |
125 |
||
126 |
"Created: / 06-12-2012 / 21:38:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
146
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
127 |
"Modified: / 07-12-2012 / 16:28:33 / jv" |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
128 |
! |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
129 |
|
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
130 |
mustReloadBecauseOf: filenameOrString |
150
1813913f6106
Addec HGRepositoru>>remotes returning list of remote repositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
147
diff
changeset
|
131 |
"Return true, if config must be reloaded because file is newer" |
146
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
132 |
|
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
133 |
| filename | |
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
134 |
|
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
135 |
filename := filenameOrString asFilename. |
150
1813913f6106
Addec HGRepositoru>>remotes returning list of remote repositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
147
diff
changeset
|
136 |
"/compensate for lack of milliseconds in OS time ---v |
1813913f6106
Addec HGRepositoru>>remotes returning list of remote repositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
147
diff
changeset
|
137 |
^filename exists and:[(filename modificationTime + 1000) >= timestamp]. |
146
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
138 |
|
1015b8f6dc1c
Added check for author signature before commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
145
diff
changeset
|
139 |
"Created: / 07-12-2012 / 16:26:38 / jv" |
150
1813913f6106
Addec HGRepositoru>>remotes returning list of remote repositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
147
diff
changeset
|
140 |
"Modified (comment): / 09-12-2012 / 23:15:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
145 | 141 |
! |
142 |
||
143 |
root |
|
144 |
self mustReload ifTrue:[ |
|
150
1813913f6106
Addec HGRepositoru>>remotes returning list of remote repositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
147
diff
changeset
|
145 |
timestamp := Timestamp now. |
145 | 146 |
root := HGCommand showconfig |
147 |
workingDirectory: repository pathName; |
|
148 |
execute. |
|
149 |
]. |
|
150 |
^root |
|
151 |
||
152 |
"Created: / 06-12-2012 / 20:25:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
150
1813913f6106
Addec HGRepositoru>>remotes returning list of remote repositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
147
diff
changeset
|
153 |
"Modified: / 09-12-2012 / 23:10:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
145 | 154 |
! ! |
155 |
||
156 |
!HGConfig::Entry methodsFor:'accessing'! |
|
157 |
||
158 |
name |
|
159 |
^ name |
|
160 |
! |
|
161 |
||
162 |
value |
|
163 |
^ value |
|
164 |
! ! |
|
165 |
||
166 |
!HGConfig::Entry methodsFor:'initialization'! |
|
167 |
||
168 |
setName: nm value: val |
|
169 |
name := nm. |
|
170 |
value := val. |
|
171 |
||
172 |
"Created: / 06-12-2012 / 19:29:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
173 |
! ! |
|
174 |
||
175 |
!HGConfig::Entry methodsFor:'testing'! |
|
176 |
||
177 |
isEntry |
|
178 |
^true |
|
179 |
||
180 |
"Created: / 06-12-2012 / 19:36:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
181 |
! |
|
182 |
||
183 |
isSection |
|
184 |
^false |
|
185 |
||
186 |
"Created: / 06-12-2012 / 19:36:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
187 |
! ! |
|
188 |
||
189 |
!HGConfig::Section methodsFor:'accessing'! |
|
190 |
||
191 |
get: key |
|
192 |
||
193 |
| entry | |
|
194 |
||
195 |
entry := self. |
|
196 |
(key isCollection and:[key isString not]) ifTrue:[ |
|
197 |
key do:[:e|entry := entry at: e] |
|
198 |
] ifFalse:[ |
|
199 |
entry := entry at:key. |
|
200 |
]. |
|
201 |
^entry value |
|
202 |
||
203 |
"Created: / 06-12-2012 / 20:01:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
204 |
"Modified: / 06-12-2012 / 21:48:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
205 |
! |
|
206 |
||
207 |
get: key default: default |
|
208 |
| entry | |
|
209 |
||
210 |
entry := self. |
|
211 |
(key isCollection and:[key isString not]) ifTrue:[ |
|
212 |
key do:[:e|entry := entry at: e ifAbsent:[ ^ default ]] |
|
213 |
] ifFalse:[ |
|
214 |
entry := entry at:key ifAbsent:[ ^ default ]. |
|
215 |
]. |
|
216 |
^entry value |
|
217 |
||
218 |
"Created: / 06-12-2012 / 20:07:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
219 |
"Modified: / 06-12-2012 / 21:49:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
220 |
! |
|
221 |
||
222 |
name |
|
223 |
^ name |
|
224 |
! ! |
|
225 |
||
226 |
!HGConfig::Section methodsFor:'initialization'! |
|
227 |
||
228 |
setName: nm |
|
229 |
name := nm. |
|
230 |
entries := Dictionary new |
|
231 |
||
232 |
"Created: / 06-12-2012 / 19:57:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
233 |
! ! |
|
234 |
||
235 |
!HGConfig::Section methodsFor:'testing'! |
|
236 |
||
237 |
isEntry |
|
238 |
^false |
|
239 |
||
240 |
"Created: / 06-12-2012 / 19:36:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
241 |
! |
|
242 |
||
243 |
isSection |
|
244 |
^true |
|
245 |
||
246 |
"Created: / 06-12-2012 / 19:36:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
247 |
! ! |
|
248 |
||
249 |
!HGConfig class methodsFor:'documentation'! |
|
250 |
||
251 |
version_HG |
|
252 |
||
253 |
^ '$Changeset: <not expanded> $' |
|
254 |
! ! |
|
210 | 255 |