annotate .svn/pristine/88/880e4f9fa0e67cb00d3c13f438c6ea56d517bb78.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents dffacf8a6908
children
rev   line source
Chris@1517 1 # Redmine - project management software
Chris@1517 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1517 3 #
Chris@1517 4 # This program is free software; you can redistribute it and/or
Chris@1517 5 # modify it under the terms of the GNU General Public License
Chris@1517 6 # as published by the Free Software Foundation; either version 2
Chris@1517 7 # of the License, or (at your option) any later version.
Chris@1517 8 #
Chris@1517 9 # This program is distributed in the hope that it will be useful,
Chris@1517 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1517 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1517 12 # GNU General Public License for more details.
Chris@1517 13 #
Chris@1517 14 # You should have received a copy of the GNU General Public License
Chris@1517 15 # along with this program; if not, write to the Free Software
Chris@1517 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1517 17
Chris@1517 18 require 'redmine/scm/adapters/darcs_adapter'
Chris@1517 19
Chris@1517 20 class Repository::Darcs < Repository
Chris@1517 21 validates_presence_of :url, :log_encoding
Chris@1517 22
Chris@1517 23 def self.human_attribute_name(attribute_key_name, *args)
Chris@1517 24 attr_name = attribute_key_name.to_s
Chris@1517 25 if attr_name == "url"
Chris@1517 26 attr_name = "path_to_repository"
Chris@1517 27 end
Chris@1517 28 super(attr_name, *args)
Chris@1517 29 end
Chris@1517 30
Chris@1517 31 def self.scm_adapter_class
Chris@1517 32 Redmine::Scm::Adapters::DarcsAdapter
Chris@1517 33 end
Chris@1517 34
Chris@1517 35 def self.scm_name
Chris@1517 36 'Darcs'
Chris@1517 37 end
Chris@1517 38
Chris@1517 39 def supports_directory_revisions?
Chris@1517 40 true
Chris@1517 41 end
Chris@1517 42
Chris@1517 43 def entry(path=nil, identifier=nil)
Chris@1517 44 patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
Chris@1517 45 scm.entry(path, patch.nil? ? nil : patch.scmid)
Chris@1517 46 end
Chris@1517 47
Chris@1517 48 def scm_entries(path=nil, identifier=nil)
Chris@1517 49 patch = nil
Chris@1517 50 if ! identifier.nil?
Chris@1517 51 patch = changesets.find_by_revision(identifier)
Chris@1517 52 return nil if patch.nil?
Chris@1517 53 end
Chris@1517 54 entries = scm.entries(path, patch.nil? ? nil : patch.scmid)
Chris@1517 55 if entries
Chris@1517 56 entries.each do |entry|
Chris@1517 57 # Search the DB for the entry's last change
Chris@1517 58 if entry.lastrev && !entry.lastrev.scmid.blank?
Chris@1517 59 changeset = changesets.find_by_scmid(entry.lastrev.scmid)
Chris@1517 60 end
Chris@1517 61 if changeset
Chris@1517 62 entry.lastrev.identifier = changeset.revision
Chris@1517 63 entry.lastrev.name = changeset.revision
Chris@1517 64 entry.lastrev.time = changeset.committed_on
Chris@1517 65 entry.lastrev.author = changeset.committer
Chris@1517 66 end
Chris@1517 67 end
Chris@1517 68 end
Chris@1517 69 entries
Chris@1517 70 end
Chris@1517 71 protected :scm_entries
Chris@1517 72
Chris@1517 73 def cat(path, identifier=nil)
Chris@1517 74 patch = identifier.nil? ? nil : changesets.find_by_revision(identifier.to_s)
Chris@1517 75 scm.cat(path, patch.nil? ? nil : patch.scmid)
Chris@1517 76 end
Chris@1517 77
Chris@1517 78 def diff(path, rev, rev_to)
Chris@1517 79 patch_from = changesets.find_by_revision(rev)
Chris@1517 80 return nil if patch_from.nil?
Chris@1517 81 patch_to = changesets.find_by_revision(rev_to) if rev_to
Chris@1517 82 if path.blank?
Chris@1517 83 path = patch_from.filechanges.collect{|change| change.path}.join(' ')
Chris@1517 84 end
Chris@1517 85 patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil
Chris@1517 86 end
Chris@1517 87
Chris@1517 88 def fetch_changesets
Chris@1517 89 scm_info = scm.info
Chris@1517 90 if scm_info
Chris@1517 91 db_last_id = latest_changeset ? latest_changeset.scmid : nil
Chris@1517 92 next_rev = latest_changeset ? latest_changeset.revision.to_i + 1 : 1
Chris@1517 93 # latest revision in the repository
Chris@1517 94 scm_revision = scm_info.lastrev.scmid
Chris@1517 95 unless changesets.find_by_scmid(scm_revision)
Chris@1517 96 revisions = scm.revisions('', db_last_id, nil, :with_path => true)
Chris@1517 97 transaction do
Chris@1517 98 revisions.reverse_each do |revision|
Chris@1517 99 changeset = Changeset.create(:repository => self,
Chris@1517 100 :revision => next_rev,
Chris@1517 101 :scmid => revision.scmid,
Chris@1517 102 :committer => revision.author,
Chris@1517 103 :committed_on => revision.time,
Chris@1517 104 :comments => revision.message)
Chris@1517 105 revision.paths.each do |change|
Chris@1517 106 changeset.create_change(change)
Chris@1517 107 end
Chris@1517 108 next_rev += 1
Chris@1517 109 end if revisions
Chris@1517 110 end
Chris@1517 111 end
Chris@1517 112 end
Chris@1517 113 end
Chris@1517 114 end