##// END OF EJS Templates
Adds support for file viewing with Darcs 2.0+ (patch #1799 by Ralph Lange slightly edited)....
Jean-Philippe Lang -
r1758:d93f96765b6f
parent child
Show More
@@ -1,90 +1,100
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/darcs_adapter'
18 require 'redmine/scm/adapters/darcs_adapter'
19
19
20 class Repository::Darcs < Repository
20 class Repository::Darcs < Repository
21 validates_presence_of :url
21 validates_presence_of :url
22
22
23 def scm_adapter
23 def scm_adapter
24 Redmine::Scm::Adapters::DarcsAdapter
24 Redmine::Scm::Adapters::DarcsAdapter
25 end
25 end
26
26
27 def self.scm_name
27 def self.scm_name
28 'Darcs'
28 'Darcs'
29 end
29 end
30
30
31 def entry(path=nil, identifier=nil)
32 patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
33 scm.entry(path, patch.nil? ? nil : patch.scmid)
34 end
35
31 def entries(path=nil, identifier=nil)
36 def entries(path=nil, identifier=nil)
32 patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
37 patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
33 entries = scm.entries(path, patch.nil? ? nil : patch.scmid)
38 entries = scm.entries(path, patch.nil? ? nil : patch.scmid)
34 if entries
39 if entries
35 entries.each do |entry|
40 entries.each do |entry|
36 # Search the DB for the entry's last change
41 # Search the DB for the entry's last change
37 changeset = changesets.find_by_scmid(entry.lastrev.scmid) if entry.lastrev && !entry.lastrev.scmid.blank?
42 changeset = changesets.find_by_scmid(entry.lastrev.scmid) if entry.lastrev && !entry.lastrev.scmid.blank?
38 if changeset
43 if changeset
39 entry.lastrev.identifier = changeset.revision
44 entry.lastrev.identifier = changeset.revision
40 entry.lastrev.name = changeset.revision
45 entry.lastrev.name = changeset.revision
41 entry.lastrev.time = changeset.committed_on
46 entry.lastrev.time = changeset.committed_on
42 entry.lastrev.author = changeset.committer
47 entry.lastrev.author = changeset.committer
43 end
48 end
44 end
49 end
45 end
50 end
46 entries
51 entries
47 end
52 end
48
53
54 def cat(path, identifier=nil)
55 patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
56 scm.cat(path, patch.nil? ? nil : patch.scmid)
57 end
58
49 def diff(path, rev, rev_to)
59 def diff(path, rev, rev_to)
50 patch_from = changesets.find_by_revision(rev)
60 patch_from = changesets.find_by_revision(rev)
51 return nil if patch_from.nil?
61 return nil if patch_from.nil?
52 patch_to = changesets.find_by_revision(rev_to) if rev_to
62 patch_to = changesets.find_by_revision(rev_to) if rev_to
53 if path.blank?
63 if path.blank?
54 path = patch_from.changes.collect{|change| change.path}.join(' ')
64 path = patch_from.changes.collect{|change| change.path}.join(' ')
55 end
65 end
56 patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil
66 patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil
57 end
67 end
58
68
59 def fetch_changesets
69 def fetch_changesets
60 scm_info = scm.info
70 scm_info = scm.info
61 if scm_info
71 if scm_info
62 db_last_id = latest_changeset ? latest_changeset.scmid : nil
72 db_last_id = latest_changeset ? latest_changeset.scmid : nil
63 next_rev = latest_changeset ? latest_changeset.revision.to_i + 1 : 1
73 next_rev = latest_changeset ? latest_changeset.revision.to_i + 1 : 1
64 # latest revision in the repository
74 # latest revision in the repository
65 scm_revision = scm_info.lastrev.scmid
75 scm_revision = scm_info.lastrev.scmid
66 unless changesets.find_by_scmid(scm_revision)
76 unless changesets.find_by_scmid(scm_revision)
67 revisions = scm.revisions('', db_last_id, nil, :with_path => true)
77 revisions = scm.revisions('', db_last_id, nil, :with_path => true)
68 transaction do
78 transaction do
69 revisions.reverse_each do |revision|
79 revisions.reverse_each do |revision|
70 changeset = Changeset.create(:repository => self,
80 changeset = Changeset.create(:repository => self,
71 :revision => next_rev,
81 :revision => next_rev,
72 :scmid => revision.scmid,
82 :scmid => revision.scmid,
73 :committer => revision.author,
83 :committer => revision.author,
74 :committed_on => revision.time,
84 :committed_on => revision.time,
75 :comments => revision.message)
85 :comments => revision.message)
76
86
77 revision.paths.each do |change|
87 revision.paths.each do |change|
78 Change.create(:changeset => changeset,
88 Change.create(:changeset => changeset,
79 :action => change[:action],
89 :action => change[:action],
80 :path => change[:path],
90 :path => change[:path],
81 :from_path => change[:from_path],
91 :from_path => change[:from_path],
82 :from_revision => change[:from_revision])
92 :from_revision => change[:from_revision])
83 end
93 end
84 next_rev += 1
94 next_rev += 1
85 end if revisions
95 end if revisions
86 end
96 end
87 end
97 end
88 end
98 end
89 end
99 end
90 end
100 end
@@ -1,45 +1,45
1 Creating test repositories
1 Creating test repositories
2 ===================
2 ===================
3
3
4 mkdir tmp/test
4 mkdir tmp/test
5
5
6 Subversion
6 Subversion
7 ----------
7 ----------
8 svnadmin create tmp/test/subversion_repository
8 svnadmin create tmp/test/subversion_repository
9 gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load tmp/test/subversion_repository
9 gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load tmp/test/subversion_repository
10
10
11 CVS
11 CVS
12 ---
12 ---
13 gunzip < test/fixtures/repositories/cvs_repository.tar.gz | tar -xv -C tmp/test
13 gunzip < test/fixtures/repositories/cvs_repository.tar.gz | tar -xv -C tmp/test
14
14
15 Bazaar
15 Bazaar
16 ------
16 ------
17 gunzip < test/fixtures/repositories/bazaar_repository.tar.gz | tar -xv -C tmp/test
17 gunzip < test/fixtures/repositories/bazaar_repository.tar.gz | tar -xv -C tmp/test
18
18
19 Mercurial
19 Mercurial
20 ---------
20 ---------
21 gunzip < test/fixtures/repositories/mercurial_repository.tar.gz | tar -xv -C tmp/test
21 gunzip < test/fixtures/repositories/mercurial_repository.tar.gz | tar -xv -C tmp/test
22
22
23 Git
23 Git
24 ---
24 ---
25 gunzip < test/fixtures/repositories/git_repository.tar.gz | tar -xv -C tmp/test
25 gunzip < test/fixtures/repositories/git_repository.tar.gz | tar -xv -C tmp/test
26
26
27 Darcs
27 Darcs (2.0+ required)
28 -----
28 ---------------------
29 gunzip < test/fixtures/repositories/darcs_repository.tar.gz | tar -xv -C tmp/test
29 gunzip < test/fixtures/repositories/darcs_repository.tar.gz | tar -xv -C tmp/test
30
30
31 FileSystem
31 FileSystem
32 ----------
32 ----------
33 gunzip < test/fixtures/repositories/filesystem_repository.tar.gz | tar -xv -C tmp/test
33 gunzip < test/fixtures/repositories/filesystem_repository.tar.gz | tar -xv -C tmp/test
34
34
35
35
36 Running Tests
36 Running Tests
37 =============
37 =============
38
38
39 Run
39 Run
40
40
41 rake --tasks | grep test
41 rake --tasks | grep test
42
42
43 to see available tests.
43 to see available tests.
44
44
45 RAILS_ENV=test rake test will run tests.
45 RAILS_ENV=test rake test will run tests.
@@ -1,156 +1,189
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/abstract_adapter'
18 require 'redmine/scm/adapters/abstract_adapter'
19 require 'rexml/document'
19 require 'rexml/document'
20
20
21 module Redmine
21 module Redmine
22 module Scm
22 module Scm
23 module Adapters
23 module Adapters
24 class DarcsAdapter < AbstractAdapter
24 class DarcsAdapter < AbstractAdapter
25 # Darcs executable name
25 # Darcs executable name
26 DARCS_BIN = "darcs"
26 DARCS_BIN = "darcs"
27
27
28 class << self
29 def client_version
30 @@client_version ||= (darcs_binary_version || [])
31 end
32
33 def darcs_binary_version
34 cmd = "#{DARCS_BIN} --version"
35 version = nil
36 shellout(cmd) do |io|
37 # Read darcs version in first returned line
38 if m = io.gets.match(%r{((\d+\.)+\d+)})
39 version = m[0].scan(%r{\d+}).collect(&:to_i)
40 end
41 end
42 return nil if $? && $?.exitstatus != 0
43 version
44 end
45 end
46
28 def initialize(url, root_url=nil, login=nil, password=nil)
47 def initialize(url, root_url=nil, login=nil, password=nil)
29 @url = url
48 @url = url
30 @root_url = url
49 @root_url = url
31 end
50 end
32
51
33 def supports_cat?
52 def supports_cat?
34 false
53 # cat supported in darcs 2.0.0 and higher
54 self.class.client_version_above?([2, 0, 0])
35 end
55 end
36
56
37 # Get info about the svn repository
57 # Get info about the darcs repository
38 def info
58 def info
39 rev = revisions(nil,nil,nil,{:limit => 1})
59 rev = revisions(nil,nil,nil,{:limit => 1})
40 rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil
60 rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil
41 end
61 end
42
62
43 # Returns an Entries collection
63 # Returns an Entries collection
44 # or nil if the given path doesn't exist in the repository
64 # or nil if the given path doesn't exist in the repository
45 def entries(path=nil, identifier=nil)
65 def entries(path=nil, identifier=nil)
46 path_prefix = (path.blank? ? '' : "#{path}/")
66 path_prefix = (path.blank? ? '' : "#{path}/")
47 path = '.' if path.blank?
67 path = '.' if path.blank?
48 entries = Entries.new
68 entries = Entries.new
49 cmd = "#{DARCS_BIN} annotate --repodir #{@url} --xml-output"
69 cmd = "#{DARCS_BIN} annotate --repodir #{@url} --xml-output"
50 cmd << " --match \"hash #{identifier}\"" if identifier
70 cmd << " --match \"hash #{identifier}\"" if identifier
51 cmd << " #{path}"
71 cmd << " #{path}"
52 shellout(cmd) do |io|
72 shellout(cmd) do |io|
53 begin
73 begin
54 doc = REXML::Document.new(io)
74 doc = REXML::Document.new(io)
55 if doc.root.name == 'directory'
75 if doc.root.name == 'directory'
56 doc.elements.each('directory/*') do |element|
76 doc.elements.each('directory/*') do |element|
57 next unless ['file', 'directory'].include? element.name
77 next unless ['file', 'directory'].include? element.name
58 entries << entry_from_xml(element, path_prefix)
78 entries << entry_from_xml(element, path_prefix)
59 end
79 end
60 elsif doc.root.name == 'file'
80 elsif doc.root.name == 'file'
61 entries << entry_from_xml(doc.root, path_prefix)
81 entries << entry_from_xml(doc.root, path_prefix)
62 end
82 end
63 rescue
83 rescue
64 end
84 end
65 end
85 end
66 return nil if $? && $?.exitstatus != 0
86 return nil if $? && $?.exitstatus != 0
67 entries.sort_by_name
87 entries.sort_by_name
68 end
88 end
69
89
70 def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
90 def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
71 path = '.' if path.blank?
91 path = '.' if path.blank?
72 revisions = Revisions.new
92 revisions = Revisions.new
73 cmd = "#{DARCS_BIN} changes --repodir #{@url} --xml-output"
93 cmd = "#{DARCS_BIN} changes --repodir #{@url} --xml-output"
74 cmd << " --from-match \"hash #{identifier_from}\"" if identifier_from
94 cmd << " --from-match \"hash #{identifier_from}\"" if identifier_from
75 cmd << " --last #{options[:limit].to_i}" if options[:limit]
95 cmd << " --last #{options[:limit].to_i}" if options[:limit]
76 shellout(cmd) do |io|
96 shellout(cmd) do |io|
77 begin
97 begin
78 doc = REXML::Document.new(io)
98 doc = REXML::Document.new(io)
79 doc.elements.each("changelog/patch") do |patch|
99 doc.elements.each("changelog/patch") do |patch|
80 message = patch.elements['name'].text
100 message = patch.elements['name'].text
81 message << "\n" + patch.elements['comment'].text.gsub(/\*\*\*END OF DESCRIPTION\*\*\*.*\z/m, '') if patch.elements['comment']
101 message << "\n" + patch.elements['comment'].text.gsub(/\*\*\*END OF DESCRIPTION\*\*\*.*\z/m, '') if patch.elements['comment']
82 revisions << Revision.new({:identifier => nil,
102 revisions << Revision.new({:identifier => nil,
83 :author => patch.attributes['author'],
103 :author => patch.attributes['author'],
84 :scmid => patch.attributes['hash'],
104 :scmid => patch.attributes['hash'],
85 :time => Time.parse(patch.attributes['local_date']),
105 :time => Time.parse(patch.attributes['local_date']),
86 :message => message,
106 :message => message,
87 :paths => (options[:with_path] ? get_paths_for_patch(patch.attributes['hash']) : nil)
107 :paths => (options[:with_path] ? get_paths_for_patch(patch.attributes['hash']) : nil)
88 })
108 })
89 end
109 end
90 rescue
110 rescue
91 end
111 end
92 end
112 end
93 return nil if $? && $?.exitstatus != 0
113 return nil if $? && $?.exitstatus != 0
94 revisions
114 revisions
95 end
115 end
96
116
97 def diff(path, identifier_from, identifier_to=nil)
117 def diff(path, identifier_from, identifier_to=nil)
98 path = '*' if path.blank?
118 path = '*' if path.blank?
99 cmd = "#{DARCS_BIN} diff --repodir #{@url}"
119 cmd = "#{DARCS_BIN} diff --repodir #{@url}"
100 if identifier_to.nil?
120 if identifier_to.nil?
101 cmd << " --match \"hash #{identifier_from}\""
121 cmd << " --match \"hash #{identifier_from}\""
102 else
122 else
103 cmd << " --to-match \"hash #{identifier_from}\""
123 cmd << " --to-match \"hash #{identifier_from}\""
104 cmd << " --from-match \"hash #{identifier_to}\""
124 cmd << " --from-match \"hash #{identifier_to}\""
105 end
125 end
106 cmd << " -u #{path}"
126 cmd << " -u #{path}"
107 diff = []
127 diff = []
108 shellout(cmd) do |io|
128 shellout(cmd) do |io|
109 io.each_line do |line|
129 io.each_line do |line|
110 diff << line
130 diff << line
111 end
131 end
112 end
132 end
113 return nil if $? && $?.exitstatus != 0
133 return nil if $? && $?.exitstatus != 0
114 diff
134 diff
115 end
135 end
116
136
137 def cat(path, identifier=nil)
138 cmd = "#{DARCS_BIN} show content --repodir #{@url}"
139 cmd << " --match \"hash #{identifier}\"" if identifier
140 cmd << " #{shell_quote path}"
141 cat = nil
142 shellout(cmd) do |io|
143 io.binmode
144 cat = io.read
145 end
146 return nil if $? && $?.exitstatus != 0
147 cat
148 end
149
117 private
150 private
118
151
119 def entry_from_xml(element, path_prefix)
152 def entry_from_xml(element, path_prefix)
120 Entry.new({:name => element.attributes['name'],
153 Entry.new({:name => element.attributes['name'],
121 :path => path_prefix + element.attributes['name'],
154 :path => path_prefix + element.attributes['name'],
122 :kind => element.name == 'file' ? 'file' : 'dir',
155 :kind => element.name == 'file' ? 'file' : 'dir',
123 :size => nil,
156 :size => nil,
124 :lastrev => Revision.new({
157 :lastrev => Revision.new({
125 :identifier => nil,
158 :identifier => nil,
126 :scmid => element.elements['modified'].elements['patch'].attributes['hash']
159 :scmid => element.elements['modified'].elements['patch'].attributes['hash']
127 })
160 })
128 })
161 })
129 end
162 end
130
163
131 # Retrieve changed paths for a single patch
164 # Retrieve changed paths for a single patch
132 def get_paths_for_patch(hash)
165 def get_paths_for_patch(hash)
133 cmd = "#{DARCS_BIN} annotate --repodir #{@url} --summary --xml-output"
166 cmd = "#{DARCS_BIN} annotate --repodir #{@url} --summary --xml-output"
134 cmd << " --match \"hash #{hash}\" "
167 cmd << " --match \"hash #{hash}\" "
135 paths = []
168 paths = []
136 shellout(cmd) do |io|
169 shellout(cmd) do |io|
137 begin
170 begin
138 # Darcs xml output has multiple root elements in this case (tested with darcs 1.0.7)
171 # Darcs xml output has multiple root elements in this case (tested with darcs 1.0.7)
139 # A root element is added so that REXML doesn't raise an error
172 # A root element is added so that REXML doesn't raise an error
140 doc = REXML::Document.new("<fake_root>" + io.read + "</fake_root>")
173 doc = REXML::Document.new("<fake_root>" + io.read + "</fake_root>")
141 doc.elements.each('fake_root/summary/*') do |modif|
174 doc.elements.each('fake_root/summary/*') do |modif|
142 paths << {:action => modif.name[0,1].upcase,
175 paths << {:action => modif.name[0,1].upcase,
143 :path => "/" + modif.text.chomp.gsub(/^\s*/, '')
176 :path => "/" + modif.text.chomp.gsub(/^\s*/, '')
144 }
177 }
145 end
178 end
146 rescue
179 rescue
147 end
180 end
148 end
181 end
149 paths
182 paths
150 rescue CommandFailed
183 rescue CommandFailed
151 paths
184 paths
152 end
185 end
153 end
186 end
154 end
187 end
155 end
188 end
156 end
189 end
@@ -1,55 +1,62
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 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 File.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19
19
20 class RepositoryDarcsTest < Test::Unit::TestCase
20 class RepositoryDarcsTest < Test::Unit::TestCase
21 fixtures :projects
21 fixtures :projects
22
22
23 # No '..' in the repository path
23 # No '..' in the repository path
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository'
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository'
25
25
26 def setup
26 def setup
27 @project = Project.find(1)
27 @project = Project.find(1)
28 assert @repository = Repository::Darcs.create(:project => @project, :url => REPOSITORY_PATH)
28 assert @repository = Repository::Darcs.create(:project => @project, :url => REPOSITORY_PATH)
29 end
29 end
30
30
31 if File.directory?(REPOSITORY_PATH)
31 if File.directory?(REPOSITORY_PATH)
32 def test_fetch_changesets_from_scratch
32 def test_fetch_changesets_from_scratch
33 @repository.fetch_changesets
33 @repository.fetch_changesets
34 @repository.reload
34 @repository.reload
35
35
36 assert_equal 6, @repository.changesets.count
36 assert_equal 6, @repository.changesets.count
37 assert_equal 13, @repository.changes.count
37 assert_equal 13, @repository.changes.count
38 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
38 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
39 end
39 end
40
40
41 def test_fetch_changesets_incremental
41 def test_fetch_changesets_incremental
42 @repository.fetch_changesets
42 @repository.fetch_changesets
43 # Remove changesets with revision > 3
43 # Remove changesets with revision > 3
44 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
44 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
45 @repository.reload
45 @repository.reload
46 assert_equal 3, @repository.changesets.count
46 assert_equal 3, @repository.changesets.count
47
47
48 @repository.fetch_changesets
48 @repository.fetch_changesets
49 assert_equal 6, @repository.changesets.count
49 assert_equal 6, @repository.changesets.count
50 end
50 end
51
52 def test_cat
53 @repository.fetch_changesets
54 cat = @repository.cat("sources/welcome_controller.rb", 2)
55 assert_not_nil cat
56 assert cat.include?('class WelcomeController < ApplicationController')
57 end
51 else
58 else
52 puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
59 puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
53 def test_fake; assert true end
60 def test_fake; assert true end
54 end
61 end
55 end
62 end
General Comments 0
You need to be logged in to leave comments. Login now