Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 24
- Log:
Initial import of Collaboa 0.5.6 from downloaded Tarball. Collaboa is
a Ruby On Rails based bug tracker and SVN repository browsing tool.
- Author:
- adh
- Date:
- Mon Jul 24 21:54:39 +0100 2006
- Size:
- 4406 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/env ruby |
2 | |
3 | require 'optparse' |
4 | |
5 | OPTIONS = { |
6 | :environment => "production", |
7 | :reload_db => false, |
8 | :dry_run => false, |
9 | :verbose => false, |
10 | :truncate_db => false |
11 | } |
12 | |
13 | ARGV.options do |opts| |
14 | script_name = File.basename($0) |
15 | opts.banner = "Usage: ruby #{script_name} [options]" |
16 | |
17 | opts.separator "" |
18 | |
19 | opts.on("-t", "--truncate-db", |
20 | "resync the entire database, truncating it first") { |OPTIONS[:truncate_db]| } |
21 | opts.on("-e", "--environment=name", String, |
22 | "Specifies the environment to run this script against", |
23 | "(test/development/production). Default: production") { |OPTIONS[:environment]| } |
24 | opts.on("-d", "--dry-run", |
25 | "Doesn't insert anything into the database") { |OPTIONS[:dry_run]| } |
26 | opts.on("-v", "--verbose", |
27 | "Use verbose output on STDOUT") { |OPTIONS[:verbose]| } |
28 | |
29 | opts.separator "" |
30 | |
31 | opts.on("-h", "--help", |
32 | "Show this help message.") { puts opts; exit } |
33 | |
34 | opts.parse! |
35 | end |
36 | |
37 | # Set up our environment |
38 | ENV["RAILS_ENV"] = OPTIONS[:environment] |
39 | require File.dirname(__FILE__) + '/../config/environment' |
40 | |
41 | |
42 | if OPTIONS[:dry_run] |
43 | puts '*' * 50 |
44 | puts ' ' * 10 + 'THIS IS A DRY RUN ONLY!' |
45 | puts '*' * 50 |
46 | end |
47 | |
48 | # Truncate the tables if requested |
49 | if OPTIONS[:truncate_db] |
50 | ActiveRecord::Base.connection.execute("TRUNCATE TABLE changesets") unless OPTIONS[:dry_run] |
51 | ActiveRecord::Base.connection.execute("TRUNCATE TABLE changes") unless OPTIONS[:dry_run] |
52 | puts ">>> Truncated 'changesets' and 'changes' tables <<<" |
53 | end |
54 | |
55 | # Reset column info |
56 | Change.reset_column_information |
57 | Changeset.reset_column_information |
58 | |
59 | # The actual sync stuff |
60 | begin |
61 | Changeset.transaction do |
62 | last_stored = Changeset.find_first(nil, "revision DESC") |
63 | if last_stored.nil? |
64 | youngest_stored = 0 |
65 | else |
66 | youngest_stored = last_stored.revision |
67 | end |
68 | youngest_rev = Repository.get_youngest_rev |
69 | |
70 | # FOR DEBUG !!! |
71 | #youngest_stored = 93 |
72 | #youngest_rev = 94 |
73 | |
74 | revs_to_sync = ((youngest_stored + 1)..youngest_rev).to_a |
75 | revs_to_sync.each do |rev| |
76 | |
77 | revision = Repository.get_changeset(rev) |
78 | |
79 | cs = Changeset.create(:revision => rev, |
80 | :author => revision.author, |
81 | :log => revision.log_message, |
82 | :revised_at => revision.date) unless OPTIONS[:dry_run] |
83 | if OPTIONS[:verbose] |
84 | puts '-' * 50 |
85 | puts "revision #{rev} by #{revision.author}. Commit message:" |
86 | puts revision.log_message |
87 | puts '-' * 50 |
88 | end |
89 | |
90 | revision.copied_nodes.each do |path| |
91 | cs.changes << Change.new(:revision => rev, :name => 'CP', |
92 | :path => path[0], :from_path => path[1], |
93 | :from_revision => path[2]) unless OPTIONS[:dry_run] |
94 | puts " CP #{path[0]} (from #{path[1]}:#{path[2]})" if OPTIONS[:verbose] |
95 | end |
96 | |
97 | revision.moved_nodes.each do |path| |
98 | cs.changes << Change.new(:revision => rev, :name => 'MV', |
99 | :path => path[0], :from_path => path[1], |
100 | :from_revision => path[2]) unless OPTIONS[:dry_run] |
101 | puts " MV #{path[0]} (from #{path[1]}:#{path[2]})" if OPTIONS[:verbose] |
102 | end |
103 | |
104 | revision.added_nodes.each do |path| |
105 | cs.changes << Change.new(:revision => rev, :name => 'A', :path => path) unless OPTIONS[:dry_run] |
106 | puts " A #{path}" if OPTIONS[:verbose] |
107 | end |
108 | |
109 | revision.deleted_nodes.each do |path| |
110 | cs.changes << Change.new(:revision => rev, :name => 'D', :path => path) unless OPTIONS[:dry_run] |
111 | puts " D #{path}" if OPTIONS[:verbose] |
112 | end |
113 | |
114 | revision.updated_nodes.each do |path| |
115 | cs.changes << Change.new(:revision => rev, :name => 'M', :path => path) unless OPTIONS[:dry_run] |
116 | puts " M #{path}" if OPTIONS[:verbose] |
117 | end |
118 | |
119 | puts "* Synced changeset #{rev}" |
120 | puts if OPTIONS[:verbose] |
121 | |
122 | # Run GC manually to cut down the memory footprint, |
123 | # TODO: recheck it on next svn update, current release has known memory issues |
124 | revision = nil |
125 | cs = nil |
126 | GC.start |
127 | sleep 0.01 # give GC a chance |
128 | |
129 | end if youngest_stored < youngest_rev |
130 | end # end transaction |
131 | rescue ActiveRecord::RecordInvalid => rie |
132 | # presuming it'll only get raised when revision is not unique |
133 | puts "Revision already exists, moving on.." |
134 | end |
135 |