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