aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2012-07-27 02:50:29 -0500
committerJack Nagel2012-07-27 02:50:29 -0500
commit96ee0e90ccaccb9a91dfbe53919998a0adc68cbd (patch)
tree253ac1305bb1e1c1c72ed0c708bad84c9b44cc14 /Library
parent5a62582b39b7df44c8068970728f0a2f800bf39f (diff)
downloadbrew-96ee0e90ccaccb9a91dfbe53919998a0adc68cbd.tar.bz2
Deduplicate requirements
Because of some quirks in how formulae are loaded, DSL methods invoked in the class definition are called multiple times. This results in, for example, duplicate dependencies and requirements. Code that iterates over requirements and takes some action for each can thus repeat things that shouldn't be repeated, like appending to environment variables. Make DependencyCollector's external_deps a Set, and define eql? and hash on Requirement to prevent these duplicates. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/dependencies.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb
index 6a4c3e228..43596ad6c 100644
--- a/Library/Homebrew/dependencies.rb
+++ b/Library/Homebrew/dependencies.rb
@@ -1,3 +1,5 @@
+require 'set'
+
## This file defines dependencies and requirements.
##
## A dependency is a formula that another formula needs to install.
@@ -21,7 +23,7 @@ class DependencyCollector
def initialize
@deps = Dependencies.new
- @external_deps = []
+ @external_deps = Set.new
end
def add spec
@@ -119,6 +121,14 @@ class Requirement
def fatal?; false; end
def message; ""; end
def modify_build_environment; nil end
+
+ def eql?(other)
+ other.is_a? self.class and hash == other.hash
+ end
+
+ def hash
+ @message.hash
+ end
end