--- a/mercurial/HGCommandParser.st Tue Nov 27 18:20:56 2012 +0000
+++ b/mercurial/HGCommandParser.st Tue Nov 27 21:00:31 2012 +0000
@@ -63,6 +63,51 @@
!HGCommandParser methodsFor:'parsing'!
+parseBranches
+ "Parse output of 'hg branches' command. Return collection
+ of orphaned HGBranch"
+
+ | branches |
+
+ branches := OrderedCollection new.
+ [ stream atEnd ] whileFalse:[
+ branches add: self parseBranchesEntry
+ ].
+ ^branches
+
+ "Created: / 27-11-2012 / 20:20:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parseBranchesEntry
+ | branch |
+
+ branch := HGBranch new.
+ branch setName: self parseName.
+
+ stream skipSeparators.
+ self parseNodeId.
+ stream peek == Character space ifTrue:[
+ stream next.
+ stream peek == $( ifFalse:[self error:'''('' expected but ''' , stream peek , ''' found'].
+ stream next.
+ stream peek == $i ifTrue:[
+ self expect:'inactive)'.
+ branch setActive: false.
+ ] ifFalse:[
+ stream peek == $c ifTrue:[
+ self expect:'closed)'.
+ branch setClosed: true.
+ ] ifFalse:[
+ self error:'Unexpected branch attribute (only ''closed'' and ''inactive'' supported)'''
+ ]
+ ].
+ ].
+ self expectLineEnd.
+ ^branch
+
+ "Created: / 27-11-2012 / 19:23:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
parseDate
| ts |
ts := Timestamp readIso8601FormatFrom:stream.
@@ -117,11 +162,12 @@
"Parse single revision entry, assuming the template given
was HGCommandParser templateLog. Return a HGRevision."
- | rev line message |
+ | rev branches line message |
rev := HGChangeset new.
rev setId: self parseNodeId. self expectLineEnd.
- rev setBranch: self nextLine.
+ branches := self parseNameList. self expectLineEnd.
+ rev setBranches: branches.
rev setParent1Id: self parseNodeId. self expectSpace.
rev setParent2Id: self parseNodeId. self expectSpace. self expectLineEnd.
rev setAuthor: self nextLine.
@@ -139,7 +185,33 @@
^rev
"Created: / 13-11-2012 / 09:45:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 21-11-2012 / 18:08:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 27-11-2012 / 20:32:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parseName
+ ^String streamContents:[:out|
+ [ stream peek isSeparator ] whileFalse:[
+ out nextPut:stream next
+ ]
+ ].
+
+ "Created: / 27-11-2012 / 20:21:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parseNameList
+ | list |
+
+ stream atEnd ifTrue:[ ^#() ].
+ stream peek isSeparator ifTrue:[ ^#() ].
+ list := OrderedCollection new.
+ list add: self parseName.
+ [ stream atEnd not and:[stream peek == Character space]] whileTrue:[
+ stream next. "/eat space.
+ list add: self parseName.
+ ].
+ ^list.
+
+ "Created: / 27-11-2012 / 20:30:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
parseNodeId
@@ -166,6 +238,16 @@
!HGCommandParser methodsFor:'parsing - commands'!
+parseCommandBranches
+ "Parse output of 'hg branches' command. Return collection
+ of orphaned HGBranch"
+
+ ^self parseBranches
+
+ "Created: / 27-11-2012 / 19:16:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 27-11-2012 / 20:21:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
parseCommandLocate
"Filenames are 0-byte separated. Yeah, Mercurial is easy
to parse"