aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-06-03 00:23:06 +0200
committerMarkus Reiter2017-06-04 10:24:16 +0200
commit8ffc77d8e89ebb1e4895b1d4927f713f182cac66 (patch)
treedcfb8359c98ab69603316d972058bc8f84e71681 /Library
parentd596c955842336d6a660fb7d598cb8a6b4d9a035 (diff)
downloadbrew-8ffc77d8e89ebb1e4895b1d4927f713f182cac66.tar.bz2
Refactor `formula_at_revision`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula_versions.rb27
1 files changed, 14 insertions, 13 deletions
diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb
index dda8dc712..bb6803567 100644
--- a/Library/Homebrew/formula_versions.rb
+++ b/Library/Homebrew/formula_versions.rb
@@ -17,6 +17,7 @@ class FormulaVersions
@repository = formula.tap.path
@entry_name = @path.relative_path_from(repository).to_s
@current_formula = formula
+ @formula_at_revision = {}
end
def rev_list(branch)
@@ -32,20 +33,20 @@ class FormulaVersions
end
def formula_at_revision(rev)
- contents = file_contents_at_revision(rev)
-
- begin
- Homebrew.raise_deprecation_exceptions = true
- yield nostdout { Formulary.from_contents(name, path, contents) }
- rescue *IGNORED_EXCEPTIONS => e
- # We rescue these so that we can skip bad versions and
- # continue walking the history
- ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
- rescue FormulaUnavailableError
- # Suppress this error
- ensure
- Homebrew.raise_deprecation_exceptions = false
+ Homebrew.raise_deprecation_exceptions = true
+
+ yield @formula_at_revision[rev] ||= begin
+ contents = file_contents_at_revision(rev)
+ nostdout { Formulary.from_contents(name, path, contents) }
end
+ rescue *IGNORED_EXCEPTIONS => e
+ # We rescue these so that we can skip bad versions and
+ # continue walking the history
+ ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
+ rescue FormulaUnavailableError
+ # Suppress this error
+ ensure
+ Homebrew.raise_deprecation_exceptions = false
end
def bottle_version_map(branch)