772 ifFalse:[environment := Dictionary new]. |
772 ifFalse:[environment := Dictionary new]. |
773 environment at: 'HGEDITOR' put: 'true'. |
773 environment at: 'HGEDITOR' put: 'true'. |
774 environment at:'LANG' put:'C'. |
774 environment at:'LANG' put:'C'. |
775 environment at:'LC_MESSAGES' put:'C'. |
775 environment at:'LC_MESSAGES' put:'C'. |
776 |
776 |
777 exe := self executable. |
777 exe := self executable. |
778 args := self arguments. |
778 args := self arguments. |
779 |
779 |
780 OperatingSystem isMSWINDOWSlike ifTrue:[ |
780 OperatingSystem isMSWINDOWSlike ifTrue:[ |
781 (exe endsWith:'.bat') ifTrue:[ |
781 (exe endsWith:'.bat') ifTrue:[ |
782 | cmd | |
782 | cmd | |
783 cmd := OperatingSystem pathOfCommand:'cmd'. |
783 cmd := OperatingSystem pathOfCommand:'cmd'. |
784 args := #( '/C' ) , args. |
784 args := #( '/C' ) , args. |
785 exe := cmd. |
785 exe := cmd. |
786 |
|
787 ]. |
786 ]. |
788 args := String streamContents:[:s| |
787 args := String streamContents:[:s| |
789 args |
788 args |
790 do:[:each | s nextPut:$"; nextPutAll: each; nextPut: $"] |
789 do:[:each | self quoteShellCommandParameter: each asForCmdOn: s ] |
791 separatedBy: [ s space ] |
790 separatedBy: [ s space ] |
792 ] |
791 ] |
793 ]. |
792 ]. |
794 |
793 |
795 |
794 |
874 workingDirectory := anHGRepository pathName |
873 workingDirectory := anHGRepository pathName |
875 ]. |
874 ]. |
876 ^self execute. |
875 ^self execute. |
877 |
876 |
878 "Created: / 03-03-2013 / 20:34:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
877 "Created: / 03-03-2013 / 20:34:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
878 ! |
|
879 |
|
880 quoteShellCommandParameter: parameter asForCmdOn: stream |
|
881 "Quotes the parameter as neccesary on Windows" |
|
882 |
|
883 "/ Adapted version of ArgvQuote, |
|
884 "/ see http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx |
|
885 |
|
886 | parameterS | |
|
887 |
|
888 stream nextPut: $". |
|
889 parameterS := parameter readStream. |
|
890 [ parameterS atEnd ] whileFalse:[ |
|
891 | numBackSlashes | |
|
892 |
|
893 numBackSlashes := 0. |
|
894 |
|
895 [ parameterS atEnd not and:[ parameterS peek == $\ ] ] whileTrue:[ |
|
896 numBackSlashes := numBackSlashes + 1. |
|
897 parameterS next. |
|
898 ]. |
|
899 parameterS atEnd ifTrue:[ |
|
900 "/ Escape all backslashes, but let the terminating |
|
901 "/ double quotation mark we add below be interpreted |
|
902 "/ as a metacharacter. |
|
903 stream next: numBackSlashes * 2 put: $\ |
|
904 ] ifFalse:[ |
|
905 parameterS peek == $" ifTrue:[ |
|
906 "/ Escape all backslashes and the following |
|
907 "/ double quotation mark. |
|
908 stream next: numBackSlashes * 2 put: $\. |
|
909 stream nextPut: $\. |
|
910 stream nextPut: $". |
|
911 ] ifFalse:[ |
|
912 "/ Backslashes aren't special here. |
|
913 stream next: numBackSlashes put: $\. |
|
914 stream nextPut: parameterS peek. |
|
915 ]. |
|
916 parameterS next. |
|
917 ]. |
|
918 ]. |
|
919 stream nextPut: $". |
879 ! ! |
920 ! ! |
880 |
921 |
881 !HGCommand methodsFor:'initialization'! |
922 !HGCommand methodsFor:'initialization'! |
882 |
923 |
883 initialize |
924 initialize |