]> git.openstreetmap.org Git - rails.git/blobdiff - lib/diff_reader.rb
yet more rewriting of putway...
[rails.git] / lib / diff_reader.rb
index 165e30e20fa94840f70c2d3bff9365eee4f8faba..6a053e4adc19dc8a010d6744da1a125b47314e25 100644 (file)
@@ -79,6 +79,7 @@ class DiffReader
     ids = { :node => node_ids, :way => way_ids, :relation => rel_ids}
 
     result = OSM::API.new.get_xml_doc
+    result.root.name = "diffResult"
 
     # loop at the top level, within the <osmChange> element (although we
     # don't actually check this...)
@@ -99,9 +100,8 @@ class DiffReader
           # diff, so we must fix these before saving the element.
           new.fix_placeholders!(ids)
 
-          # set the initial version to zero and save (which increments it)
-          new.version = 0
-          new.save_with_history!
+          # create element given user
+          new.create_with_history(@changeset.user)
           
           # save placeholder => allocated ID map
           ids[model.to_s.downcase.to_sym][placeholder_id] = new.id
@@ -130,8 +130,10 @@ class DiffReader
 
           xml_result = XML::Node.new model.to_s.downcase
           xml_result["old_id"] = old.id.to_s
-          xml_result["new_id"] = new.id.to_s
-          xml_result["new_version"] = new.version.to_s
+          xml_result["new_id"] = new.id.to_s 
+          # version is updated in "old" through the update, so we must not
+          # return new.version here but old.version!
+          xml_result["new_version"] = old.version.to_s
           result.root << xml_result
         end