Mercurial > hg > soundsoftware-site
comparison app/models/repository/subversion.rb @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 051f544170fe |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
245:051f544170fe | 441:cbce1fd3b1b7 |
---|---|
1 # redMine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2007 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 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. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require 'redmine/scm/adapters/subversion_adapter' | 18 require 'redmine/scm/adapters/subversion_adapter' |
28 | 28 |
29 def self.scm_name | 29 def self.scm_name |
30 'Subversion' | 30 'Subversion' |
31 end | 31 end |
32 | 32 |
33 def supports_directory_revisions? | |
34 true | |
35 end | |
36 | |
33 def repo_log_encoding | 37 def repo_log_encoding |
34 'UTF-8' | 38 'UTF-8' |
35 end | 39 end |
36 | 40 |
37 def latest_changesets(path, rev, limit=10) | 41 def latest_changesets(path, rev, limit=10) |
38 revisions = scm.revisions(path, rev, nil, :limit => limit) | 42 revisions = scm.revisions(path, rev, nil, :limit => limit) |
39 revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : [] | 43 revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : [] |
40 end | 44 end |
41 | 45 |
42 # Returns a path relative to the url of the repository | 46 # Returns a path relative to the url of the repository |
43 def relative_path(path) | 47 def relative_path(path) |
44 path.gsub(Regexp.new("^\/?#{Regexp.escape(relative_url)}"), '') | 48 path.gsub(Regexp.new("^\/?#{Regexp.escape(relative_url)}"), '') |
45 end | 49 end |
46 | 50 |
47 def fetch_changesets | 51 def fetch_changesets |
48 scm_info = scm.info | 52 scm_info = scm.info |
49 if scm_info | 53 if scm_info |
50 # latest revision found in database | 54 # latest revision found in database |
51 db_revision = latest_changeset ? latest_changeset.revision.to_i : 0 | 55 db_revision = latest_changeset ? latest_changeset.revision.to_i : 0 |
58 # loads changesets by batches of 200 | 62 # loads changesets by batches of 200 |
59 identifier_to = [identifier_from + 199, scm_revision].min | 63 identifier_to = [identifier_from + 199, scm_revision].min |
60 revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true) | 64 revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true) |
61 revisions.reverse_each do |revision| | 65 revisions.reverse_each do |revision| |
62 transaction do | 66 transaction do |
63 changeset = Changeset.create(:repository => self, | 67 changeset = Changeset.create(:repository => self, |
64 :revision => revision.identifier, | 68 :revision => revision.identifier, |
65 :committer => revision.author, | 69 :committer => revision.author, |
66 :committed_on => revision.time, | 70 :committed_on => revision.time, |
67 :comments => revision.message) | 71 :comments => revision.message) |
68 | 72 |
69 revision.paths.each do |change| | 73 revision.paths.each do |change| |
70 changeset.create_change(change) | 74 changeset.create_change(change) |
71 end unless changeset.new_record? | 75 end unless changeset.new_record? |
72 end | 76 end |
73 end unless revisions.nil? | 77 end unless revisions.nil? |
74 identifier_from = identifier_to + 1 | 78 identifier_from = identifier_to + 1 |
75 end | 79 end |
76 end | 80 end |
77 end | 81 end |
78 end | 82 end |
79 | 83 |
80 private | 84 private |
81 | 85 |
82 # Returns the relative url of the repository | 86 # Returns the relative url of the repository |
83 # Eg: root_url = file:///var/svn/foo | 87 # Eg: root_url = file:///var/svn/foo |
84 # url = file:///var/svn/foo/bar | 88 # url = file:///var/svn/foo/bar |
85 # => returns /bar | 89 # => returns /bar |
86 def relative_url | 90 def relative_url |