Mercurial > hg > soundsoftware-site
comparison app/models/repository/cvs.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbce1fd3b1b7 |
children | 51d7f3e06556 622f24f53b42 261b3d9a4903 |
comparison
equal
deleted
inserted
replaced
929:5f33065ddc4b | 1115:433d4f72a19b |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
19 require 'digest/sha1' | 19 require 'digest/sha1' |
20 | 20 |
21 class Repository::Cvs < Repository | 21 class Repository::Cvs < Repository |
22 validates_presence_of :url, :root_url, :log_encoding | 22 validates_presence_of :url, :root_url, :log_encoding |
23 | 23 |
24 def self.human_attribute_name(attribute_key_name) | 24 safe_attributes 'root_url', |
25 attr_name = attribute_key_name | 25 :if => lambda {|repository, user| repository.new_record?} |
26 | |
27 def self.human_attribute_name(attribute_key_name, *args) | |
28 attr_name = attribute_key_name.to_s | |
26 if attr_name == "root_url" | 29 if attr_name == "root_url" |
27 attr_name = "cvsroot" | 30 attr_name = "cvsroot" |
28 elsif attr_name == "url" | 31 elsif attr_name == "url" |
29 attr_name = "cvs_module" | 32 attr_name = "cvs_module" |
30 end | 33 end |
31 super(attr_name) | 34 super(attr_name, *args) |
32 end | 35 end |
33 | 36 |
34 def self.scm_adapter_class | 37 def self.scm_adapter_class |
35 Redmine::Scm::Adapters::CvsAdapter | 38 Redmine::Scm::Adapters::CvsAdapter |
36 end | 39 end |
52 end | 55 end |
53 entries = scm.entries(path, rev.nil? ? nil : rev.committed_on) | 56 entries = scm.entries(path, rev.nil? ? nil : rev.committed_on) |
54 if entries | 57 if entries |
55 entries.each() do |entry| | 58 entries.each() do |entry| |
56 if ( ! entry.lastrev.nil? ) && ( ! entry.lastrev.revision.nil? ) | 59 if ( ! entry.lastrev.nil? ) && ( ! entry.lastrev.revision.nil? ) |
57 change=changes.find_by_revision_and_path( | 60 change = filechanges.find_by_revision_and_path( |
58 entry.lastrev.revision, | 61 entry.lastrev.revision, |
59 scm.with_leading_slash(entry.path) ) | 62 scm.with_leading_slash(entry.path) ) |
60 if change | 63 if change |
61 entry.lastrev.identifier = change.changeset.revision | 64 entry.lastrev.identifier = change.changeset.revision |
62 entry.lastrev.revision = change.changeset.revision | 65 entry.lastrev.revision = change.changeset.revision |
64 # entry.lastrev.branch = change.branch | 67 # entry.lastrev.branch = change.branch |
65 end | 68 end |
66 end | 69 end |
67 end | 70 end |
68 end | 71 end |
72 load_entries_changesets(entries) | |
69 entries | 73 entries |
70 end | 74 end |
71 | 75 |
72 def cat(path, identifier=nil) | 76 def cat(path, identifier=nil) |
73 rev = nil | 77 rev = nil |
92 diff=[] | 96 diff=[] |
93 changeset_from = changesets.find_by_revision(rev) | 97 changeset_from = changesets.find_by_revision(rev) |
94 if rev_to.to_i > 0 | 98 if rev_to.to_i > 0 |
95 changeset_to = changesets.find_by_revision(rev_to) | 99 changeset_to = changesets.find_by_revision(rev_to) |
96 end | 100 end |
97 changeset_from.changes.each() do |change_from| | 101 changeset_from.filechanges.each() do |change_from| |
98 revision_from = nil | 102 revision_from = nil |
99 revision_to = nil | 103 revision_to = nil |
100 if path.nil? || (change_from.path.starts_with? scm.with_leading_slash(path)) | 104 if path.nil? || (change_from.path.starts_with? scm.with_leading_slash(path)) |
101 revision_from = change_from.revision | 105 revision_from = change_from.revision |
102 end | 106 end |
103 if revision_from | 107 if revision_from |
104 if changeset_to | 108 if changeset_to |
105 changeset_to.changes.each() do |change_to| | 109 changeset_to.filechanges.each() do |change_to| |
106 revision_to = change_to.revision if change_to.path == change_from.path | 110 revision_to = change_to.revision if change_to.path == change_from.path |
107 end | 111 end |
108 end | 112 end |
109 unless revision_to | 113 unless revision_to |
110 revision_to = scm.get_previous_revision(revision_from) | 114 revision_to = scm.get_previous_revision(revision_from) |
131 tmp_rev_num = 1 | 135 tmp_rev_num = 1 |
132 scm.revisions('', fetch_since, nil, :log_encoding => repo_log_encoding) do |revision| | 136 scm.revisions('', fetch_since, nil, :log_encoding => repo_log_encoding) do |revision| |
133 # only add the change to the database, if it doen't exists. the cvs log | 137 # only add the change to the database, if it doen't exists. the cvs log |
134 # is not exclusive at all. | 138 # is not exclusive at all. |
135 tmp_time = revision.time.clone | 139 tmp_time = revision.time.clone |
136 unless changes.find_by_path_and_revision( | 140 unless filechanges.find_by_path_and_revision( |
137 scm.with_leading_slash(revision.paths[0][:path]), | 141 scm.with_leading_slash(revision.paths[0][:path]), |
138 revision.paths[0][:revision] | 142 revision.paths[0][:revision] |
139 ) | 143 ) |
140 cmt = Changeset.normalize_comments(revision.message, repo_log_encoding) | 144 cmt = Changeset.normalize_comments(revision.message, repo_log_encoding) |
141 author_utf8 = Changeset.to_utf8(revision.author, repo_log_encoding) | 145 author_utf8 = Changeset.to_utf8(revision.author, repo_log_encoding) |
179 ) | 183 ) |
180 end | 184 end |
181 end | 185 end |
182 | 186 |
183 # Renumber new changesets in chronological order | 187 # Renumber new changesets in chronological order |
184 changesets.find( | 188 Changeset.all( |
185 :all, | |
186 :order => 'committed_on ASC, id ASC', | 189 :order => 'committed_on ASC, id ASC', |
187 :conditions => "revision LIKE 'tmp%'" | 190 :conditions => ["repository_id = ? AND revision LIKE 'tmp%'", id] |
188 ).each do |changeset| | 191 ).each do |changeset| |
189 changeset.update_attribute :revision, next_revision_number | 192 changeset.update_attribute :revision, next_revision_number |
190 end | 193 end |
191 end # transaction | 194 end # transaction |
192 @current_revision_number = nil | 195 @current_revision_number = nil |