Added children support to changesets.
HGChangeset>>children returns all child changesets of given one.
This can be used to figure out newer changesets.
"{ Package: 'stx:libscm/mercurial' }"
HGRepositoryObject subclass:#HGChangeset
instanceVariableNames:'id branches author timestamp message parent1 parent2 children
root'
classVariableNames:''
poolDictionaries:''
category:'SCM-Mercurial-Core'
!
!HGChangeset class methodsFor:'documentation'!
documentation
"
A HGChangeset represent one changeset in Mercurial repository.
[author:]
Jan Vrany <jan.vrany@fit.cvut.cz>
[instance variables:]
[class variables:]
[see also:]
http://mercurial.selenic.com/wiki/UnderstandingMercurial
"
! !
!HGChangeset class methodsFor:'instance creation'!
new
"return an initialized instance"
^ self basicNew initialize.
! !
!HGChangeset methodsFor:'accessing'!
/ name
"Return an HGChangesetFile representing a file
(in root of the directory)"
^self construct: name
"Created: / 16-11-2012 / 22:24:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
author
^ author
!
branch
"Return branch (as HGBranch) in which this changeset is commited. It the changeset is commited in
multiple branches, raise an error"
branches size ~~ 1 ifTrue:[
HGError
raiseSignalWith: self
errorString:('Changeset %1 commited in more than one branch' bindWith: id)
].
^self branches anElement
"Created: / 27-11-2012 / 20:49:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
branches
"Return list of branches (as HGBranch) in which this changeset is commited"
(branches anySatisfy:[:b|b isString]) ifTrue:[
| all |
all := repository branches.
branches := branches collect:[:nm|all detect:[:b|b name = nm] ifNone:[HGNoSuchBranchError raiseSignalWith: nm errorString:'No such branch: ', nm]]
].
^branches.
"Created: / 27-11-2012 / 20:40:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
children
1 to: children size do:[:i|
(children at:i) class == HGChangesetId ifTrue:[
children at:i put: (repository changesetWithId: (children at:i))
].
].
^children.
"Created: / 05-12-2012 / 17:31:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
construct: name
"Return an HGChangesetFile representing a file
(in root of the directory)"
^self root construct: name
"Created: / 16-11-2012 / 22:25:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
id
^ id
!
message
^ message
!
parent1
parent1 class == HGChangesetId ifTrue:[
parent1 := repository changesetWithId: parent1
].
^parent1
"Modified: / 13-11-2012 / 18:04:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
parent2
parent2 class == HGChangesetId ifTrue:[
parent2 := repository changesetWithId: parent2
].
^parent2
"Modified: / 13-11-2012 / 18:05:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
root
"Return an HGChangesetFile represening the root of
the changeset,i.e, root of the directory tree
represented by given changeset"
| filenames |
root notNil ifTrue:[ ^ root ].
filenames := HGCommand locate
workingDirectory: repository pathName;
revision: id revno;
execute.
root := HGChangesetFile new setChangeset: self name: ''.
filenames do:[:each|root create: each].
^root.
"Created: / 16-11-2012 / 22:26:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 30-11-2012 / 23:35:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
timestamp
^ timestamp
! !
!HGChangeset methodsFor:'initialization'!
initialize
"Invoked when a new instance is created."
"/ please change as required (and remove this comment)
"/ id := nil.
"/ user := nil.
"/ timestamp := nil.
"/ files := nil.
"/ message := nil.
"/ super initialize. -- commented since inherited method does nothing
"Modified: / 19-10-2012 / 16:08:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setAuthor: aString
author := aString
"Created: / 13-11-2012 / 10:23:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 13-11-2012 / 17:30:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setBranches: aCollection
branches := aCollection.
"Created: / 27-11-2012 / 20:25:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setChildren: aCollection
children := aCollection
"Created: / 05-12-2012 / 17:32:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setId: anHGNodeId
id := anHGNodeId
"Created: / 13-11-2012 / 10:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setMessage: aString
message := aString
"Created: / 13-11-2012 / 10:23:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setParent1Id: anHGNodeId
anHGNodeId ~~ HGChangesetId null ifTrue:[
parent1 := anHGNodeId
]
"Created: / 13-11-2012 / 10:23:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 13-11-2012 / 18:05:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setParent2Id: anHGNodeId
anHGNodeId ~~ HGChangesetId null ifTrue:[
parent2 := anHGNodeId
]
"Created: / 13-11-2012 / 10:23:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 13-11-2012 / 18:05:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setTimestamp: aTimestamp
timestamp := aTimestamp
"Created: / 13-11-2012 / 17:24:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGChangeset methodsFor:'printing & storing'!
printOn:aStream
"append a printed representation if the receiver to the argument, aStream"
super printOn:aStream.
aStream nextPutAll:'('.
id printOn:aStream.
aStream nextPutAll:')'.
"Modified: / 27-11-2012 / 21:36:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGChangeset class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
!
version_SVN
^ '§Id:: §'
! !