r4662 fails in old Mercurial. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4686 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
35b9972c81
commit
a6f05b5e56
|
@ -154,14 +154,18 @@ module Redmine
|
||||||
def diff(path, identifier_from, identifier_to=nil)
|
def diff(path, identifier_from, identifier_to=nil)
|
||||||
path ||= ''
|
path ||= ''
|
||||||
diff_args = ''
|
diff_args = ''
|
||||||
|
diff = []
|
||||||
if identifier_to
|
if identifier_to
|
||||||
diff_args = "-r #{hgrev(identifier_to)} -r #{hgrev(identifier_from)}"
|
diff_args = "-r #{hgrev(identifier_to)} -r #{hgrev(identifier_from)}"
|
||||||
else
|
else
|
||||||
diff_args = "-c #{hgrev(identifier_from)}"
|
if self.class.client_version_above?([1, 2])
|
||||||
|
diff_args = "-c #{hgrev(identifier_from)}"
|
||||||
|
else
|
||||||
|
return []
|
||||||
|
end
|
||||||
end
|
end
|
||||||
cmd = "#{HG_BIN} -R #{target('')} diff --nodates --git #{diff_args}"
|
cmd = "#{HG_BIN} -R #{target('')} diff --nodates --git #{diff_args}"
|
||||||
cmd << " -I #{target(path)}" unless path.empty?
|
cmd << " -I #{target(path)}" unless path.empty?
|
||||||
diff = []
|
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
diff << line
|
diff << line
|
||||||
|
|
|
@ -32,9 +32,10 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
|
||||||
@request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
@response = ActionController::TestResponse.new
|
@response = ActionController::TestResponse.new
|
||||||
User.current = nil
|
User.current = nil
|
||||||
Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH)
|
@repository = Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH)
|
||||||
|
assert @repository
|
||||||
end
|
end
|
||||||
|
|
||||||
if File.directory?(REPOSITORY_PATH)
|
if File.directory?(REPOSITORY_PATH)
|
||||||
def test_show
|
def test_show
|
||||||
get :show, :id => 3
|
get :show, :id => 3
|
||||||
|
@ -132,12 +133,15 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
|
||||||
get :diff, :id => 3, :rev => 4
|
get :diff, :id => 3, :rev => 4
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'diff'
|
assert_template 'diff'
|
||||||
# Line 22 removed
|
|
||||||
assert_tag :tag => 'th',
|
if @repository.scm.class.client_version_above?([1, 2])
|
||||||
:content => '22',
|
# Line 22 removed
|
||||||
:sibling => { :tag => 'td',
|
assert_tag :tag => 'th',
|
||||||
:attributes => { :class => /diff_out/ },
|
:content => '22',
|
||||||
:content => /def remove/ }
|
:sibling => { :tag => 'td',
|
||||||
|
:attributes => { :class => /diff_out/ },
|
||||||
|
:content => /def remove/ }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,19 @@ begin
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_diff
|
def test_diff
|
||||||
assert_nil @adapter.diff(nil, '100000')
|
if @adapter.class.client_version_above?([1, 2])
|
||||||
|
assert_nil @adapter.diff(nil, '100000')
|
||||||
|
end
|
||||||
assert_nil @adapter.diff(nil, '100000', '200000')
|
assert_nil @adapter.diff(nil, '100000', '200000')
|
||||||
[2, '400bb8672109', '400', 400].each do |r1|
|
[2, '400bb8672109', '400', 400].each do |r1|
|
||||||
diff1 = @adapter.diff(nil, r1)
|
diff1 = @adapter.diff(nil, r1)
|
||||||
assert_equal 28, diff1.size
|
if @adapter.class.client_version_above?([1, 2])
|
||||||
buf = diff1[24].gsub(/\r\n|\r|\n/, "")
|
assert_equal 28, diff1.size
|
||||||
assert_equal "+ return true unless klass.respond_to?('watched_by')", buf
|
buf = diff1[24].gsub(/\r\n|\r|\n/, "")
|
||||||
|
assert_equal "+ return true unless klass.respond_to?('watched_by')", buf
|
||||||
|
else
|
||||||
|
assert_equal 0, diff1.size
|
||||||
|
end
|
||||||
[4, 'def6d2f1254a'].each do |r2|
|
[4, 'def6d2f1254a'].each do |r2|
|
||||||
diff2 = @adapter.diff(nil,r1,r2)
|
diff2 = @adapter.diff(nil,r1,r2)
|
||||||
assert_equal 50, diff2.size
|
assert_equal 50, diff2.size
|
||||||
|
|
Loading…
Reference in New Issue