Revision 912:5e80956cc792 app/models/repository
| app/models/repository/darcs.rb.rej | ||
|---|---|---|
| 1 |
--- app/models/repository/darcs.rb |
|
| 2 |
+++ app/models/repository/darcs.rb |
|
| 3 |
@@ -85,11 +85,7 @@ |
|
| 4 |
:comments => revision.message) |
|
| 5 |
|
|
| 6 |
revision.paths.each do |change| |
|
| 7 |
- Change.create(:changeset => changeset, |
|
| 8 |
- :action => change[:action], |
|
| 9 |
- :path => change[:path], |
|
| 10 |
- :from_path => change[:from_path], |
|
| 11 |
- :from_revision => change[:from_revision]) |
|
| 12 |
+ changeset.create_change(change) |
|
| 13 |
end |
|
| 14 |
next_rev += 1 |
|
| 15 |
end if revisions |
|
| app/models/repository/git.rb | ||
|---|---|---|
| 53 | 53 |
true |
| 54 | 54 |
end |
| 55 | 55 |
|
| 56 |
def supports_revision_graph? |
|
| 57 |
true |
|
| 58 |
end |
|
| 59 |
|
|
| 56 | 60 |
def repo_log_encoding |
| 57 | 61 |
'UTF-8' |
| 58 | 62 |
end |
| ... | ... | |
| 77 | 81 |
|
| 78 | 82 |
def default_branch |
| 79 | 83 |
scm.default_branch |
| 84 |
rescue Exception => e |
|
| 85 |
logger.error "git: error during get default branch: #{e.message}"
|
|
| 86 |
nil |
|
| 80 | 87 |
end |
| 81 | 88 |
|
| 82 | 89 |
def find_changeset_by_name(name) |
| ... | ... | |
| 92 | 99 |
options = {:report_last_commit => extra_report_last_commit})
|
| 93 | 100 |
end |
| 94 | 101 |
|
| 102 |
# With SCMs that have a sequential commit numbering, |
|
| 103 |
# such as Subversion and Mercurial, |
|
| 104 |
# Redmine is able to be clever and only fetch changesets |
|
| 105 |
# going forward from the most recent one it knows about. |
|
| 106 |
# |
|
| 107 |
# However, Git does not have a sequential commit numbering. |
|
| 108 |
# |
|
| 109 |
# In order to fetch only new adding revisions, |
|
| 110 |
# Redmine needs to parse revisions per branch. |
|
| 111 |
# Branch "last_scmid" is for this requirement. |
|
| 112 |
# |
|
| 95 | 113 |
# In Git and Mercurial, revisions are not in date order. |
| 96 | 114 |
# Redmine Mercurial fixed issues. |
| 97 | 115 |
# * Redmine Takes Too Long On Large Mercurial Repository |
| ... | ... | |
| 126 | 144 |
merge_extra_info(h) |
| 127 | 145 |
self.save |
| 128 | 146 |
end |
| 129 |
scm_brs.each do |br| |
|
| 147 |
scm_brs.each do |br1| |
|
| 148 |
br = br1.to_s |
|
| 130 | 149 |
from_scmid = nil |
| 131 | 150 |
from_scmid = h["branches"][br]["last_scmid"] if h["branches"][br] |
| 132 | 151 |
h["branches"][br] ||= {}
|
| ... | ... | |
| 134 | 153 |
db_rev = find_changeset_by_name(rev.revision) |
| 135 | 154 |
transaction do |
| 136 | 155 |
if db_rev.nil? |
| 137 |
save_revision(rev) |
|
| 156 |
db_saved_rev = save_revision(rev) |
|
| 157 |
parents = {}
|
|
| 158 |
parents[db_saved_rev] = rev.parents unless rev.parents.nil? |
|
| 159 |
parents.each do |ch, chparents| |
|
| 160 |
ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
|
|
| 161 |
end |
|
| 138 | 162 |
end |
| 139 | 163 |
h["branches"][br]["last_scmid"] = rev.scmid |
| 140 | 164 |
merge_extra_info(h) |
| ... | ... | |
| 161 | 185 |
:path => file[:path]) |
| 162 | 186 |
end |
| 163 | 187 |
end |
| 188 |
changeset |
|
| 164 | 189 |
end |
| 165 | 190 |
private :save_revision |
| 166 | 191 |
|
| app/models/repository/mercurial.rb | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
class Repository::Mercurial < Repository |
| 21 | 21 |
# sort changesets by revision number |
| 22 |
has_many :changesets, :order => "#{Changeset.table_name}.id DESC", :foreign_key => 'repository_id'
|
|
| 22 |
has_many :changesets, |
|
| 23 |
:order => "#{Changeset.table_name}.id DESC",
|
|
| 24 |
:foreign_key => 'repository_id' |
|
| 23 | 25 |
|
| 24 |
attr_protected :root_url |
|
| 26 |
attr_protected :root_url
|
|
| 25 | 27 |
# validates_presence_of :url |
| 26 | 28 |
|
| 27 |
FETCH_AT_ONCE = 100 # number of changesets to fetch at once |
|
| 29 |
# number of changesets to fetch at once |
|
| 30 |
FETCH_AT_ONCE = 100 |
|
| 28 | 31 |
|
| 29 | 32 |
def self.human_attribute_name(attribute_key_name) |
| 30 | 33 |
attr_name = attribute_key_name |
| ... | ... | |
| 46 | 49 |
true |
| 47 | 50 |
end |
| 48 | 51 |
|
| 52 |
def supports_revision_graph? |
|
| 53 |
true |
|
| 54 |
end |
|
| 55 |
|
|
| 49 | 56 |
def repo_log_encoding |
| 50 | 57 |
'UTF-8' |
| 51 | 58 |
end |
| ... | ... | |
| 84 | 91 |
# Sqlite3 and PostgreSQL pass. |
| 85 | 92 |
# Is this MySQL bug? |
| 86 | 93 |
def latest_changesets(path, rev, limit=10) |
| 87 |
changesets.find(:all, :include => :user, |
|
| 94 |
changesets.find(:all, |
|
| 95 |
:include => :user, |
|
| 88 | 96 |
:conditions => latest_changesets_cond(path, rev, limit), |
| 89 |
:limit => limit, :order => "#{Changeset.table_name}.id DESC")
|
|
| 97 |
:limit => limit, |
|
| 98 |
:order => "#{Changeset.table_name}.id DESC")
|
|
| 90 | 99 |
end |
| 91 | 100 |
|
| 92 | 101 |
def latest_changesets_cond(path, rev, limit) |
| ... | ... | |
| 108 | 117 |
cond << "#{Changeset.table_name}.id <= ?"
|
| 109 | 118 |
args << last.id |
| 110 | 119 |
end |
| 111 |
|
|
| 112 | 120 |
unless path.blank? |
| 113 | 121 |
cond << "EXISTS (SELECT * FROM #{Change.table_name}
|
| 114 | 122 |
WHERE #{Change.table_name}.changeset_id = #{Changeset.table_name}.id
|
| 115 | 123 |
AND (#{Change.table_name}.path = ?
|
| 116 | 124 |
OR #{Change.table_name}.path LIKE ? ESCAPE ?))"
|
| 117 | 125 |
args << path.with_leading_slash |
| 118 |
args << "#{path.with_leading_slash.gsub(/[%_\\]/) { |s| "\\#{s}" }}/%" << '\\'
|
|
| 126 |
args << "#{path.with_leading_slash.gsub(%r{[%_\\]}) { |s| "\\#{s}" }}/%" << '\\'
|
|
| 119 | 127 |
end |
| 120 |
|
|
| 121 | 128 |
[cond.join(' AND '), *args] unless cond.empty?
|
| 122 | 129 |
end |
| 123 | 130 |
private :latest_changesets_cond |
| ... | ... | |
| 125 | 132 |
def fetch_changesets |
| 126 | 133 |
return if scm.info.nil? |
| 127 | 134 |
scm_rev = scm.info.lastrev.revision.to_i |
| 128 |
db_rev = latest_changeset ? latest_changeset.revision.to_i : -1 |
|
| 135 |
db_rev = latest_changeset ? latest_changeset.revision.to_i : -1
|
|
| 129 | 136 |
return unless db_rev < scm_rev # already up-to-date |
| 130 | 137 |
|
| 131 | 138 |
logger.debug "Fetching changesets for repository #{url}" if logger
|
| 132 | 139 |
(db_rev + 1).step(scm_rev, FETCH_AT_ONCE) do |i| |
| 133 | 140 |
transaction do |
| 134 | 141 |
scm.each_revision('', i, [i + FETCH_AT_ONCE - 1, scm_rev].min) do |re|
|
| 135 |
cs = Changeset.create(:repository => self, |
|
| 136 |
:revision => re.revision, |
|
| 137 |
:scmid => re.scmid, |
|
| 138 |
:committer => re.author, |
|
| 142 |
cs = Changeset.create(:repository => self,
|
|
| 143 |
:revision => re.revision,
|
|
| 144 |
:scmid => re.scmid,
|
|
| 145 |
:committer => re.author,
|
|
| 139 | 146 |
:committed_on => re.time, |
| 140 |
:comments => re.message) |
|
| 147 |
:comments => re.message)
|
|
| 141 | 148 |
re.paths.each { |e| cs.create_change(e) }
|
| 149 |
parents = {}
|
|
| 150 |
parents[cs] = re.parents unless re.parents.nil? |
|
| 151 |
parents.each do |ch, chparents| |
|
| 152 |
ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
|
|
| 153 |
end |
|
| 142 | 154 |
end |
| 143 | 155 |
end |
| 144 | 156 |
end |
| 145 |
self |
|
| 146 | 157 |
end |
| 147 | 158 |
end |
| app/models/repository/mercurial.rb.rej | ||
|---|---|---|
| 1 |
--- app/models/repository/mercurial.rb |
|
| 2 |
+++ app/models/repository/mercurial.rb |
|
| 3 |
@@ -78,11 +78,7 @@ |
|
| 4 |
:comments => revision.message) |
|
| 5 |
|
|
| 6 |
revision.paths.each do |change| |
|
| 7 |
- Change.create(:changeset => changeset, |
|
| 8 |
- :action => change[:action], |
|
| 9 |
- :path => change[:path], |
|
| 10 |
- :from_path => change[:from_path], |
|
| 11 |
- :from_revision => change[:from_revision]) |
|
| 12 |
+ changeset.create_change(change) |
|
| 13 |
end |
|
| 14 |
end |
|
| 15 |
end unless revisions.nil? |
|
| app/models/repository/subversion.rb.rej | ||
|---|---|---|
| 1 |
--- app/models/repository/subversion.rb |
|
| 2 |
+++ app/models/repository/subversion.rb |
|
| 3 |
@@ -63,11 +63,7 @@ |
|
| 4 |
:comments => revision.message) |
|
| 5 |
|
|
| 6 |
revision.paths.each do |change| |
|
| 7 |
- Change.create(:changeset => changeset, |
|
| 8 |
- :action => change[:action], |
|
| 9 |
- :path => change[:path], |
|
| 10 |
- :from_path => change[:from_path], |
|
| 11 |
- :from_revision => change[:from_revision]) |
|
| 12 |
+ changeset.create_change(change) |
|
| 13 |
end unless changeset.new_record? |
|
| 14 |
end |
|
| 15 |
end unless revisions.nil? |
|
Also available in: Unified diff