Skip to content

Commit

Permalink
Use XML-specified ordering during fetch-manifest.
Browse files Browse the repository at this point in the history
Previously, entries were only read into a hashtable, so iteration
ordering was undefined and seen to be different across machines.

Change-Id: Ifc0807384b7ce7a41c5c440ec5f5a4e0d15fc513
Reviewed-on: http://review.couchbase.org/14276
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
  • Loading branch information
steveyen committed Mar 27, 2012
1 parent 27bc7f1 commit 746a2b0
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions fetch-manifest.rb
Expand Up @@ -18,15 +18,18 @@
root = REXML::Document.new(File.new(path)).root

default = root.get_elements("//default")[0]
remotes = {}

remotes_arr = []
remotes = {}
root.each_element("//remote") do |remote|
remotes_arr << remote.attributes['name']
remotes[remote.attributes['name']] = remote
end

projects_arr = []
projects = {}

root.each_element("//project") do |project|
projects_arr << project.attributes['name']
projects[project.attributes['name']] = project
end

Expand All @@ -36,16 +39,23 @@
if more
more_root = REXML::Document.new(File.new(more)).root
more_root.each_element("//remote") do |remote|
unless remotes[remote.attributes['name']]
remotes_arr << remote.attributes['name']
end
remotes[remote.attributes['name']] = remote
end
more_root.each_element("//project") do |project|
unless projects[project.attributes['name']]
projects_arr << project.attributes['name']
end
projects[project.attributes['name']] = project
end
end

changes = {}

projects.each do |name, project|
projects_arr.each do |name|
project = projects[name]
path = project.attributes['path'] || project.attributes['name']
remote = remotes[project.attributes['remote'] || default.attributes['remote']]
fetch = remote.attributes['fetch']
Expand Down Expand Up @@ -121,14 +131,14 @@
File.open(oxml, 'w') do |o|
o.write "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
o.write "<manifest>\n"
remotes.keys.sort.each do |name|
remotes_arr.each do |name|
remote = remotes[name]
o.write " <remote name=\"#{name}\" fetch=\"#{remote.attributes['fetch']}\"/>\n"
end
o.write "\n"
o.write " <default remote=\"#{default.attributes['remote']}\" revision=\"#{default.attributes['revision']}\"/>\n"
o.write "\n"
projects.keys.sort.each do |name|
projects_arr.each do |name|
project = projects[name]
remote = project.attributes['remote']
path = project.attributes['path'] || project.attributes['name']
Expand Down

0 comments on commit 746a2b0

Please sign in to comment.