@@ -1,113 +1,113 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 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/darcs_adapter' |
|
19 | 19 | |
|
20 | 20 | class Repository::Darcs < Repository |
|
21 | 21 | validates_presence_of :url, :log_encoding |
|
22 | 22 | |
|
23 | 23 | def self.human_attribute_name(attribute_key_name, *args) |
|
24 | attr_name = attribute_key_name | |
|
24 | attr_name = attribute_key_name.to_s | |
|
25 | 25 | if attr_name == "url" |
|
26 | 26 | attr_name = "path_to_repository" |
|
27 | 27 | end |
|
28 | 28 | super(attr_name, *args) |
|
29 | 29 | end |
|
30 | 30 | |
|
31 | 31 | def self.scm_adapter_class |
|
32 | 32 | Redmine::Scm::Adapters::DarcsAdapter |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | def self.scm_name |
|
36 | 36 | 'Darcs' |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def supports_directory_revisions? |
|
40 | 40 | true |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | def entry(path=nil, identifier=nil) |
|
44 | 44 | patch = identifier.nil? ? nil : changesets.find_by_revision(identifier) |
|
45 | 45 | scm.entry(path, patch.nil? ? nil : patch.scmid) |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def entries(path=nil, identifier=nil) |
|
49 | 49 | patch = nil |
|
50 | 50 | if ! identifier.nil? |
|
51 | 51 | patch = changesets.find_by_revision(identifier) |
|
52 | 52 | return nil if patch.nil? |
|
53 | 53 | end |
|
54 | 54 | entries = scm.entries(path, patch.nil? ? nil : patch.scmid) |
|
55 | 55 | if entries |
|
56 | 56 | entries.each do |entry| |
|
57 | 57 | # Search the DB for the entry's last change |
|
58 | 58 | if entry.lastrev && !entry.lastrev.scmid.blank? |
|
59 | 59 | changeset = changesets.find_by_scmid(entry.lastrev.scmid) |
|
60 | 60 | end |
|
61 | 61 | if changeset |
|
62 | 62 | entry.lastrev.identifier = changeset.revision |
|
63 | 63 | entry.lastrev.name = changeset.revision |
|
64 | 64 | entry.lastrev.time = changeset.committed_on |
|
65 | 65 | entry.lastrev.author = changeset.committer |
|
66 | 66 | end |
|
67 | 67 | end |
|
68 | 68 | end |
|
69 | 69 | entries |
|
70 | 70 | end |
|
71 | 71 | |
|
72 | 72 | def cat(path, identifier=nil) |
|
73 | 73 | patch = identifier.nil? ? nil : changesets.find_by_revision(identifier.to_s) |
|
74 | 74 | scm.cat(path, patch.nil? ? nil : patch.scmid) |
|
75 | 75 | end |
|
76 | 76 | |
|
77 | 77 | def diff(path, rev, rev_to) |
|
78 | 78 | patch_from = changesets.find_by_revision(rev) |
|
79 | 79 | return nil if patch_from.nil? |
|
80 | 80 | patch_to = changesets.find_by_revision(rev_to) if rev_to |
|
81 | 81 | if path.blank? |
|
82 | 82 | path = patch_from.changes.collect{|change| change.path}.join(' ') |
|
83 | 83 | end |
|
84 | 84 | patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil |
|
85 | 85 | end |
|
86 | 86 | |
|
87 | 87 | def fetch_changesets |
|
88 | 88 | scm_info = scm.info |
|
89 | 89 | if scm_info |
|
90 | 90 | db_last_id = latest_changeset ? latest_changeset.scmid : nil |
|
91 | 91 | next_rev = latest_changeset ? latest_changeset.revision.to_i + 1 : 1 |
|
92 | 92 | # latest revision in the repository |
|
93 | 93 | scm_revision = scm_info.lastrev.scmid |
|
94 | 94 | unless changesets.find_by_scmid(scm_revision) |
|
95 | 95 | revisions = scm.revisions('', db_last_id, nil, :with_path => true) |
|
96 | 96 | transaction do |
|
97 | 97 | revisions.reverse_each do |revision| |
|
98 | 98 | changeset = Changeset.create(:repository => self, |
|
99 | 99 | :revision => next_rev, |
|
100 | 100 | :scmid => revision.scmid, |
|
101 | 101 | :committer => revision.author, |
|
102 | 102 | :committed_on => revision.time, |
|
103 | 103 | :comments => revision.message) |
|
104 | 104 | revision.paths.each do |change| |
|
105 | 105 | changeset.create_change(change) |
|
106 | 106 | end |
|
107 | 107 | next_rev += 1 |
|
108 | 108 | end if revisions |
|
109 | 109 | end |
|
110 | 110 | end |
|
111 | 111 | end |
|
112 | 112 | end |
|
113 | 113 | end |
General Comments 0
You need to be logged in to leave comments.
Login now