]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make arc patch be less ROFL for mercurial
authorBob Trahan <bob.trahan@gmail.com>
Tue, 17 Jan 2012 01:12:34 +0000 (17:12 -0800)
committerBob Trahan <bob.trahan@gmail.com>
Tue, 17 Jan 2012 17:40:43 +0000 (09:40 -0800)
Summary:
pretty easy stuff as mercurial accepts git style patches...!

also fixed two issues where we were 1) storing the short hash and 2) storing it
with a trailing "\n".  This diff makes us store the full hash AND no trailing
return character

Test Plan:
in my mercurial repo
<note repo at revision $foo>
<did something dumb>
hg commit -m "something dumb"
arc diff
<go to web and fill out stuff for DX>
hg checkout $foo
arc patch DX
<verify patch DX successfully applied!>

use conduit console to verify a few diffs were returning the correct full
revision hash with a trailing \n

Reviewers: epriestley

Reviewed By: epriestley

CC: aran
Maniphest Tasks: T630

Differential Revision: https://secure.phabricator.com/D1431

src/repository/api/mercurial/ArcanistMercurialAPI.php
src/workflow/patch/ArcanistPatchWorkflow.php

index fd893b4210ae602f085f9fd9e7e8994e43a4d06f..4968a56d3e3931656d6183ef13cd055309703e73 100644 (file)
@@ -33,10 +33,11 @@ class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
 
   public function getSourceControlBaseRevision() {
     list($stdout) = execx(
-      '(cd %s && hg id -ir %s)',
+      '(cd %s && hg log -l 1 --template %s -r %s)',
       $this->getPath(),
+      '{node}\\n',
       $this->getRelativeCommit());
-    return $stdout;
+    return rtrim($stdout, "\n");
   }
 
   public function getSourceControlPath() {
index eaaa100f88fee8bdf0dc7abd53a1a68fe9e42fe9..76cd249e887b26712224df149cc895af84065913 100644 (file)
@@ -403,7 +403,7 @@ EOTEXT
       }
 
       return $patch_err;
-    } else {
+    } else if ($repository_api instanceof ArcanistGitAPI) {
       $future = new ExecFuture(
         '(cd %s; git apply --index --reject)',
         $repository_api->getPath());
@@ -412,6 +412,17 @@ EOTEXT
 
       echo phutil_console_format(
         "<bg:green>** OKAY **</bg> Successfully applied patch.\n");
+    } else if ($repository_api instanceof ArcanistMercurialAPI) {
+      $future = new ExecFuture(
+        '(cd %s; hg import --no-commit -)',
+        $repository_api->getPath());
+      $future->write($bundle->toGitPatch());
+      $future->resolvex();
+
+      echo phutil_console_format(
+        "<bg:green>** OKAY **</bg> Successfully applied patch.\n");
+    } else {
+      throw new Exception('Unknown version control system.');
     }
 
     return 0;