Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/ruby/test/test_info.rb view on Meta::CPAN
end
def test_changed
dir = "changed_dir"
tmp_dir = "changed_tmp_dir"
dir_path = File.join(@wc_path, dir)
tmp_dir_path = File.join(@wc_path, tmp_dir)
dir_svn_path = dir
tmp_dir_svn_path = tmp_dir
file1 = "changed1.txt"
file2 = "changed2.txt"
file3 = "changed3.txt"
file4 = "changed4.txt"
file5 = "changed5.txt"
file1_path = File.join(@wc_path, file1)
file2_path = File.join(dir_path, file2)
file3_path = File.join(@wc_path, file3)
file4_path = File.join(dir_path, file4)
file5_path = File.join(@wc_path, file5)
file1_svn_path = file1
file2_svn_path = [dir_svn_path, file2].join("/")
file3_svn_path = file3
file4_svn_path = [dir_svn_path, file4].join("/")
file5_svn_path = file5
file6 = "changed6.txt"
file7 = "changed7.txt"
file8 = "changed8.txt"
file9 = "changed9.txt"
file6_path = File.join(dir_path, file6)
file7_path = File.join(@wc_path, file7)
file8_path = File.join(dir_path, file8)
file9_path = File.join(dir_path, file9)
file6_svn_path = [dir_svn_path, file6].join("/")
file7_svn_path = file7
file8_svn_path = [dir_svn_path, file8].join("/")
file9_svn_path = [dir_svn_path, file9].join("/")
first_rev = nil
log = "added 2 dirs\nanded 5 files"
make_context(log) do |ctx|
ctx.mkdir([dir_path, tmp_dir_path])
FileUtils.touch(file1_path)
FileUtils.touch(file2_path)
FileUtils.touch(file3_path)
FileUtils.touch(file4_path)
FileUtils.touch(file5_path)
ctx.add(file1_path)
ctx.add(file2_path)
ctx.add(file3_path)
ctx.add(file4_path)
ctx.add(file5_path)
commit_info = ctx.commit(@wc_path)
first_rev = commit_info.revision
info = make_info(commit_info.revision)
assert_equal([].sort, info.updated_dirs)
assert_equal([].sort, info.deleted_dirs)
assert_equal(["#{dir_svn_path}/", "#{tmp_dir_svn_path}/"].sort,
info.added_dirs)
end
log = "changed 3 files\ndeleted 2 files\nadded 3 files"
make_context(log) do |ctx|
File.open(file1_path, "w") {|f| f.puts "changed"}
File.open(file2_path, "w") {|f| f.puts "changed"}
File.open(file3_path, "w") {|f| f.puts "changed"}
ctx.rm_f([file4_path, file5_path])
FileUtils.touch(file6_path)
FileUtils.touch(file7_path)
FileUtils.touch(file8_path)
ctx.add(file6_path)
ctx.add(file7_path)
ctx.add(file8_path)
ctx.cp(file1_path, file9_path)
ctx.rm(tmp_dir_path)
commit_info = ctx.commit(@wc_path)
second_rev = commit_info.revision
info = make_info(commit_info.revision)
assert_equal([file1_svn_path, file2_svn_path, file3_svn_path].sort,
info.updated_files)
assert_equal([file4_svn_path, file5_svn_path].sort,
info.deleted_files)
assert_equal([file6_svn_path, file7_svn_path, file8_svn_path].sort,
info.added_files)
assert_equal([].sort, info.updated_dirs)
assert_equal([
[file9_svn_path, file1_svn_path, first_rev]
].sort_by{|x| x[0]},
info.copied_files)
assert_equal([], info.copied_dirs)
assert_equal(["#{tmp_dir_svn_path}/"].sort, info.deleted_dirs)
assert_equal([].sort, info.added_dirs)
end
end
def test_diff
log = "diff"
make_context(log) do |ctx|
file1 = "diff1.txt"
file2 = "diff2.txt"
file3 = "diff3.txt"
file1_path = File.join(@wc_path, "diff1.txt")
file2_path = File.join(@wc_path, "diff2.txt")
file3_path = File.join(@wc_path, "diff3.txt")
file1_prop_key = "AAA"
file1_prop_value = "BBB"
FileUtils.touch(file1_path)
File.open(file2_path, "w") {|f| f.puts "changed"}
FileUtils.touch(file3_path)
ctx.add(file1_path)
ctx.add(file2_path)
ctx.add(file3_path)
ctx.propset(file1_prop_key, file1_prop_value, file1_path)
ctx.commit(@wc_path)
file4 = "diff4.txt"
file5 = "diff5.txt"
file4_path = File.join(@wc_path, file4)
file5_path = File.join(@wc_path, file5)
file4_prop_key = "XXX"
file4_prop_value = "YYY"
File.open(file1_path, "w") {|f| f.puts "changed"}
File.open(file2_path, "wb") {|f| f.puts "removed\nadded"}
FileUtils.touch(file4_path)
ctx.add(file4_path)
ctx.propdel(file1_prop_key, file1_path)
ctx.propset(file4_prop_key, file4_prop_value, file4_path)
ctx.cp(file3_path, file5_path)
commit_info = ctx.commit(@wc_path)
info = make_info(commit_info.revision)
keys = info.diffs.keys.sort
file5_key = keys.last
assert_equal(4, info.diffs.size)
assert_equal([file1, file2, file4].sort, keys[0..-2])
assert_match(/\A#{file5}/, file5_key)
assert(info.diffs[file1].has_key?(:modified))
assert(info.diffs[file1].has_key?(:property_changed))
assert(info.diffs[file2].has_key?(:modified))
assert(info.diffs[file4].has_key?(:added))
assert(info.diffs[file4].has_key?(:property_changed))
( run in 0.351 second using v1.01-cache-2.11-cpan-5623c5533a1 )