Fixed Mercurial version parsing
Non-release version of mercurial reports version in `hg --version` as
3.2.1+128-b913c394386f (when built from arbitrary commit) or
2.9+20140204 when built from exported sources.
--- a/mercurial/HGCommandParser.st Mon Dec 01 00:31:47 2014 +0000
+++ b/mercurial/HGCommandParser.st Mon Dec 01 20:30:53 2014 +0000
@@ -1094,12 +1094,14 @@
revision := self parseInteger.
].
- self skipSeparators.
- self expect:$).
+ (stream peek ~~ $) and:[ stream peek ~~ $+]) ifTrue:[
+ self error: ('Expected ''$)'' or ''+'' got ''%2''.' bindWith: stream peek).
+ ].
^(Array with: major with: minor with: revision)
"Created: / 19-11-2012 / 20:19:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 01-12-2014 / 20:25:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGCommandParser methodsFor:'parsing - errors'!
--- a/mercurial/HGCommandParserTests.st Mon Dec 01 00:31:47 2014 +0000
+++ b/mercurial/HGCommandParserTests.st Mon Dec 01 20:30:53 2014 +0000
@@ -949,6 +949,40 @@
self assert: vsn = #(2 4 nil)
"Created: / 19-11-2012 / 21:00:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_version_2_9_20140204
+
+ | vsn |
+
+ vsn := (HGCommandParser on: 'Mercurial Distributed SCM (version 2.9+20140204)
+(see http://mercurial.selenic.com for more information)
+
+Copyright (C) 2005-2014 Matt Mackall and others
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+') parseCommandVersion.
+
+ self assert: vsn = #(2 9 nil)
+
+ "Created: / 01-12-2014 / 20:16:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_version_3_2_1_128_b913c394386f
+
+ | vsn |
+
+ vsn := (HGCommandParser on: 'Mercurial Distributed SCM (version 3.2.1+128-b913c394386f)
+(see http://mercurial.selenic.com for more information)
+
+Copyright (C) 2005-2014 Matt Mackall and others
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+') parseCommandVersion.
+
+ self assert: vsn = #(3 2 1)
+
+ "Created: / 01-12-2014 / 20:13:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGCommandParserTests methodsFor:'tests - shell'!