From 7e4bde114e9fa2890a15e2684c861eaf2ad6daa3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 19 May 2011 10:13:44 -0700 Subject: [PATCH] Detect library conflicts in Arcanist and raise a very specific error message 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 | 5 ++++- scripts/arcanist.php | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.arcconfig b/.arcconfig index 417127e0..de02caaa 100644 --- a/.arcconfig +++ b/.arcconfig @@ -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/" + } } diff --git a/scripts/arcanist.php b/scripts/arcanist.php index 7eb37be3..a67098db 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -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); } } }