@@ -46,17 +46,17 module RepositoriesHelper | |||
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def render_changeset_changes |
|
49 | changes = @changeset.changes.find(:all, :limit => 1000, :order => 'path').collect do |change| | |
|
49 | changes = @changeset.filechanges.find(:all, :limit => 1000, :order => 'path').collect do |change| | |
|
50 | 50 | case change.action |
|
51 | 51 | when 'A' |
|
52 | 52 | # Detects moved/copied files |
|
53 | 53 | if !change.from_path.blank? |
|
54 | 54 | change.action = |
|
55 | @changeset.changes.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C' | |
|
55 | @changeset.filechanges.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C' | |
|
56 | 56 | end |
|
57 | 57 | change |
|
58 | 58 | when 'D' |
|
59 | @changeset.changes.detect {|c| c.from_path == change.path} ? nil : change | |
|
59 | @changeset.filechanges.detect {|c| c.from_path == change.path} ? nil : change | |
|
60 | 60 | else |
|
61 | 61 | change |
|
62 | 62 | end |
@@ -20,7 +20,7 require 'iconv' | |||
|
20 | 20 | class Changeset < ActiveRecord::Base |
|
21 | 21 | belongs_to :repository |
|
22 | 22 | belongs_to :user |
|
23 | has_many :changes, :dependent => :delete_all | |
|
23 | has_many :filechanges, :class_name => 'Change', :dependent => :delete_all | |
|
24 | 24 | has_and_belongs_to_many :issues |
|
25 | 25 | has_and_belongs_to_many :parents, |
|
26 | 26 | :class_name => "Changeset", |
@@ -22,7 +22,7 class Repository < ActiveRecord::Base | |||
|
22 | 22 | |
|
23 | 23 | belongs_to :project |
|
24 | 24 | has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC" |
|
25 | has_many :changes, :through => :changesets | |
|
25 | has_many :filechanges, :class_name => 'Change', :through => :changesets | |
|
26 | 26 | |
|
27 | 27 | serialize :extra_info |
|
28 | 28 | |
@@ -228,7 +228,7 class Repository < ActiveRecord::Base | |||
|
228 | 228 | :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC", |
|
229 | 229 | :limit => limit) |
|
230 | 230 | else |
|
231 | changes.find( | |
|
231 | filechanges.find( | |
|
232 | 232 | :all, |
|
233 | 233 | :include => {:changeset => :user}, |
|
234 | 234 | :conditions => ["path = ?", path.with_leading_slash], |
@@ -54,7 +54,7 class Repository::Cvs < Repository | |||
|
54 | 54 | if entries |
|
55 | 55 | entries.each() do |entry| |
|
56 | 56 | if ( ! entry.lastrev.nil? ) && ( ! entry.lastrev.revision.nil? ) |
|
57 | change=changes.find_by_revision_and_path( | |
|
57 | change = filechanges.find_by_revision_and_path( | |
|
58 | 58 | entry.lastrev.revision, |
|
59 | 59 | scm.with_leading_slash(entry.path) ) |
|
60 | 60 | if change |
@@ -94,7 +94,7 class Repository::Cvs < Repository | |||
|
94 | 94 | if rev_to.to_i > 0 |
|
95 | 95 | changeset_to = changesets.find_by_revision(rev_to) |
|
96 | 96 | end |
|
97 | changeset_from.changes.each() do |change_from| | |
|
97 | changeset_from.filechanges.each() do |change_from| | |
|
98 | 98 | revision_from = nil |
|
99 | 99 | revision_to = nil |
|
100 | 100 | if path.nil? || (change_from.path.starts_with? scm.with_leading_slash(path)) |
@@ -102,7 +102,7 class Repository::Cvs < Repository | |||
|
102 | 102 | end |
|
103 | 103 | if revision_from |
|
104 | 104 | if changeset_to |
|
105 | changeset_to.changes.each() do |change_to| | |
|
105 | changeset_to.filechanges.each() do |change_to| | |
|
106 | 106 | revision_to = change_to.revision if change_to.path == change_from.path |
|
107 | 107 | end |
|
108 | 108 | end |
@@ -133,7 +133,7 class Repository::Cvs < Repository | |||
|
133 | 133 | # only add the change to the database, if it doen't exists. the cvs log |
|
134 | 134 | # is not exclusive at all. |
|
135 | 135 | tmp_time = revision.time.clone |
|
136 | unless changes.find_by_path_and_revision( | |
|
136 | unless filechanges.find_by_path_and_revision( | |
|
137 | 137 | scm.with_leading_slash(revision.paths[0][:path]), |
|
138 | 138 | revision.paths[0][:revision] |
|
139 | 139 | ) |
@@ -79,7 +79,7 class Repository::Darcs < Repository | |||
|
79 | 79 | return nil if patch_from.nil? |
|
80 | 80 | patch_to = changesets.find_by_revision(rev_to) if rev_to |
|
81 | 81 | if path.blank? |
|
82 | path = patch_from.changes.collect{|change| change.path}.join(' ') | |
|
82 | path = patch_from.filechanges.collect{|change| change.path}.join(' ') | |
|
83 | 83 | end |
|
84 | 84 | patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil |
|
85 | 85 | end |
@@ -83,7 +83,7 | |||
|
83 | 83 | :id => @project, |
|
84 | 84 | :repository_id => @repository.identifier_param, |
|
85 | 85 | :path => "", |
|
86 | :rev => @changeset.identifier) if @changeset.changes.any? %></p> | |
|
86 | :rev => @changeset.identifier) if @changeset.filechanges.any? %></p> | |
|
87 | 87 | |
|
88 | 88 | <div class="changeset-changes"> |
|
89 | 89 | <%= render_changeset_changes %> |
@@ -67,7 +67,7 class RepositoryBazaarTest < ActiveSupport::TestCase | |||
|
67 | 67 | @project.reload |
|
68 | 68 | |
|
69 | 69 | assert_equal NUM_REV, @repository.changesets.count |
|
70 | assert_equal 9, @repository.changes.count | |
|
70 | assert_equal 9, @repository.filechanges.count | |
|
71 | 71 | assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments |
|
72 | 72 | end |
|
73 | 73 |
@@ -102,7 +102,7 class RepositoryCvsTest < ActiveSupport::TestCase | |||
|
102 | 102 | @project.reload |
|
103 | 103 | |
|
104 | 104 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
105 | assert_equal 16, @repository.changes.count | |
|
105 | assert_equal 16, @repository.filechanges.count | |
|
106 | 106 | assert_not_nil @repository.changesets.find_by_comments('Two files changed') |
|
107 | 107 | |
|
108 | 108 | r2 = @repository.changesets.find_by_revision('2') |
@@ -68,7 +68,7 class RepositoryDarcsTest < ActiveSupport::TestCase | |||
|
68 | 68 | @project.reload |
|
69 | 69 | |
|
70 | 70 | assert_equal NUM_REV, @repository.changesets.count |
|
71 | assert_equal 13, @repository.changes.count | |
|
71 | assert_equal 13, @repository.filechanges.count | |
|
72 | 72 | assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments |
|
73 | 73 | end |
|
74 | 74 |
@@ -62,11 +62,11 class RepositoryFilesystemTest < ActiveSupport::TestCase | |||
|
62 | 62 | if File.directory?(REPOSITORY_PATH) |
|
63 | 63 | def test_fetch_changesets |
|
64 | 64 | assert_equal 0, @repository.changesets.count |
|
65 | assert_equal 0, @repository.changes.count | |
|
65 | assert_equal 0, @repository.filechanges.count | |
|
66 | 66 | @repository.fetch_changesets |
|
67 | 67 | @project.reload |
|
68 | 68 | assert_equal 0, @repository.changesets.count |
|
69 | assert_equal 0, @repository.changes.count | |
|
69 | assert_equal 0, @repository.filechanges.count | |
|
70 | 70 | end |
|
71 | 71 | |
|
72 | 72 | def test_entries |
@@ -105,7 +105,7 class RepositoryGitTest < ActiveSupport::TestCase | |||
|
105 | 105 | @project.reload |
|
106 | 106 | |
|
107 | 107 | assert_equal NUM_REV, @repository.changesets.count |
|
108 | assert_equal 39, @repository.changes.count | |
|
108 | assert_equal 39, @repository.filechanges.count | |
|
109 | 109 | |
|
110 | 110 | commit = @repository.changesets.find_by_revision("7234cb2750b63f47bff735edc50a1c0a433c2518") |
|
111 | 111 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid |
@@ -115,8 +115,8 class RepositoryGitTest < ActiveSupport::TestCase | |||
|
115 | 115 | # TODO: add a commit with commit time <> author time to the test repository |
|
116 | 116 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on |
|
117 | 117 | assert_equal "2007-12-14".to_date, commit.commit_date |
|
118 | assert_equal 3, commit.changes.count | |
|
119 | change = commit.changes.sort_by(&:path).first | |
|
118 | assert_equal 3, commit.filechanges.count | |
|
119 | change = commit.filechanges.sort_by(&:path).first | |
|
120 | 120 | assert_equal "README", change.path |
|
121 | 121 | assert_equal nil, change.from_path |
|
122 | 122 | assert_equal "A", change.action |
@@ -86,7 +86,7 class RepositoryMercurialTest < ActiveSupport::TestCase | |||
|
86 | 86 | @repository.fetch_changesets |
|
87 | 87 | @project.reload |
|
88 | 88 | assert_equal NUM_REV, @repository.changesets.count |
|
89 | assert_equal 46, @repository.changes.count | |
|
89 | assert_equal 46, @repository.filechanges.count | |
|
90 | 90 | assert_equal "Initial import.\nThe repository contains 3 files.", |
|
91 | 91 | @repository.changesets.find_by_revision('0').comments |
|
92 | 92 | end |
@@ -214,7 +214,7 class RepositoryMercurialTest < ActiveSupport::TestCase | |||
|
214 | 214 | |
|
215 | 215 | cs1 = @repository.changesets.find_by_revision('13') |
|
216 | 216 | assert_not_nil cs1 |
|
217 | c1 = cs1.changes.sort_by(&:path) | |
|
217 | c1 = cs1.filechanges.sort_by(&:path) | |
|
218 | 218 | assert_equal 2, c1.size |
|
219 | 219 | |
|
220 | 220 | assert_equal 'A', c1[0].action |
@@ -227,7 +227,7 class RepositoryMercurialTest < ActiveSupport::TestCase | |||
|
227 | 227 | assert_equal '/sql_escape/underscore_dir/understrike_file.txt', c1[1].from_path |
|
228 | 228 | |
|
229 | 229 | cs2 = @repository.changesets.find_by_revision('15') |
|
230 | c2 = cs2.changes | |
|
230 | c2 = cs2.filechanges | |
|
231 | 231 | assert_equal 1, c2.size |
|
232 | 232 | |
|
233 | 233 | assert_equal 'A', c2[0].action |
@@ -236,7 +236,7 class RepositoryMercurialTest < ActiveSupport::TestCase | |||
|
236 | 236 | assert_equal '933ca60293d7', c2[0].from_revision |
|
237 | 237 | |
|
238 | 238 | cs3 = @repository.changesets.find_by_revision('19') |
|
239 | c3 = cs3.changes | |
|
239 | c3 = cs3.filechanges | |
|
240 | 240 | assert_equal 1, c3.size |
|
241 | 241 | assert_equal 'A', c3[0].action |
|
242 | 242 | assert_equal "/latin-1-dir/test-#{@char_1}-1.txt", c3[0].path |
@@ -36,7 +36,7 class RepositorySubversionTest < ActiveSupport::TestCase | |||
|
36 | 36 | @project.reload |
|
37 | 37 | |
|
38 | 38 | assert_equal NUM_REV, @repository.changesets.count |
|
39 | assert_equal 20, @repository.changes.count | |
|
39 | assert_equal 20, @repository.filechanges.count | |
|
40 | 40 | assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments |
|
41 | 41 | end |
|
42 | 42 | |
@@ -99,7 +99,7 class RepositorySubversionTest < ActiveSupport::TestCase | |||
|
99 | 99 | @project.reload |
|
100 | 100 | |
|
101 | 101 | assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision' |
|
102 | assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add' | |
|
102 | assert_equal 2, @repository.filechanges.count, 'Expected to see 2 changes, dir add and file add' | |
|
103 | 103 | |
|
104 | 104 | entries = @repository.entries('') |
|
105 | 105 | assert_not_nil entries, 'Expect to find entries' |
@@ -98,8 +98,10 class RepositoryTest < ActiveSupport::TestCase | |||
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | def test_destroy |
|
101 | changesets = Changeset.where("repository_id = 10").all.count | |
|
102 | changes = Changeset.joins([:changes]).where("repository_id = 10").all.count | |
|
101 | repository = Repository.find(10) | |
|
102 | changesets = repository.changesets.count | |
|
103 | changes = repository.filechanges.count | |
|
104 | ||
|
103 | 105 | assert_difference 'Changeset.count', -changesets do |
|
104 | 106 | assert_difference 'Change.count', -changes do |
|
105 | 107 | Repository.find(10).destroy |
General Comments 0
You need to be logged in to leave comments.
Login now