]> khamidou — GitHub mirrors - arcanist.git/commitdiff
fix 'arc feature' not creating bookmarks on mercurial
authordurham <durham@fb.com>
Thu, 21 Feb 2013 04:06:16 +0000 (20:06 -0800)
committerdurham <durham@fb.com>
Thu, 21 Feb 2013 04:06:16 +0000 (20:06 -0800)
Summary:
The arc feature command wasn't actually creating bookmarks
on mercurial. It needs to call 'hg bookmark' instead of 'hg update'

Also removed an unnecessary hgsprintf since there were no arguments.

Test Plan:
Ran 'arc feature foo' and 'arc feature bar tip^'.
The former created a bookmark at my current location.
The latter created a bookmark at tip^ and moved me to that revision.

Reviewers: vrana, epriestley

Reviewed By: epriestley

CC: sid0, bos, dschleimer, aran, Korvin
Differential Revision: https://secure.phabricator.com/D5023

src/workflow/ArcanistFeatureWorkflow.php

index 927dd454e4dd4ce92a82e6c0369bde15e9aedb9c..2d8a0800591de0abb99c0ad791b18e55360da9c4 100644 (file)
@@ -105,9 +105,14 @@ EOTEXT
       $command = 'checkout %s';
     }
 
-    list($err, $stdout, $stderr) = $api->execManualLocal(
-      $command,
-      reset($names));
+    $err = 1;
+
+    $branches = $api->getAllBranches();
+    if (in_array(reset($names), ipull($branches, 'name'))) {
+      list($err, $stdout, $stderr) = $api->execManualLocal(
+        $command,
+        reset($names));
+    }
 
     if ($err) {
       $match = null;
@@ -134,13 +139,17 @@ EOTEXT
       if ($api instanceof ArcanistMercurialAPI) {
         $rev = '';
         if (isset($names[1])) {
-          $rev = csprintf('-r %s', hgsprintf($names[1]));
+          $rev = csprintf('-r %s', $names[1]);
         }
+
         $exec = $api->execManualLocal(
-          'update %C %s',
+          'bookmark %C %s',
           $rev,
           $names[0]);
 
+        if (!$exec[0] && isset($names[1])) {
+          $api->execxLocal('update %s', $names[0]);
+        }
       } else {
         $exec = $api->execManualLocal(
           'checkout -b %Ls',