--- a/mercurial/HGCommandParser.st Wed Dec 05 18:09:53 2012 +0000
+++ b/mercurial/HGCommandParser.st Wed Dec 05 19:05:06 2012 +0000
@@ -37,6 +37,10 @@
{branch}
{parents}
{children}
+{file_adds}
+{file_copies}
+{file_dels}
+{file_mods}
{author}
{date|isodate}
{desc}
@@ -44,7 +48,7 @@
'
"Created: / 12-11-2012 / 23:06:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 05-12-2012 / 17:21:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 05-12-2012 / 18:26:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGCommandParser methodsFor:'accessing'!
@@ -169,7 +173,7 @@
"Parse single revision entry, assuming the template given
was HGCommandParser templateLog. Return a HGRevision."
- | rev branches line message |
+ | rev branches line message adds copies deletions modifications |
rev := HGChangeset new.
rev setId: self parseNodeId. self expectLineEnd.
@@ -178,6 +182,23 @@
rev setParent1Id: self parseNodeId. self expectSpace.
rev setParent2Id: self parseNodeId. self expectSpace. self expectLineEnd.
rev setChildren: self parseNodeIdList. self expectLineEnd.
+
+ adds := self parsePathList. self expectLineEnd.
+ copies := self parsePathCopyList. self expectLineEnd.
+ deletions := self parsePathList. self expectLineEnd.
+ modifications := self parsePathList. self expectLineEnd.
+
+ copies pairsDo:[:dst :src|
+ adds remove: dst.
+ deletions remove: src.
+ ].
+
+ adds := adds collect:[:e|HGChange newAdded setChangeset: rev path: e].
+ copies := copies collect:[:e|HGChange newCopied setChangeset: rev path: e first; setSource: e second].
+ deletions := deletions collect:[:e|HGChange newRemoved setChangeset: rev path: e].
+ modifications := modifications collect:[:e|HGChange newModified setChangeset: rev path: e].
+
+ rev setChanges: modifications , adds , deletions , copies.
rev setAuthor: self nextLine.
rev setTimestamp: self parseDate. self expectLineEnd.
message := String streamContents:[:s|
@@ -193,7 +214,7 @@
^rev
"Created: / 13-11-2012 / 09:45:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 05-12-2012 / 17:32:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 05-12-2012 / 18:46:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
parseName
@@ -260,6 +281,66 @@
^ids
"Created: / 05-12-2012 / 17:24:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parsePath
+ "Parse single path entry from repository"
+
+ ^self parseName
+
+ "Created: / 05-12-2012 / 18:27:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parsePathCopy
+ "Parse single path entry from repository"
+
+ | dst src |
+
+ dst := self parseName.
+ self expectSpace.
+ self expect:$(.
+ src := String streamContents:[:out|
+ [ stream peek == $) ] whileFalse:[
+ out nextPut:stream next
+ ].
+ stream next.
+ ].
+
+ ^Array with: dst with: src
+
+ "Created: / 05-12-2012 / 18:38:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parsePathCopyList
+ | list |
+
+ stream atEnd ifTrue:[ ^#() ].
+ stream peek isSeparator ifTrue:[ ^#() ].
+ list := OrderedCollection new.
+ list add: self parsePathCopy.
+ [ stream atEnd not and:[stream peek == Character space]] whileTrue:[
+ stream next. "/eat space.
+ list add: self parsePathCopy.
+ ].
+ ^list.
+
+ "Created: / 05-12-2012 / 18:39:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parsePathList
+ | list |
+
+ stream atEnd ifTrue:[ ^#() ].
+ stream peek isSeparator ifTrue:[ ^#() ].
+ list := OrderedCollection new.
+ list add: self parsePath.
+ [ stream atEnd not and:[stream peek == Character space]] whileTrue:[
+ stream next. "/eat space.
+ list add: self parsePath.
+ ].
+ ^list.
+
+ "Created: / 05-12-2012 / 18:27:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGCommandParser methodsFor:'parsing - commands'!