Hi,
> > Here is a patch to add a new method, Svn::Core::LogChangedPath#copied?
> > implemented with Svn::Util.copy?.
>
> +1
> I'm very happy if you add a test case for your patch.
> Anyway, please commit, nori.
Thank you for reviewing my patch.
I've written a test case.
Here attached a new patch with a test case.
Thanks,
-nori
[[[
Improve usability for Svn::Core::LogChangedPath in the SWIG/Ruby bindings
by adding a method. Also, add a missing test case for the class.
* subversion/bindings/swig/ruby/svn/core.rb
(Svn::Core::LogChangedPath#copied?): A new method for determining whether
the path was copied or not.
* subversion/bindings/swig/ruby/test/test_client.rb
(SvnClientTest#test_log_message): Rename from SvnClientTest#test_log
since it tests Svn::Client::Context#log_message.
(SvnClientTest#test_log): A new test case for Svn::Client::Context#log
and Svn::Core::LogChangedPath.
]]]
Index: subversion/bindings/swig/ruby/test/test_client.rb
===================================================================
--- subversion/bindings/swig/ruby/test/test_client.rb (revision 20043)
+++ subversion/bindings/swig/ruby/test/test_client.rb (working copy)
@@ -558,6 +558,69 @@
end
def test_log
+ log1 = "sample log1"
+ log2 = "sample log2"
+ log3 = "sample log3"
+ src1 = "source1\n"
+ src2 = "source2\n"
+ src3 = "source3\n"
+ file1 = "sample1.txt"
+ file2 = "sample2.txt"
+ file3 = "sample3.txt"
+ path1 = File.join(@wc_path, file1)
+ path2 = File.join(@wc_path, file2)
+ path3 = File.join(@wc_path, file3)
+ abs_path1 = File.join('', file1)
+ abs_path2 = File.join('', file2)
+ abs_path3 = File.join('', file3)
+
+ ctx = make_context(log1)
+ File.open(path1, "w") {|f| f.print(src1)}
+ ctx.add(path1)
+ rev1 = ctx.ci(@wc_path).revision
+
+ ctx = make_context(log2)
+ ctx.cp(path1, path2)
+ rev2 = ctx.ci(@wc_path).revision
+
+ ctx = make_context(log3)
+ ctx.cp(path1, path3)
+ File.open(path1, "w") {|f| f.print(src2)}
+ File.open(path3, "w") {|f| f.print(src3)}
+ rev3 = ctx.ci(@wc_path).revision
+
+ logs = {}
+ keys = [@wc_path, path1, path2, path3]
+ keys.each do |key|
+ logs[key] = []
+ ctx.log(key, 1, "HEAD", 0, true, nil) \
+ do |changed_paths, rev, author, date, message|
+ logs[key] << [changed_paths, rev, author, date, message]
+ end
+ end
+ changed_paths_list = logs[@wc_path].collect {|arr| arr[0] }
+
+ assert_equal([rev1, rev2, rev3], logs[@wc_path].collect {|arr| arr[1] })
+ assert_equal([rev1, rev3], logs[path1].collect {|arr| arr[1] })
+ assert_equal([rev1, rev2], logs[path2].collect {|arr| arr[1] })
+ assert_equal([rev1, rev3], logs[path3].collect {|arr| arr[1] })
+ assert_equal([log1, log2, log3], logs[@wc_path].collect {|arr| arr[4] })
+ assert_equal([[abs_path1], [abs_path2], [abs_path1, abs_path3]] \
+ .collect {|paths| paths.sort },
+ changed_paths_list.collect {|changed_paths|
+ changed_paths.keys.sort
+ })
+ assert_equal('A', changed_paths_list[0][abs_path1].action)
+ assert_equal(false, changed_paths_list[0][abs_path1].copied?)
+ assert_equal('A', changed_paths_list[1][abs_path2].action)
+ assert_equal(true, changed_paths_list[1][abs_path2].copied?)
+ assert_equal(abs_path1, changed_paths_list[1][abs_path2].copyfrom_path)
+ assert_equal(rev1, changed_paths_list[1][abs_path2].copyfrom_rev)
+ assert_equal('M', changed_paths_list[2][abs_path1].action)
+ assert_equal('A', changed_paths_list[2][abs_path3].action)
+ end
+
+ def test_log_message
log = "sample log"
file = "hello.txt"
path = File.join(@wc_path, file)
Index: subversion/bindings/swig/ruby/svn/core.rb
===================================================================
--- subversion/bindings/swig/ruby/svn/core.rb (revision 20043)
+++ subversion/bindings/swig/ruby/svn/core.rb (working copy)
@@ -456,5 +456,11 @@
__date && Time.from_svn_format(__date)
end
end
+
+ class LogChangedPath
+ def copied?
+ Util.copy?(copyfrom_path, copyfrom_rev)
+ end
+ end
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jun 12 21:13:44 2006