"{ Package: 'stx:libscm/mercurial' }"
ByteArray variableByteSubclass:#HGNodeId
instanceVariableNames:'revno'
classVariableNames:'NullId'
poolDictionaries:''
category:'SCM-Mercurial-Core'
!
!HGNodeId class methodsFor:'instance creation'!
fromBytes: aByteArrayOrString
^self new replaceBytesFrom: 1 to: 20 with: aByteArrayOrString startingAt: 1
"Created: / 25-09-2012 / 21:00:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
fromString: aString
"/ | oid |
"/
"/ oid := self new.
"/ GitPrimitives prim_git_oid_fromstr: oid str: aString.
"/ ^oid.
| sz oid s hi lo |
sz := aString size.
sz ~~ 40 ifTrue:[
self error:'Not a SHA-1 hex string (must have 40 chars)'.
^nil
].
oid := self new.
s := aString readStream.
1 to: 20 do: [ :idx |
hi := s next digitValue.
lo := s next digitValue.
oid at:idx put: ((hi bitShift:4) bitOr: lo)
].
^ oid
"
GitOid fromString: '7164acf359f5da8a4bc9cd3e03e2e461013c3811'
"
"Created: / 10-09-2012 / 10:49:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
new
^self new: 20
"Created: / 10-09-2012 / 10:42:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 19-10-2012 / 15:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
new: size
size ~~ 20 ifTrue:[
self error: 'Size of HGNodeId must be exactly 20 bytes, its a SHA-1 hash'.
^nil.
].
^super new: size
"Created: / 10-09-2012 / 10:44:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 19-10-2012 / 15:52:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGNodeId class methodsFor:'accessing'!
null
NullId isNil ifTrue:[
NullId := self new.
NullId revno: -1
].
^NullId
"
HGNodeId null
"
"Created: / 19-10-2012 / 15:51:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (comment): / 13-11-2012 / 09:54:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGNodeId methodsFor:'accessing'!
revno
^ revno ? -2
"Created: / 13-11-2012 / 09:52:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
revno:anInteger
revno := anInteger.
! !
!HGNodeId methodsFor:'printing & storing'!
displayOn:aStream
^self printOn: aStream
"Created: / 13-11-2012 / 09:55:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
printOn:aStream
"append a printed representation if the receiver to the argument, aStream"
| rn |
rn := self revno.
rn == -2 ifTrue:[
aStream nextPut:$?.
] ifFalse:[
rn printOn: aStream.
].
aStream nextPut: $:.
self hexPrintOn:aStream.
"Modified: / 13-11-2012 / 09:52:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGNodeId class methodsFor:'documentation'!
version_SVN
^ '$Id:: $'
! !