]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Use phutil_passthru() in "arc commit" instead of passthru().
authorepriestley <git@epriestley.com>
Wed, 18 May 2011 17:32:00 +0000 (10:32 -0700)
committerepriestley <git@epriestley.com>
Thu, 19 May 2011 17:19:01 +0000 (10:19 -0700)
Summary:
passthru() doesn't show up on --trace, and one time a while ago someone had an
issue which was harder than necessary to debug because the command wasn't
avialable in the log. Use the logged version.

Also fix a locale issue I ran into on my local machine, with "en_US.utf8" not
being a valid locale.

Test Plan:
Created an SVN repo and used "arc commit" to make commits against it.

Reviewed By: jungejason
Reviewers: jungejason, tuomaspelkonen, aran
CC: aran, epriestley, jungejason
Differential Revision: 306

src/workflow/commit/ArcanistCommitWorkflow.php
src/workflow/commit/__init__.php

index 348d47eccf6c49a497e632aaf4c9e489942d612d..e455f1c16d4200a7e6222a5f60ac4d8614117fd7 100644 (file)
@@ -116,13 +116,14 @@ EOTEXT
     $message = escapeshellarg($message);
     $root = escapeshellarg($repository_api->getPath());
 
+    $lang = $this->getSVNLangEnvVar();
+
     // Specify LANG explicitly so that UTF-8 commit messages don't break
     // subversion.
     $command =
-      "(cd {$root} && LANG=en_US.utf8 svn commit {$files} -m {$message})";
+      "(cd {$root} && LANG={$lang} svn commit {$files} -m {$message})";
 
-    $err = null;
-    passthru($command, $err);
+    $err = phutil_passthru('%C', $command);
 
     if ($err) {
       throw new Exception("Executing 'svn commit' failed!");
@@ -258,4 +259,29 @@ EOTEXT
     return array('svn');
   }
 
+  /**
+   * On some systems, we need to specify "en_US.UTF-8" instead of "en_US.utf8",
+   * and SVN spews some bewildering warnings if we don't:
+   *
+   *   svn: warning: cannot set LC_CTYPE locale
+   *   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.
+   */
+  private function getSVNLangEnvVar() {
+    $locale = 'en_US.utf8';
+    try {
+      list($locales) = execx('locale -a');
+      $locales = explode("\n", trim($locales));
+      $locales = array_fill_keys($locales, true);
+      if (isset($locales['en_US.UTF-8'])) {
+        $locale = 'en_US.UTF-8';
+      }
+    } catch (Exception $ex) {
+      // Ignore.
+    }
+    return $locale;
+  }
+
 }
index e325c8521dde19b056d58d82583579a76806dd34..a63499f835f293422661d6ea30cc50ca996cfe45 100644 (file)
@@ -13,6 +13,7 @@ phutil_require_module('arcanist', 'workflow/base');
 
 phutil_require_module('phutil', 'console');
 phutil_require_module('phutil', 'filesystem');
+phutil_require_module('phutil', 'future/exec');
 phutil_require_module('phutil', 'utils');