diff options
| author | Xu Cheng | 2015-09-02 16:42:54 +0800 |
|---|---|---|
| committer | Xu Cheng | 2015-09-06 20:47:04 +0800 |
| commit | 11f0979dfb11cad1e0b3aefc910235f79faffa3b (patch) | |
| tree | 53bdb60b5b91e36210084f7395d7af10b386b7f5 /Library | |
| parent | 61c8f69c25223cc696003dbf83888a6b8377d446 (diff) | |
| download | brew-11f0979dfb11cad1e0b3aefc910235f79faffa3b.tar.bz2 | |
FormulaVersions: load from contents to reduce io
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula_versions.rb | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index 5d9ad4317..3d92d676c 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -7,12 +7,13 @@ class FormulaVersions ErrorDuringExecution, LoadError ] - attr_reader :name, :repository, :entry_name + attr_reader :name, :path, :repository, :entry_name def initialize(formula) @name = formula.name + @path = formula.path @repository = formula.tap? ? HOMEBREW_LIBRARY.join("Taps", formula.tap) : HOMEBREW_REPOSITORY - @entry_name = formula.path.relative_path_from(repository).to_s + @entry_name = @path.relative_path_from(repository).to_s end def rev_list(branch) @@ -28,19 +29,16 @@ class FormulaVersions end def formula_at_revision(rev) - FileUtils.mktemp(name) do - path = Pathname.pwd.join("#{name}.rb") - path.write file_contents_at_revision(rev) - - begin - nostdout { yield Formulary.factory(path.to_s) } - 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 - end + contents = file_contents_at_revision(rev) + + begin + nostdout { yield 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 end end |
