diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-19 04:03:01 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-19 04:03:01 +0000 |
| commit | 94762e1ef4d935d3c1a0c2621e7be7230da21c07 (patch) | |
| tree | 09952b41736b7d84713026d103b5a1c6e028aa6b /lib/puppet/parser | |
| parent | 176d483efa052754f38ab15f1592a630da8d6cb7 (diff) | |
| download | puppet-94762e1ef4d935d3c1a0c2621e7be7230da21c07.tar.gz puppet-94762e1ef4d935d3c1a0c2621e7be7230da21c07.tar.xz puppet-94762e1ef4d935d3c1a0c2621e7be7230da21c07.zip | |
Trying to fix a bug where files other than site.pp do not get noticed for reparsing
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1621 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser')
| -rw-r--r-- | lib/puppet/parser/grammar.ra | 37 | ||||
| -rw-r--r-- | lib/puppet/parser/interpreter.rb | 17 | ||||
| -rw-r--r-- | lib/puppet/parser/parser.rb | 41 |
3 files changed, 41 insertions, 54 deletions
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra index 623ca0cab..3a1a78e50 100644 --- a/lib/puppet/parser/grammar.ra +++ b/lib/puppet/parser/grammar.ra @@ -661,20 +661,23 @@ def initialize #end end +# Add a new file to be checked when we're checking to see if we should be +# reparsed. +def newfile(*files) + files.each do |file| + unless file.is_a? Puppet::LoadedFile + file = Puppet::LoadedFile.new(file) + end + @files << file + end +end + def on_error(token,value,stack) #on '%s' at '%s' in\n'%s'" % [token,value,stack] #error = "line %s: parse error after '%s'" % # [@lexer.line,@lexer.last] error = "Syntax error at '%s'" % [value] - #if Puppet[:debug] - #puts stack.inspect - #puts stack.class - #end - #if @lexer.file - # error += (" in '%s'" % @lexer.file) - #end - except = Puppet::ParseError.new(error) except.line = @lexer.line if @lexer.file @@ -705,33 +708,27 @@ def parse(string = nil) # and this is a framework error except.line ||= @lexer.line except.file ||= @lexer.file - #if Puppet[:debug] - # puts except.stack - #end raise except rescue Puppet::DevError => except except.line ||= @lexer.line except.file ||= @lexer.file - #if Puppet[:debug] - # puts except.stack - #end raise except rescue => except error = Puppet::DevError.new(except.message) error.line = @lexer.line error.file = @lexer.file error.set_backtrace except.backtrace - #if Puppet[:debug] - # puts caller - #end raise error end end +# See if any of the files have changed. def reparse? - @files.detect { |file| - file.changed? - } + if file = @files.detect { |file| file.changed? } + return file.stamp + else + return false + end end def string=(string) diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index ad30e6ed3..26bf8104e 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -89,8 +89,6 @@ module Puppet raise Puppet::DevError, "You must provide code or a manifest" end - @lastchecked = 0 - if hash.include?(:UseNodes) @usenodes = hash[:UseNodes] else @@ -386,8 +384,9 @@ module Puppet # Check if the parser should reparse. if @file if defined? @parser - unless @parser.reparse? - @lastchecked = Time.now + if stamp = @parser.reparse? + Puppet.notice "Reloading files" + else return false end end @@ -401,17 +400,14 @@ module Puppet end end - if defined? @parser - # If this isn't our first time parsing in this process, - # note that we're reparsing. - Puppet.info "Reloading files" - end # should i be creating a new parser each time...? @parser = Puppet::Parser::Parser.new() if @code @parser.string = @code else @parser.file = @file + # Mark when we parsed, so we can check freshness + @parsedate = File.stat(@file).ctime.to_i end if @local @@ -421,10 +417,7 @@ module Puppet @ast = @parser.parse end end - - # Mark when we parsed, so we can check freshness @parsedate = Time.now.to_i - @lastchecked = Time.now end # Store the configs into the database. diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb index 41c119c2c..a79f18b0e 100644 --- a/lib/puppet/parser/parser.rb +++ b/lib/puppet/parser/parser.rb @@ -29,7 +29,7 @@ module Puppet class Parser < Racc::Parser -module_eval <<'..end grammar.ra modeval..idab2f060823', 'grammar.ra', 603 +module_eval <<'..end grammar.ra modeval..id1e49212871', 'grammar.ra', 603 require 'puppet/parser/functions' attr_reader :file @@ -91,20 +91,23 @@ def initialize #end end +# Add a new file to be checked when we're checking to see if we should be +# reparsed. +def newfile(*files) + files.each do |file| + unless file.is_a? Puppet::LoadedFile + file = Puppet::LoadedFile.new(file) + end + @files << file + end +end + def on_error(token,value,stack) #on '%s' at '%s' in\n'%s'" % [token,value,stack] #error = "line %s: parse error after '%s'" % # [@lexer.line,@lexer.last] error = "Syntax error at '%s'" % [value] - #if Puppet[:debug] - #puts stack.inspect - #puts stack.class - #end - #if @lexer.file - # error += (" in '%s'" % @lexer.file) - #end - except = Puppet::ParseError.new(error) except.line = @lexer.line if @lexer.file @@ -135,33 +138,27 @@ def parse(string = nil) # and this is a framework error except.line ||= @lexer.line except.file ||= @lexer.file - #if Puppet[:debug] - # puts except.stack - #end raise except rescue Puppet::DevError => except except.line ||= @lexer.line except.file ||= @lexer.file - #if Puppet[:debug] - # puts except.stack - #end raise except rescue => except error = Puppet::DevError.new(except.message) error.line = @lexer.line error.file = @lexer.file error.set_backtrace except.backtrace - #if Puppet[:debug] - # puts caller - #end raise error end end +# See if any of the files have changed. def reparse? - @files.detect { |file| - file.changed? - } + if file = @files.detect { |file| file.changed? } + return file.stamp + else + return false + end end def string=(string) @@ -175,7 +172,7 @@ end # $Id$ -..end grammar.ra modeval..idab2f060823 +..end grammar.ra modeval..id1e49212871 ##### racc 1.4.5 generates ### |
