Project

General

Profile

Patch #1799 ยป redmine-fix1794-allow-darcs-cat-r1747.patch

Fix #1794 agaings r1747: Allow file browsing with darcs repos - Ralph Lange, 2008-08-18 17:24

View differences:

lib/redmine/scm/adapters/darcs_adapter.rb (working copy)
# Darcs executable name
DARCS_BIN = "darcs"
class << self
def client_version
@@client_version ||= (darcs_binary_version || [])
end
def darcs_binary_version
cmd = "#{DARCS_BIN} --version"
version = nil
shellout(cmd) do |io|
# Read darcs version in first returned line
if m = io.gets.match(%r{((\d+\.)+\d+)})
version = m[0].scan(%r{\d+}).collect(&:to_i)
end
end
return nil if $? && $?.exitstatus != 0
version
end
end
def initialize(url, root_url=nil, login=nil, password=nil)
@url = url
@root_url = url
end
def supports_cat?
false
end
# Get info about the svn repository
# Get info about the darcs repository
def info
rev = revisions(nil,nil,nil,{:limit => 1})
rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil
......
diff
end
def cat(path, identifier=nil)
# cat supported in darcs 2.0.0 and higher
return nil unless self.class.client_version_above?([2, 0, 0])
cmd = "#{DARCS_BIN} show content --repodir #{@url}"
cmd << " --match \"hash #{identifier}\"" if identifier
cmd << " #{path}"
cat = nil
shellout(cmd) do |io|
io.binmode
cat = io.read
end
return nil if $? && $?.exitstatus != 0
cat
end
private
def entry_from_xml(element, path_prefix)
app/models/repository/darcs.rb (working copy)
'Darcs'
end
def entry(path=nil, identifier=nil)
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
scm.entry(path, patch.nil? ? nil : patch.scmid)
end
def entries(path=nil, identifier=nil)
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
entries = scm.entries(path, patch.nil? ? nil : patch.scmid)
......
entries
end
def cat(path, identifier=nil)
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
scm.cat(path, patch.nil? ? nil : patch.scmid)
end
def diff(path, rev, rev_to)
patch_from = changesets.find_by_revision(rev)
return nil if patch_from.nil?
    (1-1/1)