##// END OF EJS Templates
Subversion repository now accepts svn+ssh url....
Jean-Philippe Lang -
r740:a42a115b8fa2
parent child
Show More
@@ -1,69 +1,69
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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'
19
19
20 class Repository::Subversion < Repository
20 class Repository::Subversion < Repository
21 attr_protected :root_url
21 attr_protected :root_url
22 validates_presence_of :url
22 validates_presence_of :url
23 validates_format_of :url, :with => /^(http|https|svn|file):\/\/.+/i
23 validates_format_of :url, :with => /^(http|https|svn|svn\+ssh|file):\/\/.+/i
24
24
25 def scm_adapter
25 def scm_adapter
26 Redmine::Scm::Adapters::SubversionAdapter
26 Redmine::Scm::Adapters::SubversionAdapter
27 end
27 end
28
28
29 def self.scm_name
29 def self.scm_name
30 'Subversion'
30 'Subversion'
31 end
31 end
32
32
33 def fetch_changesets
33 def fetch_changesets
34 scm_info = scm.info
34 scm_info = scm.info
35 if scm_info
35 if scm_info
36 # latest revision found in database
36 # latest revision found in database
37 db_revision = latest_changeset ? latest_changeset.revision : 0
37 db_revision = latest_changeset ? latest_changeset.revision : 0
38 # latest revision in the repository
38 # latest revision in the repository
39 scm_revision = scm_info.lastrev.identifier.to_i
39 scm_revision = scm_info.lastrev.identifier.to_i
40 if db_revision < scm_revision
40 if db_revision < scm_revision
41 logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug?
41 logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug?
42 identifier_from = db_revision + 1
42 identifier_from = db_revision + 1
43 while (identifier_from <= scm_revision)
43 while (identifier_from <= scm_revision)
44 # loads changesets by batches of 200
44 # loads changesets by batches of 200
45 identifier_to = [identifier_from + 199, scm_revision].min
45 identifier_to = [identifier_from + 199, scm_revision].min
46 revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
46 revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
47 transaction do
47 transaction do
48 revisions.reverse_each do |revision|
48 revisions.reverse_each do |revision|
49 changeset = Changeset.create(:repository => self,
49 changeset = Changeset.create(:repository => self,
50 :revision => revision.identifier,
50 :revision => revision.identifier,
51 :committer => revision.author,
51 :committer => revision.author,
52 :committed_on => revision.time,
52 :committed_on => revision.time,
53 :comments => revision.message)
53 :comments => revision.message)
54
54
55 revision.paths.each do |change|
55 revision.paths.each do |change|
56 Change.create(:changeset => changeset,
56 Change.create(:changeset => changeset,
57 :action => change[:action],
57 :action => change[:action],
58 :path => change[:path],
58 :path => change[:path],
59 :from_path => change[:from_path],
59 :from_path => change[:from_path],
60 :from_revision => change[:from_revision])
60 :from_revision => change[:from_revision])
61 end
61 end
62 end
62 end
63 end unless revisions.nil?
63 end unless revisions.nil?
64 identifier_from = identifier_to + 1
64 identifier_from = identifier_to + 1
65 end
65 end
66 end
66 end
67 end
67 end
68 end
68 end
69 end
69 end
General Comments 0
You need to be logged in to leave comments. Login now