@@ -1,86 +1,91 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require 'redmine/scm/adapters/bazaar_adapter' |
|
19 | 19 | |
|
20 | 20 | class Repository::Bazaar < Repository |
|
21 | 21 | attr_protected :root_url |
|
22 | 22 | validates_presence_of :url |
|
23 | 23 | |
|
24 | 24 | def scm_adapter |
|
25 | 25 | Redmine::Scm::Adapters::BazaarAdapter |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | def self.scm_name |
|
29 | 29 | 'Bazaar' |
|
30 | 30 | end |
|
31 | 31 | |
|
32 | 32 | def entries(path=nil, identifier=nil) |
|
33 | 33 | entries = scm.entries(path, identifier) |
|
34 | 34 | if entries |
|
35 | 35 | entries.each do |e| |
|
36 | 36 | next if e.lastrev.revision.blank? |
|
37 | # Set the filesize unless browsing a specific revision | |
|
38 | if identifier.nil? && e.is_file? | |
|
39 | full_path = File.join(root_url, e.path) | |
|
40 | e.size = File.stat(full_path).size if File.file?(full_path) | |
|
41 | end | |
|
37 | 42 | c = Change.find(:first, |
|
38 | 43 | :include => :changeset, |
|
39 | 44 | :conditions => ["#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?", e.lastrev.revision, id], |
|
40 | 45 | :order => "#{Changeset.table_name}.revision DESC") |
|
41 | 46 | if c |
|
42 | 47 | e.lastrev.identifier = c.changeset.revision |
|
43 | 48 | e.lastrev.name = c.changeset.revision |
|
44 | 49 | e.lastrev.author = c.changeset.committer |
|
45 | 50 | end |
|
46 | 51 | end |
|
47 | 52 | end |
|
48 | 53 | end |
|
49 | 54 | |
|
50 | 55 | def fetch_changesets |
|
51 | 56 | scm_info = scm.info |
|
52 | 57 | if scm_info |
|
53 | 58 | # latest revision found in database |
|
54 | 59 | db_revision = latest_changeset ? latest_changeset.revision.to_i : 0 |
|
55 | 60 | # latest revision in the repository |
|
56 | 61 | scm_revision = scm_info.lastrev.identifier.to_i |
|
57 | 62 | if db_revision < scm_revision |
|
58 | 63 | logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug? |
|
59 | 64 | identifier_from = db_revision + 1 |
|
60 | 65 | while (identifier_from <= scm_revision) |
|
61 | 66 | # loads changesets by batches of 200 |
|
62 | 67 | identifier_to = [identifier_from + 199, scm_revision].min |
|
63 | 68 | revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true) |
|
64 | 69 | transaction do |
|
65 | 70 | revisions.reverse_each do |revision| |
|
66 | 71 | changeset = Changeset.create(:repository => self, |
|
67 | 72 | :revision => revision.identifier, |
|
68 | 73 | :committer => revision.author, |
|
69 | 74 | :committed_on => revision.time, |
|
70 | 75 | :scmid => revision.scmid, |
|
71 | 76 | :comments => revision.message) |
|
72 | 77 | |
|
73 | 78 | revision.paths.each do |change| |
|
74 | 79 | Change.create(:changeset => changeset, |
|
75 | 80 | :action => change[:action], |
|
76 | 81 | :path => change[:path], |
|
77 | 82 | :revision => change[:revision]) |
|
78 | 83 | end |
|
79 | 84 | end |
|
80 | 85 | end unless revisions.nil? |
|
81 | 86 | identifier_from = identifier_to + 1 |
|
82 | 87 | end |
|
83 | 88 | end |
|
84 | 89 | end |
|
85 | 90 | end |
|
86 | 91 | end |
General Comments 0
You need to be logged in to leave comments.
Login now