You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Kobayashi Noritada <no...@dolphin.c.u-tokyo.ac.jp> on 2006/06/12 05:48:18 UTC
[PATCH] Add a new method, Svn::Core::LogChangedPath#copied? for
the SWIG/Ruby bindings.
Hi,
Here is a patch to add a new method, Svn::Core::LogChangedPath#copied?
implemented with Svn::Util.copy?.
Currently in the SWIG/Ruby bindings, although Svn::Core::LogChangedPath has
instance methods 'copyfrom_path' and 'copyfrom_rev' to know which path and
which revision the copy was taken from, it does not seem to have methods
determining whether the path was copied or not.
I know anyone can do determine by using copyfrom_path and copyfrom_rev, but
it is better for API to have a method to do so.
Fortunately, I find Svn::Util.copy? exactly does the determination.
Please review it and its way of naming.
# Which is better, 'copy?' or 'copied?'? ;-)
Thanks,
-nori
[[[
* subversion/bindings/swig/ruby/svn/core.rb
(Svn::Core::LogChangedPath#copied?): A new method for determining whether
the path was copied or not.
]]]
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
Re: [PATCH] Add a new method, Svn::Core::LogChangedPath#copied?
for the SWIG/Ruby bindings.
Posted by Kouhei Sutou <ko...@cozmixng.org>.
Hi,
In <20...@dolphin.c.u-tokyo.ac.jp>
"Re: [PATCH] Add a new method, Svn::Core::LogChangedPath#copied? for the SWIG/Ruby bindings." on Tue, 13 Jun 2006 22:33:05 +0900 (JST),
Kobayashi Noritada <no...@dolphin.c.u-tokyo.ac.jp> wrote:
> > > > > 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.
> > >
> > > Here attached a new patch with a test case.
> >
> > I found some codings I don't like in your test case. What
> > about the following my idea?
>
> Great!!
> Thank you very much for simplifying my code.
> Actually I thought that stuff was ugly and I wanted to do exactly what you've
> done, but I had no idea to do it immediately...
>
> Shall I commit this one with my original patch for
> Svn::Core::LogChangedPath#copied? ?
Yes, please commit.
Thanks,
--
kou
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] Add a new method, Svn::Core::LogChangedPath#copied?
for the SWIG/Ruby bindings.
Posted by Kobayashi Noritada <no...@dolphin.c.u-tokyo.ac.jp>.
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.
> >
> > Here attached a new patch with a test case.
>
> I found some codings I don't like in your test case. What
> about the following my idea?
Great!!
Thank you very much for simplifying my code.
Actually I thought that stuff was ugly and I wanted to do exactly what you've
done, but I had no idea to do it immediately...
Shall I commit this one with my original patch for
Svn::Core::LogChangedPath#copied? ?
-nori
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] Add a new method, Svn::Core::LogChangedPath#copied?
for the SWIG/Ruby bindings.
Posted by Kouhei Sutou <ko...@cozmixng.org>.
Hi,
In <20...@dolphin.c.u-tokyo.ac.jp>
"Re: [PATCH] Add a new method, Svn::Core::LogChangedPath#copied? for the SWIG/Ruby bindings." on Tue, 13 Jun 2006 04:13:06 +0900 (JST),
Kobayashi Noritada <no...@dolphin.c.u-tokyo.ac.jp> wrote:
> > > 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.
I found some codings I don't like in your test case. What
about the following my idea?
Thanks,
--
kou
Re: [PATCH] Add a new method, Svn::Core::LogChangedPath#copied?
for the SWIG/Ruby bindings.
Posted by Kobayashi Noritada <no...@dolphin.c.u-tokyo.ac.jp>.
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
Re: [PATCH] Add a new method, Svn::Core::LogChangedPath#copied?
for the SWIG/Ruby bindings.
Posted by Kouhei Sutou <ko...@cozmixng.org>.
Hi,
In <20...@dolphin.c.u-tokyo.ac.jp>
"[PATCH] Add a new method, Svn::Core::LogChangedPath#copied? for the SWIG/Ruby bindings." on Mon, 12 Jun 2006 14:48:18 +0900 (JST),
Kobayashi Noritada <no...@dolphin.c.u-tokyo.ac.jp> wrote:
> 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.
> Please review it and its way of naming.
> # Which is better, 'copy?' or 'copied?'? ;-)
I prefer 'copied?' to 'copy?'.
Thanks,
--
kou
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org