<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -36,6 +36,10 @@ class Puppet::Parser::LoadedCode
         nil
     end
 
+    def node_exists?(name)
+        @nodes[check_name(name)]
+    end
+
     def nodes?
         @nodes.length &gt; 0
     end</diff>
      <filename>lib/puppet/parser/loaded_code.rb</filename>
    </modified>
    <modified>
      <diff>@@ -376,7 +376,7 @@ class Puppet::Parser::Parser
         doc = lexer.getcomment
         names.collect do |name|
             name = AST::HostName.new :value =&gt; name unless name.is_a?(AST::HostName)
-            if other = @loaded_code.node(name)
+            if other = @loaded_code.node_exists?(name)
                 error(&quot;Node %s is already defined at %s:%s; cannot redefine&quot; % [other.name, other.file, other.line])
             end
             name = name.to_s if name.is_a?(Symbol)</diff>
      <filename>lib/puppet/parser/parser_support.rb</filename>
    </modified>
    <modified>
      <diff>@@ -156,7 +156,24 @@ describe Puppet::Parser::LoadedCode do
             nameout = Puppet::Parser::AST::HostName.new(:value =&gt; &quot;foo&quot;)
 
             @loader.add_node(namein, &quot;bar&quot;)
-            @loader.node(nameout) == &quot;bar&quot;
+            @loader.node(nameout).should == &quot;bar&quot;
+        end
+
+        it &quot;should be able to find node by HostName strict equality&quot; do
+            namein = Puppet::Parser::AST::HostName.new(:value =&gt; &quot;foo&quot;)
+            nameout = Puppet::Parser::AST::HostName.new(:value =&gt; &quot;foo&quot;)
+
+            @loader.add_node(namein, &quot;bar&quot;)
+            @loader.node_exists?(nameout).should == &quot;bar&quot;
+        end
+
+        it &quot;should not use node name matching when finding with strict node HostName&quot; do
+            name1 = Puppet::Parser::AST::HostName.new(:value =&gt; &quot;foo&quot;)
+            name2 = Puppet::Parser::AST::HostName.new(:value =&gt; Puppet::Parser::AST::Regex.new(:value =&gt; /foo/))
+
+            @loader.add_node(name1, &quot;bar&quot;)
+            @loader.add_node(name2, &quot;baz&quot;)
+            @loader.node_exists?(name1).should == &quot;bar&quot;
         end
 
         it &quot;should return the first matching regex nodename&quot; do</diff>
      <filename>spec/unit/parser/loaded_code.rb</filename>
    </modified>
    <modified>
      <diff>@@ -253,7 +253,7 @@ describe Puppet::Parser do
         end
 
         it &quot;should raise an error if the node already exists&quot; do
-            @loaded_code.stubs(:node).with(@nodename).returns(@node)
+            @loaded_code.stubs(:node_exists?).with(@nodename).returns(@node)
 
             lambda { @parser.newnode(@nodename) }.should raise_error
         end</diff>
      <filename>spec/unit/parser/parser.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2283605ba63b39deec30bd71b5d0879630f63e6d</id>
    </parent>
  </parents>
  <author>
    <name>Brice Figureau</name>
    <email>brice-puppet@daysofwonder.com</email>
  </author>
  <url>http://github.com/lak/puppet/commit/361c50210172ffe484550a19db3a8d10d86edc09</url>
  <id>361c50210172ffe484550a19db3a8d10d86edc09</id>
  <committed-date>2009-09-16T20:54:55-07:00</committed-date>
  <authored-date>2009-09-15T12:01:48-07:00</authored-date>
  <message>Fix #2638 - Allow creating several nodes with matching names

When we are checking if a node exists before creating a new one
we were also trying to match with regex node names, finding matches
where in fact there is no equality.

Signed-off-by: Brice Figureau &lt;brice-puppet@daysofwonder.com&gt;</message>
  <tree>24b43a67b76164a852c195cb9b05bc27c6a56a49</tree>
  <committer>
    <name>James Turnbull</name>
    <email>james@lovedthanlost.net</email>
  </committer>
</commit>
