annotate .svn/pristine/75/755c17ebd3ddb576c869a4c1a0d3c848e44bf0f3.svn-base @ 1327:287f201c2802 redmine-2.2-integration

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