Permalink
Browse files

Use XML-specified ordering during fetch-manifest.

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...
1 parent 27bc7f1 commit 746a2b06f36a79c8a55494878537a7a4ba028af7 @steveyen steveyen committed Mar 23, 2012
Showing with 15 additions and 5 deletions.
  1. +15 −5 fetch-manifest.rb
View
@@ -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
@@ -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']
@@ -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']

0 comments on commit 746a2b0

Please sign in to comment.