Allow to use hg.bat as Mercurial executable on Windows.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 26 Jun 2014 01:13:28 +0200
changeset 437 fa687128ae25
parent 436 58c7b3b23cd2
child 438 5b8836e39cbc
Allow to use hg.bat as Mercurial executable on Windows. This is usefull when one needs to wrap hg command or uses a hand-compiled Mercurial from sources under Windows.
mercurial/HGCommand.st
--- a/mercurial/HGCommand.st	Tue May 27 16:22:31 2014 +0100
+++ b/mercurial/HGCommand.st	Thu Jun 26 01:13:28 2014 +0200
@@ -672,7 +672,7 @@
 !HGCommand methodsFor:'executing'!
 
 execute
-    | stdoutPipe stdout stderrPipe stderr pid environment status args spin |
+    | stdoutPipe stdout stderrPipe stderr pid environment status exe args spin |
 
     self initialize.
 
@@ -689,8 +689,17 @@
     environment at:'LANG' put:'C'.
     environment at:'LC_MESSAGES' put:'C'.
 
+	exe := self executable.
     args := self arguments.
+	
     OperatingSystem isMSWINDOWSlike ifTrue:[
+	    (exe endsWith:'.bat') ifTrue:[
+            | cmd |
+            cmd := OperatingSystem pathOfCommand:'cmd'.
+            args := #( '/C' ) , args.
+            exe := cmd.
+
+        ].   
         args := String streamContents:[:s|
             args
                 do:[:each | s nextPut:$"; nextPutAll: each; nextPut: $"]
@@ -703,7 +712,7 @@
         Trace ifTrue:[
             Logger log: 'cmd: executing: ' , (args isString ifTrue:[args] ifFalse:[args asStringWith:' ']) severity: #trace facility: 'HG'.
         ].
-        pid := OperatingSystem exec:(self executable) withArguments:args
+        pid := OperatingSystem exec: exe withArguments:args
             environment:environment
             fileDescriptors:{0 . stdoutPipe second fileDescriptor . stderrPipe second fileDescriptor}
             fork:true