[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Nick Lewis nick at puppetlabs.com
Tue May 10 08:04:29 UTC 2011


The following commit has been merged in the experimental branch:
commit fd0bfdec4512ee0927be6c181e99b96be26363aa
Merge: d64f4a9024d738d9184f822f1d26e404a403d256 70a43c4b0d3018a39e29c50b1caf7dec38694323
Author: Nick Lewis <nick at puppetlabs.com>
Date:   Thu Feb 3 21:22:47 2011 -0800

    Merge branch '2.6.x' into next
    
    Conflicts:
    	lib/puppet/util/zaml.rb

diff --combined lib/puppet/util/zaml.rb
index 2155e98,b22dfc1..bbb2af2
--- a/lib/puppet/util/zaml.rb
+++ b/lib/puppet/util/zaml.rb
@@@ -20,6 -20,7 +20,6 @@@ class ZAM
    def self.dump(stuff, where='')
      z = new
      stuff.to_zaml(z)
 -    Label.counter_reset
      where << z.to_s
    end
    #
@@@ -29,8 -30,7 +29,8 @@@
      @result = []
      @indent = nil
      @structured_key_prefix = nil
 -    Label.counter_reset
 +    @previously_emitted_object = {}
 +    @next_free_label_number = 0
      emit('--- ')
    end
    def nested(tail='  ')
@@@ -56,29 -56,31 +56,30 @@@
      #    which we will encounter a reference to the object as we serialize
      #    it can be handled).
      #
 -    def self.counter_reset
 -      @@previously_emitted_object = {}
 -      @@next_free_label_number = 0
 -    end
 -    def initialize(obj)
 +    attr_accessor :this_label_number
 +    def initialize(obj,indent)
 +      @indent = indent
        @this_label_number = nil
+       @obj = obj # prevent garbage collection so that object id isn't reused
 -      @@previously_emitted_object[obj.object_id] = self
      end
      def to_s
 -      @this_label_number ? ('&id%03d ' % @this_label_number) : ''
 +      @this_label_number ? ('&id%03d%s' % [@this_label_number, @indent]) : ''
      end
      def reference
 -      @this_label_number ||= (@@next_free_label_number += 1)
        @reference         ||= '*id%03d' % @this_label_number
      end
 -    def self.for(obj)
 -      @@previously_emitted_object[obj.object_id]
 -    end
 +  end
 +  def label_for(obj)
 +    @previously_emitted_object[obj.object_id]
    end
    def new_label_for(obj)
 -    Label.new(obj)
 +    label = Label.new(obj,(Hash === obj || Array === obj) ? "#{@indent || "\n"}  " : ' ')
 +    @previously_emitted_object[obj.object_id] = label
 +    label
    end
    def first_time_only(obj)
 -    if label = Label.for(obj)
 +    if label = label_for(obj)
 +      label.this_label_number ||= (@next_free_label_number += 1)
        emit(label.reference)
      else
        if @structured_key_prefix and not obj.is_a? String
@@@ -91,7 -93,7 +92,7 @@@
    end
    def emit(s)
      @result << s
 -    @recent_nl = false
 +    @recent_nl = false unless s.kind_of?(Label)
    end
    def nl(s='')
      emit(@indent || "\n") unless @recent_nl
@@@ -223,32 -225,30 +224,32 @@@ class Strin
      gsub( /([\x80-\xFF])/ ) { |x| "\\x#{x.unpack("C")[0].to_s(16)}" }
    end
    def to_zaml(z)
 -    num = '[-+]?(0x)?\d+\.?\d*'
 -    case
 -      when self == ''
 -        z.emit('""')
 -      # when self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/
 -      #   z.emit("!binary |\n")
 -      #   z.emit([self].pack("m*"))
 -      when (
 -        (self =~ /\A(true|false|yes|no|on|null|off|#{num}(:#{num})*|!|=|~)$/i) or
 -        (self =~ /\A\n* /) or
 -        (self =~ /[\s:]$/) or
 -        (self =~ /^[>|][-+\d]*\s/i) or
 -        (self[-1..-1] =~ /\s/) or
 -        (self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/) or
 -        (self =~ /[,\[\]\{\}\r\t]|:\s|\s#/) or
 -        (self =~ /\A([-:?!#&*'"]|<<|%.+:.)/)
 -        )
 -        z.emit("\"#{escaped_for_zaml}\"")
 -      when self =~ /\n/
 -        if self[-1..-1] == "\n" then z.emit('|+') else z.emit('|-') end
 -        z.nested { split("\n",-1).each { |line| z.nl; z.emit(line.chomp("\n")) } }
 -      else
 -        z.emit(self)
 -    end
 +    z.first_time_only(self) {
 +      num = '[-+]?(0x)?\d+\.?\d*'
 +      case
 +        when self == ''
 +          z.emit('""')
 +        # when self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/
 +        #   z.emit("!binary |\n")
 +        #   z.emit([self].pack("m*"))
 +        when (
 +          (self =~ /\A(true|false|yes|no|on|null|off|#{num}(:#{num})*|!|=|~)$/i) or
 +          (self =~ /\A\n* /) or
 +          (self =~ /[\s:]$/) or
 +          (self =~ /^[>|][-+\d]*\s/i) or
 +          (self[-1..-1] =~ /\s/) or
 +          (self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/) or
 +          (self =~ /[,\[\]\{\}\r\t]|:\s|\s#/) or
 +          (self =~ /\A([-:?!#&*'"]|<<|%.+:.)/)
 +          )
 +          z.emit("\"#{escaped_for_zaml}\"")
 +        when self =~ /\n/
 +          if self[-1..-1] == "\n" then z.emit('|+') else z.emit('|-') end
 +          z.nested { split("\n",-1).each { |line| z.nl; z.emit(line.chomp("\n")) } }
 +        else
 +          z.emit(self)
 +      end
 +    }
    end
  end
  

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list