Revision 1759
Added by Jean-Philippe Lang almost 17 years ago
trunk/app/models/repository/darcs.rb | ||
---|---|---|
28 | 28 |
'Darcs' |
29 | 29 |
end |
30 | 30 |
|
31 |
def entry(path=nil, identifier=nil) |
|
32 |
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier) |
|
33 |
scm.entry(path, patch.nil? ? nil : patch.scmid) |
|
34 |
end |
|
35 |
|
|
31 | 36 |
def entries(path=nil, identifier=nil) |
32 | 37 |
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier) |
33 | 38 |
entries = scm.entries(path, patch.nil? ? nil : patch.scmid) |
... | ... | |
46 | 51 |
entries |
47 | 52 |
end |
48 | 53 |
|
54 |
def cat(path, identifier=nil) |
|
55 |
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier) |
|
56 |
scm.cat(path, patch.nil? ? nil : patch.scmid) |
|
57 |
end |
|
58 |
|
|
49 | 59 |
def diff(path, rev, rev_to) |
50 | 60 |
patch_from = changesets.find_by_revision(rev) |
51 | 61 |
return nil if patch_from.nil? |
trunk/doc/RUNNING_TESTS | ||
---|---|---|
24 | 24 |
--- |
25 | 25 |
gunzip < test/fixtures/repositories/git_repository.tar.gz | tar -xv -C tmp/test |
26 | 26 |
|
27 |
Darcs |
|
28 |
----- |
|
27 |
Darcs (2.0+ required)
|
|
28 |
---------------------
|
|
29 | 29 |
gunzip < test/fixtures/repositories/darcs_repository.tar.gz | tar -xv -C tmp/test |
30 | 30 |
|
31 | 31 |
FileSystem |
trunk/lib/redmine/scm/adapters/darcs_adapter.rb | ||
---|---|---|
25 | 25 |
# Darcs executable name |
26 | 26 |
DARCS_BIN = "darcs" |
27 | 27 |
|
28 |
class << self |
|
29 |
def client_version |
|
30 |
@@client_version ||= (darcs_binary_version || []) |
|
31 |
end |
|
32 |
|
|
33 |
def darcs_binary_version |
|
34 |
cmd = "#{DARCS_BIN} --version" |
|
35 |
version = nil |
|
36 |
shellout(cmd) do |io| |
|
37 |
# Read darcs version in first returned line |
|
38 |
if m = io.gets.match(%r{((\d+\.)+\d+)}) |
|
39 |
version = m[0].scan(%r{\d+}).collect(&:to_i) |
|
40 |
end |
|
41 |
end |
|
42 |
return nil if $? && $?.exitstatus != 0 |
|
43 |
version |
|
44 |
end |
|
45 |
end |
|
46 |
|
|
28 | 47 |
def initialize(url, root_url=nil, login=nil, password=nil) |
29 | 48 |
@url = url |
30 | 49 |
@root_url = url |
31 | 50 |
end |
32 | 51 |
|
33 | 52 |
def supports_cat? |
34 |
false |
|
53 |
# cat supported in darcs 2.0.0 and higher |
|
54 |
self.class.client_version_above?([2, 0, 0]) |
|
35 | 55 |
end |
36 |
|
|
37 |
# Get info about the svn repository
|
|
56 |
|
|
57 |
# Get info about the darcs repository
|
|
38 | 58 |
def info |
39 | 59 |
rev = revisions(nil,nil,nil,{:limit => 1}) |
40 | 60 |
rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil |
... | ... | |
114 | 134 |
diff |
115 | 135 |
end |
116 | 136 |
|
137 |
def cat(path, identifier=nil) |
|
138 |
cmd = "#{DARCS_BIN} show content --repodir #{@url}" |
|
139 |
cmd << " --match \"hash #{identifier}\"" if identifier |
|
140 |
cmd << " #{shell_quote path}" |
|
141 |
cat = nil |
|
142 |
shellout(cmd) do |io| |
|
143 |
io.binmode |
|
144 |
cat = io.read |
|
145 |
end |
|
146 |
return nil if $? && $?.exitstatus != 0 |
|
147 |
cat |
|
148 |
end |
|
149 |
|
|
117 | 150 |
private |
118 | 151 |
|
119 | 152 |
def entry_from_xml(element, path_prefix) |
trunk/test/unit/repository_darcs_test.rb | ||
---|---|---|
48 | 48 |
@repository.fetch_changesets |
49 | 49 |
assert_equal 6, @repository.changesets.count |
50 | 50 |
end |
51 |
|
|
52 |
def test_cat |
|
53 |
@repository.fetch_changesets |
|
54 |
cat = @repository.cat("sources/welcome_controller.rb", 2) |
|
55 |
assert_not_nil cat |
|
56 |
assert cat.include?('class WelcomeController < ApplicationController') |
|
57 |
end |
|
51 | 58 |
else |
52 | 59 |
puts "Darcs test repository NOT FOUND. Skipping unit tests !!!" |
53 | 60 |
def test_fake; assert true end |
Also available in: Unified diff
Adds support for file viewing with Darcs 2.0+ (patch #1799 by Ralph Lange slightly edited).