+ # assign new contents
+ new_relation.members = typedmembers
+ new_relation.tags = tags
+ new_relation.visible = visible
+ new_relation.changeset_id = changeset_id
+ new_relation.version = version
+
+ if relid <= 0
+ # We're creating the relation
+ new_relation.create_with_history(user)
+ elsif visible
+ # We're updating the relation
+ new_relation.id = relid
+ relation.update_from(new_relation, user)
+ else
+ # We're deleting the relation
+ new_relation.id = relid
+ relation.delete_with_history!(new_relation, user)
+ end
+ end # transaction
+
+ if relid <= 0
+ return [0, '', relid, new_relation.id, new_relation.version]
+ else
+ return [0, '', relid, relid, relation.version]
+ end
+ rescue OSM::APIChangesetAlreadyClosedError => ex
+ return [-1, "The changeset #{ex.changeset.id} was closed at #{ex.changeset.closed_at}.", relid, relid, nil]
+ rescue OSM::APIVersionMismatchError => ex
+ a=ex.to_s.match(/(\d+) of (\w+) (\d+)$/)
+ return [-3, ['relation', a[1]], relid, relid, nil]
+ rescue OSM::APIAlreadyDeletedError => ex
+ return [-1, "The relation has already been deleted.", relid, relid, nil]
+ rescue OSM::APIError => ex
+ # Some error that we don't specifically catch
+ return [-2, "An unusual error happened (in 'putrelation' #{relid}). The server said: #{ex}", relid, relid, nil]