Refactor formula_at_revision.

This commit is contained in:
Markus Reiter 2017-06-03 00:23:06 +02:00
parent d596c95584
commit 8ffc77d8e8

View File

@ -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,11 +33,12 @@ 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) }
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
@ -46,7 +48,6 @@ class FormulaVersions
ensure
Homebrew.raise_deprecation_exceptions = false
end
end
def bottle_version_map(branch)
map = Hash.new { |h, k| h[k] = [] }