]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Detect library conflicts in Arcanist and raise a very specific error message
authorepriestley <git@epriestley.com>
Thu, 19 May 2011 17:13:44 +0000 (10:13 -0700)
committerepriestley <git@epriestley.com>
Thu, 19 May 2011 18:32:53 +0000 (11:32 -0700)
Summary:
When you run one copy of arcanist against another copy, you previously got a
meaningless error. After D311 you get a slightly more meaningful error.

Capture the new exception and raise an extremely specific error.

NOTE: Adding arcanist to .arcconfig forces the library conflict error to
trigger; otherwise there's just an implicit conflict because 'arc' reads the
running-copy library amp instead of the working-copy library map. This only
worked before because arcanist includes itself.

Test Plan:
Ran arcanist on a different copy of arcanist, got a good error message.

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

.arcconfig
scripts/arcanist.php

index 417127e044aad473b1d96c02b66208d4b215e87c..de02caaaa28ac3993f02214813dd0ca34972f2b3 100644 (file)
@@ -4,5 +4,8 @@
   "lint_engine" : "PhutilLintEngine",
   "unit_engine" : "PhutilUnitTestEngine",
   "remote_hooks_installed" : true,
-  "copyright_holder" : "Facebook, Inc."
+  "copyright_holder" : "Facebook, Inc.",
+  "phutil_libraries" : {
+    "arcanist" : "src/"
+  }
 }
index 7eb37be33d5b39c2f781182569343423e9484c51..a67098dbbb11db762b36529665c6e8a24652e1de 100755 (executable)
@@ -100,6 +100,20 @@ try {
           $name,
           $location);
         throw new ArcanistUsageException($error_msg);
+      } catch (PhutilLibraryConflictException $ex) {
+        if ($ex->getLibrary() != 'arcanist') {
+          throw $ex;
+        }
+
+        $arc_dir = dirname(dirname(__FILE__));
+        $error_msg =
+          "You are trying to run one copy of Arcanist on another copy of ".
+          "Arcanist. This operation is not supported. To execute Arcanist ".
+          "operations against this working copy, run './bin/arc' (from the ".
+          "current working copy) not some other copy of 'arc' (you ran one ".
+          "from '{$arc_dir}').";
+
+        throw new ArcanistUsageException($error_msg);
       }
     }
   }