--- a/mercurial/HGCommand.st Sat Nov 17 20:20:35 2012 +0000
+++ b/mercurial/HGCommand.st Mon Nov 19 21:57:45 2012 +0000
@@ -2,7 +2,7 @@
Object subclass:#HGCommand
instanceVariableNames:'workingDirectory'
- classVariableNames:'HGExecutable Debugging'
+ classVariableNames:'HGExecutable HGVersion Debugging'
poolDictionaries:''
category:'SCM-Mercurial-Internal'
!
@@ -84,6 +84,13 @@
privateIn:HGCommand
!
+HGCommand subclass:#version
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:HGCommand
+!
+
!HGCommand class methodsFor:'documentation'!
documentation
@@ -122,6 +129,94 @@
!HGCommand class methodsFor:'accessing'!
+hgCommand
+ | h |
+
+ HGExecutable notNil ifTrue:[
+ ^ HGExecutable
+ ].
+ HGExecutable := UserPreferences current hgExecutable.
+ HGExecutable isNil ifTrue:[
+ OperatingSystem isMSWINDOWSlike ifTrue:[
+ "/ h := Win32OperatingSystem registryEntry
+ "/ key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\svn.exe'.
+ "/ h notNil ifTrue:[HGExecutable := h valueNamed:''].
+ "/ HGExecutable notEmptyOrNil ifTrue:[^HGExecutable]
+ HGExecutable := OperatingSystem pathOfCommand:'hg'.
+ ] ifFalse:[
+ OperatingSystem isUNIXlike ifTrue:[
+ HGExecutable := OperatingSystem pathOfCommand:'hg'.
+ ]
+ ].
+ ].
+ HGExecutable isNil ifTrue:[
+ self error:'''hg'' executable not found!!'.
+ ].
+ ^ HGExecutable
+
+ "
+ HGExecutable := nil.
+ self basicNew executable"
+
+ "Created: / 19-11-2012 / 21:48:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+hgCommand: command
+ HGExecutable := command
+
+ "Created: / 19-11-2012 / 21:49:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+hgVersion
+ "Return mercurial version installed on this compiter"
+
+ HGVersion isNil ifTrue:[
+ HGVersion := version new execute
+ ].
+ ^ HGVersion
+
+ "
+ HGCommand mercurialVersion"
+ "Created: / 19-11-2012 / 20:14:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+hgVersionIsSupported
+ ^ self hgVersionIsSupported:self hgVersion
+
+ "
+ HGCommand mercurialVersionIsSupported"
+ "Created: / 19-11-2012 / 20:34:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+hgVersionIsSupported:version
+ ^ self hgVersionsSupported
+ anySatisfy:[:vsn |
+ ((vsn at:1) == #'*' or:[ (vsn at:1) == (version at:1) ])
+ and:[
+ ((vsn at:2) == #'*' or:[ (vsn at:2) == (version at:2) ])
+ and:[ ((vsn at:3) == #'*' or:[ (vsn at:1) == (version at:3) ]) ]
+ ]
+ ].
+
+ "
+ HGCommand mercurialVersionIsSupported: #(2 3 2)
+ HGCommand mercurialVersionIsSupported: #(2 0 1)
+ HGCommand mercurialVersionIsSupported: #(1 9 1)
+ HGCommand mercurialVersionIsSupported: #(1 0 0)
+ HGCommand mercurialVersionIsSupported: #(2 4 nil)"
+ "Created: / 19-11-2012 / 20:31:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+hgVersionsSupported
+ "Return a list of mercurial version supported bu this
+ implementation"
+
+ ^ #( #(1 9 #'*')
+ #(2 #'*' #'*') )
+
+ "Created: / 19-11-2012 / 20:26:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
verbose
^ UserPreferences current hgVerbose
@@ -351,36 +446,9 @@
!
executable
- | h |
-
- HGExecutable notNil ifTrue:[^ HGExecutable].
-
- OperatingSystem isMSWINDOWSlike ifTrue:[
-"/ h := Win32OperatingSystem registryEntry
-"/ key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\svn.exe'.
-"/ h notNil ifTrue:[HGExecutable := h valueNamed:''].
-"/ HGExecutable notEmptyOrNil ifTrue:[^HGExecutable]
- HGExecutable := OperatingSystem pathOfCommand:'hg'.
- ] ifFalse:[
- OperatingSystem isUNIXlike ifTrue:[
- HGExecutable := OperatingSystem pathOfCommand:'hg'.
- ]].
+ ^ self class hgCommand
- HGExecutable isNil ifTrue:[
- self error:'''hg'' executable not found!!'.
- ].
- ^ HGExecutable
-
-
- "
- HGExecutable := nil.
- self basicNew executable
- "
-
- "Created: / 11-05-2011 / 07:59:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 09-12-2011 / 22:48:33 / dundee"
- "Modified (format): / 27-12-2011 / 15:51:06 / dundee"
- "Modified: / 17-11-2012 / 11:37:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-11-2012 / 21:48:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
parse: stream
@@ -863,6 +931,24 @@
"Modified: / 23-10-2012 / 11:07:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!HGCommand::version methodsFor:'private'!
+
+arguments
+
+ ^ Array with: HGExecutable with: '--version'
+
+ "Created: / 19-11-2012 / 20:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parse: stream
+ "Parses output of 'hg' command, i.e. commit, log, update, checkout,
+ etc."
+
+ ^(HGCommandParser on: stream) parseCommandVersion
+
+ "Created: / 19-11-2012 / 20:02:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!HGCommand class methodsFor:'documentation'!
version_HG