d40ab0b092fe17b7ae9585df42ade996b0706534

Author: Robin Luckey

Date: 2009-05-20 18:40:14 -0700

[FIX] Svn: Fix a complicated directory renaming case: If a directory is renamed, and then the branch we are tracking is created within that directory *during the same commit*, then the parser would mistakenly think that the branch had been moved.

diff --git a/lib/scm/adapters/svn_chain/chain.rb b/lib/scm/adapters/svn_chain/chain.rb index e7b9d63..d066203 100644 --- a/lib/scm/adapters/svn_chain/chain.rb +++ b/lib/scm/adapters/svn_chain/chain.rb @@ -39,6 +39,19 @@ module Scm::Adapters # Therefore, we must sort diffs by descending filename length, so # that we choose the longest match. c.diffs.sort { |a,b| b.path.length <=> a.path.length }.each do |d| + + # If this diff actually creates this branch, then a parent is impossible. + # Stop looking for parents. + # + # This check exists because of the following complicated commit: + # http://dendro.cornell.edu/svn/corina/branches/databasing/src/edu/cornell/dendro@813 + # It's long to explain, but basically a directory is renamed and + # then our branch is created within it, all in a single commit. + # Without this check, our code mistakenly thinks there is a parent. + if diff_creates_branch(d) + return nil + end + if (b = parent_branch_name(d)) parent = SvnChainAdapter.new( :url => File.join(root, b), :branch_name => b, @@ -46,6 +59,7 @@ module Scm::Adapters :final_token => d.from_revision).normalize break end + end end parent @@ -76,5 +90,11 @@ module Scm::Adapters d.from_path + branch_name[d.path.size..-1] end end + + # True if the passed diff represents the initial creation of the + # branch -- not a move or copy from somewhere else. + def diff_creates_branch(d) + d.action == 'A' && branch_name[0, d.path.size] == d.path && !d.from_path + end end end