[FIX] Subversion can report both R and A for a file -- eliminate the duplicate and...
authorRobin Luckey <robin@Tangier.local>
Wed, 21 Jan 2009 17:57:08 +0000 (09:57 -0800)
committerRobin Luckey <robin@Tangier.local>
Wed, 21 Jan 2009 17:57:08 +0000 (09:57 -0800)
lib/scm/adapters/svn/commits.rb
test/unit/svn_commits_test.rb

index c59a8b892c04672e8b5e61d3bacd4613da958873..25fb183d008ccc4fb85f8128304658152a634aa2 100644 (file)
@@ -86,7 +86,7 @@ module Scm::Adapters
                        # So look for diffs of the form ["M", "path"] which are matched by ["A", "path"] and remove them.
                        if commit.diffs
                                commit.diffs.delete_if do |d|
-                                       d.action == 'M' && commit.diffs.select { |x| x.action == 'A' and x.path == d.path }.any?
+                                       d.action =~ /[MR]/ && commit.diffs.select { |x| x.action == 'A' and x.path == d.path }.any?
                                end
                        end
                        commit
index 5ab3e7331aa3280a65811d5066bed3cc5feb6a27..62e3dd691bf0c6a13e0d1f12a14a653afb635b5d 100644 (file)
@@ -84,7 +84,7 @@ module Scm::Adapters
                        assert_equal '/foo', SvnAdapter.new(:branch_name => '/trunk/hamcrest-c++').strip_path_branch('/trunk/hamcrest-c++/foo')
                end
 
-               def test_remove_dupes
+               def test_remove_dupes_add_modify
                        svn = SvnAdapter.new
                        c = Scm::Commit.new(:diffs => [ Scm::Diff.new(:action => "A", :path => "foo"),
                                                                                                                                                        Scm::Diff.new(:action => "M", :path => "foo") ])
@@ -94,6 +94,16 @@ module Scm::Adapters
                        assert_equal 'A', c.diffs.first.action
                end
 
+               def test_remove_dupes_add_replace
+                       svn = SvnAdapter.new
+                       c = Scm::Commit.new(:diffs => [ Scm::Diff.new(:action => "R", :path => "foo"),
+                                                                                                                                                       Scm::Diff.new(:action => "A", :path => "foo") ])
+
+                       svn.remove_dupes(c)
+                       assert_equal 1, c.diffs.size
+                       assert_equal 'A', c.diffs.first.action
+               end
+
                # Had so many bugs around this case that a test was required
                def test_deepen_commit_with_nil_diffs
                        with_svn_repository('svn') do |svn|