Issue 256: fix parsing branch name from changelog
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 08 Jan 2019 09:35:11 +0000
changeset 866 8a885a75daa9
parent 865 c2e908e7dadc
child 867 7527dc6bc38e
Issue 256: fix parsing branch name from changelog To retrieve a branch of an changeset, `stx:libscm` uses `{branch}` branch keyword and then parses it as "name list". However, according to documentation it is a single string: branch String. The name of the branch on which the changeset was committed. This obviously caused problems when branch name had spaces in it. This commit fixes the problem. One remaining thing is that `stx:libscm` technically allows a changeset to be in more than one branch which seems to be impossible in Mercurial itself. This should be investigated and fixed, eventually.
mercurial/HGCommandParser.st
mercurial/HGTests.st
--- a/mercurial/HGCommandParser.st	Thu Jan 10 21:25:14 2019 +0000
+++ b/mercurial/HGCommandParser.st	Tue Jan 08 09:35:11 2019 +0000
@@ -392,7 +392,7 @@
 
     rev := HGChangeset new.
     rev setId: self parseNodeId. self expectLineEnd.
-    branches := self parseNameList. self expectLineEnd.
+    branches := Array with: stream nextLine.
     rev setBranches: branches.
     rev setParent1Id: self parseNodeId. self expectSpace.
     rev setParent2Id: self parseNodeId. self expectSpace. self expectLineEnd.
@@ -430,7 +430,7 @@
     ^rev
 
     "Created: / 13-11-2012 / 09:45:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 19-03-2014 / 23:23:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-01-2019 / 22:51:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 parseMergeLocalChanged: info
--- a/mercurial/HGTests.st	Thu Jan 10 21:25:14 2019 +0000
+++ b/mercurial/HGTests.st	Tue Jan 08 09:35:11 2019 +0000
@@ -453,6 +453,32 @@
     self assert: branches anElement name = 'default'
 
     "Created: / 14-01-2013 / 14:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_branches_issue256a
+    "
+    Change branch with spaces & commit. Check whether commited changeset
+    has the branch set.
+    "
+
+    | repo wc |
+
+    repo := self repositoryNamed:'test_repo_01'.
+    wc := repo workingCopy.
+    self assert: repo branches size == 1.
+    wc branch: 'test branches issue256a'.
+
+    "Modify some file"
+    (wc / 'f1.txt') writingFileDo:[:s | s nextPutAll:'modified...' ].
+    wc commit: testSelector , ' - commit 01'.
+
+    self assert: wc changeset branches size == 1.
+    self assert: wc changeset branches anElement name = 'test branches issue256a'.
+    self assert: repo branches size == 2.
+    self assert:(repo branches contains: [:b|b name = 'default']).
+    self assert:(repo branches contains: [:b|b name = 'test branches issue256a']).
+
+    "Created: / 07-01-2019 / 22:42:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGTests methodsFor:'tests - changesets'!