equal
deleted
inserted
replaced
136 |
136 |
137 readFrom: aStringOrStream onError: aBlock |
137 readFrom: aStringOrStream onError: aBlock |
138 "Parses node id from stream and returns it. Support both, |
138 "Parses node id from stream and returns it. Support both, |
139 short and full node ids" |
139 short and full node ids" |
140 |
140 |
141 | stream c c1 c2 sign revno hash hashPos short | |
141 | stream c c1 c2 sign revno hash hashPos charPos short | |
142 |
142 |
143 hash := ByteArray new: 20. |
143 hash := ByteArray new: 20. |
144 hashPos := 1. |
144 hashPos := 1. |
|
145 charPos := 0. |
145 short := true. |
146 short := true. |
146 revno := 0. |
147 revno := 0. |
147 |
148 |
148 stream := aStringOrStream readStream. |
149 stream := aStringOrStream readStream. |
149 stream peek == $- ifTrue:[ |
150 stream peek == $- ifTrue:[ |
166 hash at:hashPos put: (c1 digitValue << 4) | c2 digitValue. |
167 hash at:hashPos put: (c1 digitValue << 4) | c2 digitValue. |
167 hashPos := hashPos + 1. |
168 hashPos := hashPos + 1. |
168 c1 := c2 := nil. |
169 c1 := c2 := nil. |
169 ]. |
170 ]. |
170 stream next. |
171 stream next. |
|
172 charPos := charPos + 1. |
171 ]. |
173 ]. |
172 revno := revno * sign. |
174 revno := revno * sign. |
173 (stream atEnd or:[stream peek isSeparator]) ifTrue:[ |
175 stream atEnd ifTrue:[ |
|
176 "/ We might have read revno or a short hash that by chance |
|
177 "/ consist of only digits and not leading with 0. In this case |
|
178 "/ we actually cannot distinguish. |
|
179 "/ In case we have read less than 12 characters (size of a short id), |
|
180 "/ treat it as revno. A conservative guess... |
|
181 charPos < 12 ifTrue:[ |
|
182 ^(HGChangesetId new: 0) |
|
183 revno: revno; |
|
184 yourself |
|
185 ] |
|
186 ]. |
|
187 (stream atEnd not and:[stream peek isSeparator]) ifTrue:[ |
174 ^(HGChangesetId new: 0) |
188 ^(HGChangesetId new: 0) |
175 revno: revno; |
189 revno: revno; |
176 yourself |
190 yourself |
177 ]. |
191 ]. |
178 stream peek == $: ifTrue:[ |
192 stream peek == $: ifTrue:[ |
255 HGNodeId fromString:'4:6f88e1f44d9eb86e0b56ca15e30e5d786acd' |
269 HGNodeId fromString:'4:6f88e1f44d9eb86e0b56ca15e30e5d786acd' |
256 HGNodeId fromString:'4:6f88Z1f44d9eb86e0b56ca15e30e5d786acd83c7' |
270 HGNodeId fromString:'4:6f88Z1f44d9eb86e0b56ca15e30e5d786acd83c7' |
257 " |
271 " |
258 |
272 |
259 "Created: / 13-11-2012 / 16:49:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
273 "Created: / 13-11-2012 / 16:49:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
260 "Modified: / 22-01-2013 / 12:00:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
274 "Modified: / 13-07-2016 / 18:15:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
261 ! ! |
275 ! ! |
262 |
276 |
263 !HGChangesetId class methodsFor:'accessing'! |
277 !HGChangesetId class methodsFor:'accessing'! |
264 |
278 |
265 null |
279 null |