diff options
-rw-r--r-- | app/helpers/repositories_helper.rb | 11 | ||||
-rw-r--r-- | app/models/repository/darcs.rb | 114 | ||||
-rw-r--r-- | config/configuration.yml.example | 3 | ||||
-rw-r--r-- | config/settings.yml | 1 | ||||
-rwxr-xr-x | extra/svn/reposman.rb | 2 | ||||
-rw-r--r-- | lib/redmine.rb | 1 | ||||
-rw-r--r-- | lib/redmine/scm/adapters/darcs_adapter.rb | 239 | ||||
-rw-r--r-- | lib/tasks/testing.rake | 2 | ||||
-rw-r--r-- | test/functional/repositories_darcs_controller_test.rb | 179 | ||||
-rw-r--r-- | test/unit/helpers/application_helper_test.rb | 26 | ||||
-rw-r--r-- | test/unit/lib/redmine/scm/adapters/darcs_adapter_test.rb | 60 | ||||
-rw-r--r-- | test/unit/repository_darcs_test.rb | 129 | ||||
-rw-r--r-- | test/unit/repository_test.rb | 2 |
13 files changed, 4 insertions, 765 deletions
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 4778c79a1..314c0b29b 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -157,15 +157,6 @@ module RepositoriesHelper :onchange => "this.name='repository[password]';")) end - def darcs_field_tags(form, repository) - content_tag('p', form.text_field( - :url, :label => l(:field_path_to_repository), - :size => 60, :required => true, - :disabled => !repository.safe_attribute?('url')) + - scm_path_info_tag(repository)) + - scm_log_encoding_tag(form, repository) - end - def mercurial_field_tags(form, repository) content_tag('p', form.text_field( :url, :label => l(:field_path_to_repository), @@ -279,7 +270,7 @@ module RepositoriesHelper } end heads.sort! { |head1, head2| head1.to_s <=> head2.to_s } - space = nil + space = nil heads.each do |head| if commits_by_scmid.include? head.scmid space = index_head((space || -1) + 1, head, commits_by_scmid) diff --git a/app/models/repository/darcs.rb b/app/models/repository/darcs.rb deleted file mode 100644 index 8c1302ca2..000000000 --- a/app/models/repository/darcs.rb +++ /dev/null @@ -1,114 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2017 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -require 'redmine/scm/adapters/darcs_adapter' - -class Repository::Darcs < Repository - validates_presence_of :url, :log_encoding - - def self.human_attribute_name(attribute_key_name, *args) - attr_name = attribute_key_name.to_s - if attr_name == "url" - attr_name = "path_to_repository" - end - super(attr_name, *args) - end - - def self.scm_adapter_class - Redmine::Scm::Adapters::DarcsAdapter - end - - def self.scm_name - 'Darcs' - end - - def supports_directory_revisions? - true - end - - def entry(path=nil, identifier=nil) - patch = identifier.nil? ? nil : changesets.find_by_revision(identifier) - scm.entry(path, patch.nil? ? nil : patch.scmid) - end - - def scm_entries(path=nil, identifier=nil) - patch = nil - if ! identifier.nil? - patch = changesets.find_by_revision(identifier) - return nil if patch.nil? - end - entries = scm.entries(path, patch.nil? ? nil : patch.scmid) - if entries - entries.each do |entry| - # Search the DB for the entry's last change - if entry.lastrev && !entry.lastrev.scmid.blank? - changeset = changesets.find_by_scmid(entry.lastrev.scmid) - end - if changeset - entry.lastrev.identifier = changeset.revision - entry.lastrev.name = changeset.revision - entry.lastrev.time = changeset.committed_on - entry.lastrev.author = changeset.committer - end - end - end - entries - end - protected :scm_entries - - def cat(path, identifier=nil) - patch = identifier.nil? ? nil : changesets.find_by_revision(identifier.to_s) - scm.cat(path, patch.nil? ? nil : patch.scmid) - end - - def diff(path, rev, rev_to) - patch_from = changesets.find_by_revision(rev) - return nil if patch_from.nil? - patch_to = changesets.find_by_revision(rev_to) if rev_to - if path.blank? - path = patch_from.filechanges.collect{|change| change.path}.join(' ') - end - patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil - end - - def fetch_changesets - scm_info = scm.info - if scm_info - db_last_id = latest_changeset ? latest_changeset.scmid : nil - next_rev = latest_changeset ? latest_changeset.revision.to_i + 1 : 1 - # latest revision in the repository - scm_revision = scm_info.lastrev.scmid - unless changesets.find_by_scmid(scm_revision) - revisions = scm.revisions('', db_last_id, nil, :with_path => true) - transaction do - revisions.reverse_each do |revision| - changeset = Changeset.create(:repository => self, - :revision => next_rev, - :scmid => revision.scmid, - :committer => revision.author, - :committed_on => revision.time, - :comments => revision.message) - revision.paths.each do |change| - changeset.create_change(change) - end - next_rev += 1 - end if revisions - end - end - end - end -end diff --git a/config/configuration.yml.example b/config/configuration.yml.example index 3522ef695..e44e3c163 100644 --- a/config/configuration.yml.example +++ b/config/configuration.yml.example @@ -99,14 +99,12 @@ default: # scm_git_command: /usr/local/bin/git # (default: git) # scm_cvs_command: cvs # (default: cvs) # scm_bazaar_command: bzr.exe # (default: bzr) - # scm_darcs_command: darcs-1.0.9-i386-linux # (default: darcs) # scm_subversion_command: scm_mercurial_command: scm_git_command: scm_cvs_command: scm_bazaar_command: - scm_darcs_command: # SCM paths validation. # @@ -132,7 +130,6 @@ default: scm_git_path_regexp: scm_cvs_path_regexp: scm_bazaar_path_regexp: - scm_darcs_path_regexp: scm_filesystem_path_regexp: # Absolute path to the SCM commands errors (stderr) log file. diff --git a/config/settings.yml b/config/settings.yml index 03581a235..c10ae1acc 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -119,7 +119,6 @@ enabled_scm: serialized: true default: - Subversion - - Darcs - Mercurial - Cvs - Bazaar diff --git a/extra/svn/reposman.rb b/extra/svn/reposman.rb index 4f748acf0..aec5760d6 100755 --- a/extra/svn/reposman.rb +++ b/extra/svn/reposman.rb @@ -6,7 +6,7 @@ require 'etc' require 'rubygems' Version = "1.5" -SUPPORTED_SCM = %w( Subversion Darcs Mercurial Bazaar Git Filesystem ) +SUPPORTED_SCM = %w( Subversion Mercurial Bazaar Git Filesystem ) $verbose = 0 $quiet = false diff --git a/lib/redmine.rb b/lib/redmine.rb index 7773e3875..29d96c2b0 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -66,7 +66,6 @@ require 'redmine/hook/view_listener' require 'redmine/plugin' Redmine::Scm::Base.add "Subversion" -Redmine::Scm::Base.add "Darcs" Redmine::Scm::Base.add "Mercurial" Redmine::Scm::Base.add "Cvs" Redmine::Scm::Base.add "Bazaar" diff --git a/lib/redmine/scm/adapters/darcs_adapter.rb b/lib/redmine/scm/adapters/darcs_adapter.rb deleted file mode 100644 index dd0f4f5d3..000000000 --- a/lib/redmine/scm/adapters/darcs_adapter.rb +++ /dev/null @@ -1,239 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2017 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -require 'redmine/scm/adapters/abstract_adapter' -require 'rexml/document' - -module Redmine - module Scm - module Adapters - class DarcsAdapter < AbstractAdapter - # Darcs executable name - DARCS_BIN = Redmine::Configuration['scm_darcs_command'] || "darcs" - - class << self - def client_command - @@bin ||= DARCS_BIN - end - - def sq_bin - @@sq_bin ||= shell_quote_command - end - - def client_version - @@client_version ||= (darcs_binary_version || []) - end - - def client_available - !client_version.empty? - end - - def darcs_binary_version - darcsversion = darcs_binary_version_from_command_line.dup.force_encoding('ASCII-8BIT') - if m = darcsversion.match(%r{\A(.*?)((\d+\.)+\d+)}) - m[2].scan(%r{\d+}).collect(&:to_i) - end - end - - def darcs_binary_version_from_command_line - shellout("#{sq_bin} --version") { |io| io.read }.to_s - end - end - - def initialize(url, root_url=nil, login=nil, password=nil, - path_encoding=nil) - @url = url - @root_url = url - end - - def supports_cat? - # cat supported in darcs 2.0.0 and higher - self.class.client_version_above?([2, 0, 0]) - end - - # Get info about the darcs repository - def info - rev = revisions(nil,nil,nil,{:limit => 1}) - rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil - end - - # Returns an Entries collection - # or nil if the given path doesn't exist in the repository - def entries(path=nil, identifier=nil, options={}) - path_prefix = (path.blank? ? '' : "#{path}/") - if path.blank? - path = ( self.class.client_version_above?([2, 2, 0]) ? @url : '.' ) - end - entries = Entries.new - cmd = "#{self.class.sq_bin} annotate --repodir #{shell_quote @url} --xml-output" - cmd << " --match #{shell_quote("hash #{identifier}")}" if identifier - cmd << " #{shell_quote path}" - shellout(cmd) do |io| - begin - doc = REXML::Document.new(io) - if doc.root.name == 'directory' - doc.elements.each('directory/*') do |element| - next unless ['file', 'directory'].include? element.name - entries << entry_from_xml(element, path_prefix) - end - elsif doc.root.name == 'file' - entries << entry_from_xml(doc.root, path_prefix) - end - rescue - end - end - return nil if $? && $?.exitstatus != 0 - entries.compact! - entries.sort_by_name - end - - def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) - path = '.' if path.blank? - revisions = Revisions.new - cmd = "#{self.class.sq_bin} changes --repodir #{shell_quote @url} --xml-output" - cmd << " --from-match #{shell_quote("hash #{identifier_from}")}" if identifier_from - cmd << " --last #{options[:limit].to_i}" if options[:limit] - shellout(cmd) do |io| - begin - doc = REXML::Document.new(io) - doc.elements.each("changelog/patch") do |patch| - message = patch.elements['name'].text - message << "\n" + patch.elements['comment'].text.gsub(/\*\*\*END OF DESCRIPTION\*\*\*.*\z/m, '') if patch.elements['comment'] - revisions << Revision.new({:identifier => nil, - :author => patch.attributes['author'], - :scmid => patch.attributes['hash'], - :time => Time.parse(patch.attributes['local_date']), - :message => message, - :paths => (options[:with_path] ? get_paths_for_patch(patch.attributes['hash']) : nil) - }) - end - rescue - end - end - return nil if $? && $?.exitstatus != 0 - revisions - end - - def diff(path, identifier_from, identifier_to=nil) - path = '*' if path.blank? - cmd = "#{self.class.sq_bin} diff --repodir #{shell_quote @url}" - if identifier_to.nil? - cmd << " --match #{shell_quote("hash #{identifier_from}")}" - else - cmd << " --to-match #{shell_quote("hash #{identifier_from}")}" - cmd << " --from-match #{shell_quote("hash #{identifier_to}")}" - end - cmd << " -u #{shell_quote path}" - diff = [] - shellout(cmd) do |io| - io.each_line do |line| - diff << line - end - end - return nil if $? && $?.exitstatus != 0 - diff - end - - def cat(path, identifier=nil) - cmd = "#{self.class.sq_bin} show content --repodir #{shell_quote @url}" - cmd << " --match #{shell_quote("hash #{identifier}")}" if identifier - cmd << " #{shell_quote path}" - cat = nil - shellout(cmd) do |io| - io.binmode - cat = io.read - end - return nil if $? && $?.exitstatus != 0 - cat - end - - private - - # Returns an Entry from the given XML element - # or nil if the entry was deleted - def entry_from_xml(element, path_prefix) - modified_element = element.elements['modified'] - if modified_element.elements['modified_how'].text.match(/removed/) - return nil - end - - Entry.new({:name => element.attributes['name'], - :path => path_prefix + element.attributes['name'], - :kind => element.name == 'file' ? 'file' : 'dir', - :size => nil, - :lastrev => Revision.new({ - :identifier => nil, - :scmid => modified_element.elements['patch'].attributes['hash'] - }) - }) - end - - def get_paths_for_patch(hash) - paths = get_paths_for_patch_raw(hash) - if self.class.client_version_above?([2, 4]) - orig_paths = paths - paths = [] - add_paths = [] - add_paths_name = [] - mod_paths = [] - other_paths = [] - orig_paths.each do |path| - if path[:action] == 'A' - add_paths << path - add_paths_name << path[:path] - elsif path[:action] == 'M' - mod_paths << path - else - other_paths << path - end - end - add_paths_name.each do |add_path| - mod_paths.delete_if { |m| m[:path] == add_path } - end - paths.concat add_paths - paths.concat mod_paths - paths.concat other_paths - end - paths - end - - # Retrieve changed paths for a single patch - def get_paths_for_patch_raw(hash) - cmd = "#{self.class.sq_bin} annotate --repodir #{shell_quote @url} --summary --xml-output" - cmd << " --match #{shell_quote("hash #{hash}")} " - paths = [] - shellout(cmd) do |io| - begin - # Darcs xml output has multiple root elements in this case (tested with darcs 1.0.7) - # A root element is added so that REXML doesn't raise an error - doc = REXML::Document.new("<fake_root>" + io.read + "</fake_root>") - doc.elements.each('fake_root/summary/*') do |modif| - paths << {:action => modif.name[0,1].upcase, - :path => "/" + modif.text.chomp.gsub(/^\s*/, '') - } - end - rescue - end - end - paths - rescue CommandFailed - paths - end - end - end - end -end diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake index 47364c82c..de0d5f24c 100644 --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake @@ -26,7 +26,7 @@ namespace :test do FileUtils.mkdir_p Rails.root + '/tmp/test' end - supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem] + supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :filesystem] desc "Creates a test subversion repository" task :subversion => :create_dir do diff --git a/test/functional/repositories_darcs_controller_test.rb b/test/functional/repositories_darcs_controller_test.rb deleted file mode 100644 index 7b71da4dc..000000000 --- a/test/functional/repositories_darcs_controller_test.rb +++ /dev/null @@ -1,179 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2017 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -require File.expand_path('../../test_helper', __FILE__) - -class RepositoriesDarcsControllerTest < Redmine::RepositoryControllerTest - tests RepositoriesController - - fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, - :repositories, :enabled_modules - - REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s - PRJ_ID = 3 - NUM_REV = 6 - - def setup - super - User.current = nil - @project = Project.find(PRJ_ID) - @repository = Repository::Darcs.create( - :project => @project, - :url => REPOSITORY_PATH, - :log_encoding => 'UTF-8' - ) - assert @repository - end - - if File.directory?(REPOSITORY_PATH) - def test_get_new - @request.session[:user_id] = 1 - @project.repository.destroy - get :new, :params => { - :project_id => 'subproject1', - :repository_scm => 'Darcs' - } - assert_response :success - assert_select 'select[name=?]', 'repository_scm' do - assert_select 'option[value=?][selected=selected]', 'Darcs' - end - end - - def test_browse_root - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - get :show, :params => { - :id => PRJ_ID - } - assert_select 'table.entries tbody' do - assert_select 'tr', 3 - assert_select 'tr.dir td.filename a', :text => 'images' - assert_select 'tr.dir td.filename a', :text => 'sources' - assert_select 'tr.file td.filename a', :text => 'README' - end - end - - def test_browse_directory - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - get :show, :params => { - :id => PRJ_ID, - :path => repository_path_hash(['images'])[:param] - } - assert_response :success - assert_select 'table.entries tbody' do - assert_select 'tr', 2 - assert_select 'tr.file td.filename a', :text => 'delete.png' - assert_select 'tr.file td.filename a', :text => 'edit.png' - end - end - - def test_browse_at_given_revision - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - get :show, :params => { - :id => PRJ_ID, - :path => repository_path_hash(['images'])[:param], - :rev => 1 - } - assert_response :success - assert_select 'table.entries tbody' do - assert_select 'tr', 1 - assert_select 'tr.file td.filename a', :text => 'delete.png' - end - end - - def test_changes - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - get :changes, :params => { - :id => PRJ_ID, - :path => repository_path_hash(['images', 'edit.png'])[:param] - } - assert_response :success - assert_select 'h2', :text => /edit.png/ - end - - def test_diff - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - # Full diff of changeset 5 - ['inline', 'sbs'].each do |dt| - get :diff, :params => { - :id => PRJ_ID, - :rev => 5, - :type => dt - } - assert_response :success - # Line 22 removed - assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/ - end - end - - def test_destroy_valid_repository - @request.session[:user_id] = 1 # admin - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - - assert_difference 'Repository.count', -1 do - delete :destroy, :params => { - :id => @repository.id - } - end - assert_response 302 - @project.reload - assert_nil @project.repository - end - - def test_destroy_invalid_repository - @request.session[:user_id] = 1 # admin - @project.repository.destroy - @repository = Repository::Darcs.create!( - :project => @project, - :url => "/invalid", - :log_encoding => 'UTF-8' - ) - @repository.fetch_changesets - @project.reload - assert_equal 0, @repository.changesets.count - - assert_difference 'Repository.count', -1 do - delete :destroy, :params => { - :id => @repository.id - } - end - assert_response 302 - @project.reload - assert_nil @project.repository - end - else - puts "Darcs test repository NOT FOUND. Skipping functional tests !!!" - def test_fake; assert true end - end -end diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 3bb018be1..9eaca3221 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -606,32 +606,6 @@ RAW end # TODO: Bazaar commit id contains mail address, so it contains '@' and '_'. - def test_redmine_links_darcs_commit - changeset_link = link_to('20080308225258-98289-abcd456efg.gz', - { - :controller => 'repositories', - :action => 'revision', - :id => 'subproject1', - :rev => '123', - }, - :class => 'changeset', :title => 'test commit') - to_test = { - 'commit:20080308225258-98289-abcd456efg.gz' => changeset_link, - } - @project = Project.find(3) - r = Repository::Darcs.create!( - :project => @project, :url => '/tmp/test/darcs', - :log_encoding => 'UTF-8') - assert r - c = Changeset.new(:repository => r, - :committed_on => Time.now, - :revision => '123', - :scmid => '20080308225258-98289-abcd456efg.gz', - :comments => 'test commit') - assert( c.save ) - to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } - end - def test_redmine_links_mercurial_commit changeset_link_rev = link_to('r123', { diff --git a/test/unit/lib/redmine/scm/adapters/darcs_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/darcs_adapter_test.rb deleted file mode 100644 index 949779bf3..000000000 --- a/test/unit/lib/redmine/scm/adapters/darcs_adapter_test.rb +++ /dev/null @@ -1,60 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2017 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -require File.expand_path('../../../../../../test_helper', __FILE__) - -class DarcsAdapterTest < ActiveSupport::TestCase - REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s - - if File.directory?(REPOSITORY_PATH) - def setup - @adapter = Redmine::Scm::Adapters::DarcsAdapter.new(REPOSITORY_PATH) - end - - def test_darcsversion - to_test = { "1.0.9 (release)\n" => [1,0,9] , - "2.2.0 (release)\n" => [2,2,0] } - to_test.each do |s, v| - test_darcsversion_for(s, v) - end - end - - def test_revisions - id1 = '20080308225258-98289-761f654d669045eabee90b91b53a21ce5593cadf.gz' - revs = @adapter.revisions('', nil, nil, {:with_path => true}) - assert_equal 6, revs.size - assert_equal id1, revs[5].scmid - paths = revs[5].paths - assert_equal 5, paths.size - assert_equal 'A', paths[0][:action] - assert_equal '/README', paths[0][:path] - assert_equal 'A', paths[1][:action] - assert_equal '/images', paths[1][:path] - end - - private - - def test_darcsversion_for(darcsversion, version) - @adapter.class.expects(:darcs_binary_version_from_command_line).returns(darcsversion) - assert_equal version, @adapter.class.darcs_binary_version - end - - else - puts "Darcs test repository NOT FOUND. Skipping unit tests !!!" - def test_fake; assert true end - end -end diff --git a/test/unit/repository_darcs_test.rb b/test/unit/repository_darcs_test.rb deleted file mode 100644 index 5cb572503..000000000 --- a/test/unit/repository_darcs_test.rb +++ /dev/null @@ -1,129 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2017 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -require File.expand_path('../../test_helper', __FILE__) - -class RepositoryDarcsTest < ActiveSupport::TestCase - fixtures :projects - - include Redmine::I18n - - REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s - NUM_REV = 6 - - def setup - @project = Project.find(3) - @repository = Repository::Darcs.create( - :project => @project, - :url => REPOSITORY_PATH, - :log_encoding => 'UTF-8' - ) - assert @repository - end - - def test_blank_path_to_repository_error_message - set_language_if_valid 'en' - repo = Repository::Darcs.new( - :project => @project, - :identifier => 'test', - :log_encoding => 'UTF-8' - ) - assert !repo.save - assert_include "Path to repository cannot be blank", - repo.errors.full_messages - end - - def test_blank_path_to_repository_error_message_fr - set_language_if_valid 'fr' - str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') - repo = Repository::Darcs.new( - :project => @project, - :url => "", - :identifier => 'test', - :log_encoding => 'UTF-8' - ) - assert !repo.save - assert_include str, repo.errors.full_messages - end - - if File.directory?(REPOSITORY_PATH) - def test_fetch_changesets_from_scratch - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - - assert_equal NUM_REV, @repository.changesets.count - assert_equal 13, @repository.filechanges.count - assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments - end - - def test_fetch_changesets_incremental - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - - # Remove changesets with revision > 3 - @repository.changesets.each {|c| c.destroy if c.revision.to_i > 3} - @project.reload - @repository.reload - assert_equal 3, @repository.changesets.count - - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - end - - def test_entries - entries = @repository.entries - assert_kind_of Redmine::Scm::Adapters::Entries, entries - end - - def test_entries_invalid_revision - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - assert_nil @repository.entries('', '123') - end - - def test_deleted_files_should_not_be_listed - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - entries = @repository.entries('sources') - assert entries.detect {|e| e.name == 'watchers_controller.rb'} - assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} - end - - def test_cat - if @repository.scm.supports_cat? - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - cat = @repository.cat("sources/welcome_controller.rb", 2) - assert_not_nil cat - assert cat.include?('class WelcomeController < ApplicationController') - end - end - else - puts "Darcs test repository NOT FOUND. Skipping unit tests !!!" - def test_fake; assert true end - end -end diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb index 489a1d69d..59f011f9f 100644 --- a/test/unit/repository_test.rb +++ b/test/unit/repository_test.rb @@ -221,7 +221,7 @@ class RepositoryTest < ActiveSupport::TestCase def test_should_not_create_with_disabled_scm # disable Subversion - with_settings :enabled_scm => ['Darcs', 'Git'] do + with_settings :enabled_scm => ['Mercurial', 'Git'] do repository = Repository::Subversion.new( :project => Project.find(3), :url => "svn://localhost") assert !repository.save |