##// END OF EJS Templates
Replaces find(:first/:all) calls....
Replaces find(:first/:all) calls. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10931 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r9622:7c105ec9e93b
r10704:ea296a109a86
Show More
darcs.rb
114 lines | 3.8 KiB | text/x-ruby | RubyLexer
Toshi MARUYAMA
scm: darcs: code clean up model....
r5635 # Redmine - project management software
Jean-Philippe Lang
Copyright update....
r9453 # Copyright (C) 2006-2012 Jean-Philippe Lang
Jean-Philippe Lang
Added Darcs basic support....
r570 #
# 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.
Toshi MARUYAMA
scm: darcs: code clean up model....
r5635 #
Jean-Philippe Lang
Added Darcs basic support....
r570 # 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.
Toshi MARUYAMA
scm: darcs: code clean up model....
r5635 #
Jean-Philippe Lang
Added Darcs basic support....
r570 # 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
Toshi MARUYAMA
scm: add feature of per project repository log encoding setting (#1735)....
r4862 validates_presence_of :url, :log_encoding
Jean-Philippe Lang
Added Darcs basic support....
r570
Jean-Philippe Lang
human_attribute_name accepts optional argument....
r8166 def self.human_attribute_name(attribute_key_name, *args)
Toshi MARUYAMA
Rails3: scm: darcs: use .to_s for overriding human_attribute_name parameter...
r8853 attr_name = attribute_key_name.to_s
Toshi MARUYAMA
scm: use i18n string at 'Path to repository' setting in Mercurial, Git, Bazaar and Darcs....
r5409 if attr_name == "url"
attr_name = "path_to_repository"
end
Jean-Philippe Lang
human_attribute_name accepts optional argument....
r8166 super(attr_name, *args)
Toshi MARUYAMA
scm: add scm specific human_attribute_name for input validation....
r4855 end
Toshi MARUYAMA
scm: add scm command and version methods at repository models (#4273)....
r4702 def self.scm_adapter_class
Jean-Philippe Lang
Added Darcs basic support....
r570 Redmine::Scm::Adapters::DarcsAdapter
end
Toshi MARUYAMA
scm: add scm command and version methods at repository models (#4273)....
r4702
Jean-Philippe Lang
Added Darcs basic support....
r570 def self.scm_name
'Darcs'
end
Toshi MARUYAMA
scm: add scm command and version methods at repository models (#4273)....
r4702
Toshi MARUYAMA
scm: darcs: set supports_directory_revisions true at model (#7984)....
r5358 def supports_directory_revisions?
true
end
Jean-Philippe Lang
Adds support for file viewing with Darcs 2.0+ (patch #1799 by Ralph Lange slightly edited)....
r1758 def entry(path=nil, identifier=nil)
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
scm.entry(path, patch.nil? ? nil : patch.scmid)
end
Toshi MARUYAMA
scm: darcs: code clean up model....
r5312
Jean-Philippe Lang
Added Darcs basic support....
r570 def entries(path=nil, identifier=nil)
Toshi MARUYAMA
scm: darcs: model entries returns nil if revision is not stored in database....
r5313 patch = nil
if ! identifier.nil?
patch = changesets.find_by_revision(identifier)
return nil if patch.nil?
end
Jean-Philippe Lang
Fix repository browsing at given revision for various scm and add tests for this....
r1314 entries = scm.entries(path, patch.nil? ? nil : patch.scmid)
Jean-Philippe Lang
Added Darcs basic support....
r570 if entries
entries.each do |entry|
# Search the DB for the entry's last change
Toshi MARUYAMA
scm: darcs: code clean up model....
r5312 if entry.lastrev && !entry.lastrev.scmid.blank?
changeset = changesets.find_by_scmid(entry.lastrev.scmid)
end
Jean-Philippe Lang
Added Darcs basic support....
r570 if changeset
entry.lastrev.identifier = changeset.revision
Toshi MARUYAMA
scm: darcs: code clean up model....
r5312 entry.lastrev.name = changeset.revision
entry.lastrev.time = changeset.committed_on
entry.lastrev.author = changeset.committer
Jean-Philippe Lang
Added Darcs basic support....
r570 end
end
end
Jean-Philippe Lang
Adds a method to load changesets for repository entries....
r9622 load_entries_changesets(entries)
Jean-Philippe Lang
Added Darcs basic support....
r570 entries
end
Toshi MARUYAMA
scm: darcs: code clean up model....
r5312
Jean-Philippe Lang
Adds support for file viewing with Darcs 2.0+ (patch #1799 by Ralph Lange slightly edited)....
r1758 def cat(path, identifier=nil)
Jean-Philippe Lang
Fixes Darcs#cat with Postgresql....
r2093 patch = identifier.nil? ? nil : changesets.find_by_revision(identifier.to_s)
Jean-Philippe Lang
Adds support for file viewing with Darcs 2.0+ (patch #1799 by Ralph Lange slightly edited)....
r1758 scm.cat(path, patch.nil? ? nil : patch.scmid)
end
Toshi MARUYAMA
scm: darcs: code clean up model....
r5312
Jean-Philippe Lang
Move unified diff parser out of the scm abstract adapter so it can be reused for viewing attached diffs (#1403)....
r1499 def diff(path, rev, rev_to)
Jean-Philippe Lang
Added Darcs basic support....
r570 patch_from = changesets.find_by_revision(rev)
Jean-Philippe Lang
Merged Git support branch (r1200 to r1226)....
r1222 return nil if patch_from.nil?
Jean-Philippe Lang
Added Darcs basic support....
r570 patch_to = changesets.find_by_revision(rev_to) if rev_to
if path.blank?
Jean-Philippe Lang
Renamed #changes association to #filechanges (clash with AR::Base.changes that triggers errors with Rails 3.2.5)....
r9576 path = patch_from.filechanges.collect{|change| change.path}.join(' ')
Jean-Philippe Lang
Added Darcs basic support....
r570 end
Jean-Philippe Lang
Move unified diff parser out of the scm abstract adapter so it can be reused for viewing attached diffs (#1403)....
r1499 patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil
Jean-Philippe Lang
Added Darcs basic support....
r570 end
Toshi MARUYAMA
scm: darcs: code clean up model....
r5312
Jean-Philippe Lang
Added Darcs basic support....
r570 def fetch_changesets
scm_info = scm.info
if scm_info
db_last_id = latest_changeset ? latest_changeset.scmid : nil
Toshi MARUYAMA
scm: darcs: code clean up model....
r5635 next_rev = latest_changeset ? latest_changeset.revision.to_i + 1 : 1
Jean-Philippe Lang
Added Darcs basic support....
r570 # latest revision in the repository
Toshi MARUYAMA
scm: darcs: code clean up model....
r5635 scm_revision = scm_info.lastrev.scmid
Jean-Philippe Lang
Added Darcs basic support....
r570 unless changesets.find_by_scmid(scm_revision)
revisions = scm.revisions('', db_last_id, nil, :with_path => true)
transaction do
revisions.reverse_each do |revision|
Toshi MARUYAMA
scm: darcs: code clean up model....
r5328 changeset = Changeset.create(:repository => self,
:revision => next_rev,
:scmid => revision.scmid,
Toshi MARUYAMA
scm: darcs: code clean up model....
r5635 :committer => revision.author,
Jean-Philippe Lang
Added Darcs basic support....
r570 :committed_on => revision.time,
Toshi MARUYAMA
scm: darcs: code clean up model....
r5328 :comments => revision.message)
Jean-Philippe Lang
Added Darcs basic support....
r570 revision.paths.each do |change|
Eric Davis
Refactor: Extract method to create a Change from a Changeset....
r3246 changeset.create_change(change)
Jean-Philippe Lang
Added Darcs basic support....
r570 end
next_rev += 1
end if revisions
end
end
end
end
end