]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix an obscure dependency issue in Arcanist + libphutil
authorepriestley <git@epriestley.com>
Fri, 29 Jul 2011 16:12:24 +0000 (09:12 -0700)
committerepriestley <git@epriestley.com>
Wed, 3 Aug 2011 19:17:49 +0000 (12:17 -0700)
Summary:
The module analyzer reads "phutil_require_module" in the source of a module as a
dependency, and tries to regenerate __init__.php if symbols from that module
aren't actually used. This creates patches which don't actually resolve the
problem, since changing __init__.php won't change the dependency.

Instead, trust that anyone using phutil_require_module in the source of a module
knows what they're doing and don't mark it as a dependency.

We currently have an issue with this in phabricator's Setup process since I load
some other libraries' modules just to test if they can be loaded

@lesha, this might be the issue you reported a while ago.

Test Plan: Ran "arc lint" on a module which pulls in another module explicitly
in the source, didn't get a no-op lint error.
Reviewed By: jungejason
Reviewers: jungejason, tuomaspelkonen, aran, lesha
CC: aran, epriestley, jungejason
Differential Revision: 770

scripts/phutil_analyzer.php
src/lint/message/ArcanistLintMessage.php

index 2fdc5134fb3eaddb1a632cb45e8af9296487199c..91b253dcfef1bc182f0125bfabf2544c0eed3eac 100755 (executable)
@@ -122,7 +122,7 @@ foreach (Futures($futures) as $file => $future) {
         }
         $requirements->addSourceDependency($name, $value);
       } else if ($call_name == 'phutil_require_module') {
-        analyze_phutil_require_module($call, $requirements);
+        analyze_phutil_require_module($call, $requirements, true);
       }
     }
   } else {
@@ -154,7 +154,7 @@ foreach (Futures($futures) as $file => $future) {
 
       $call_name = $name->getConcreteString();
       if ($call_name == 'phutil_require_module') {
-        analyze_phutil_require_module($call, $requirements);
+        analyze_phutil_require_module($call, $requirements, false);
       } else if ($call_name == 'call_user_func' ||
                  $call_name == 'call_user_func_array') {
         $params = $call->getChildByIndex(1)->getChildren();
@@ -327,7 +327,8 @@ echo json_encode($requirements->toDictionary());
  */
 function analyze_phutil_require_module(
   XHPASTNode $call,
-  PhutilModuleRequirements $requirements) {
+  PhutilModuleRequirements $requirements,
+  $create_dependency) {
 
   $name = $call->getChildByIndex(0);
   $params = $call->getChildByIndex(1)->getChildren();
@@ -363,7 +364,9 @@ function analyze_phutil_require_module(
     return;
   }
 
-  $requirements->addModuleDependency(
-    $name,
-    $library_value.':'.$module_value);
+  if ($create_dependency) {
+    $requirements->addModuleDependency(
+      $name,
+      $library_value.':'.$module_value);
+  }
 }
index 5320a20226e92939b8fbc3ca574e5be000446edb..dcfa241803bf257254f4905169fcaef7c96931fb 100644 (file)
@@ -168,7 +168,8 @@ class ArcanistLintMessage {
   }
 
   public function isPatchable() {
-    return ($this->getReplacementText() !== null);
+    return ($this->getReplacementText() !== null) &&
+           ($this->getReplacementText() !== $this->getOriginalText());
   }
 
   public function didApplyPatch() {