annotate .svn/pristine/c8/c8c8b891b8b1a98cd7dec3eea46d3351c5d63dc0.svn-base @ 1494:e248c7af89ec redmine-2.4

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