From 383fb42ba8ca872e42013a0e36c8ad633ce41964 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 3 Oct 2012 14:54:43 -0700 Subject: [PATCH] make arc commit work on windows with multiline messages Summary: cd && cmd won't work so use chdir; -m $multiline_message won't work so use -F $tmp_file Test Plan: this is actually un-tested at the moment. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1617 Differential Revision: https://secure.phabricator.com/D3592 --- src/workflow/ArcanistCommitWorkflow.php | 31 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/workflow/ArcanistCommitWorkflow.php b/src/workflow/ArcanistCommitWorkflow.php index 8fce0a97..85e18fc3 100644 --- a/src/workflow/ArcanistCommitWorkflow.php +++ b/src/workflow/ArcanistCommitWorkflow.php @@ -153,17 +153,17 @@ EOTEXT $files = $this->getCommitFileList($revision); - $files = implode(' ', array_map('escapeshellarg', $files)); - $message = escapeshellarg($message); - $root = escapeshellarg($repository_api->getPath()); + $tmp_file = new TempFile(); + Filesystem::writeFile($tmp_file, $message); - $lang = $this->getSVNLangEnvVar(); + $command = $this->getSVNCommitCommand(); + chdir($repository_api->getPath()); - // Specify LANG explicitly so that UTF-8 commit messages don't break - // subversion. - $command = "(cd {$root} && LANG={$lang} svn commit {$files} -m {$message})"; - - $err = phutil_passthru('%C', $command); + $err = phutil_passthru( + $command, + $files, + $tmp_file + ); if ($err) { throw new Exception("Executing 'svn commit' failed!"); @@ -289,7 +289,8 @@ EOTEXT * svn: warning: environment variable LANG is en_US.utf8 * svn: warning: please check that your locale name is correct * - * For example, is happens on my 10.6.7 machine with Subversion 1.6.15. + * For example, it happens on epriestley's Mac (10.6.7) with + * Subversion 1.6.15. */ private function getSVNLangEnvVar() { $locale = 'en_US.utf8'; @@ -306,6 +307,16 @@ EOTEXT return $locale; } + private function getSVNCommitCommand() { + $command = 'svn commit %Ls --encoding utf-8 -F %s'; + // make sure to specify LANG on non-windows systems to surpress any fancy + // warnings; see @{method:getSVNLangEnvVar}. + if (!phutil_is_windows()) { + $command = 'LANG='.$this->getSVNLangEnvVar().' '.$command; + } + return $command; + } + private function runSanityChecks(array $revision) { $repository_api = $this->getRepositoryAPI(); $revision_id = $revision['id']; -- 2.43.0