From d17be1d824e5af121b6ca2e4333739f195f014fd Mon Sep 17 00:00:00 2001 From: vrana Date: Fri, 13 Apr 2012 10:51:27 -0700 Subject: [PATCH] Fix SVN commit change parser for files moved from deleted directory Summary: This continues work started at D2215. Files moved from deleted directory were marked as Copied Here instead of Moved Here. Test Plan: Reparsed two commits which was previously wrong, now correct. Reviewers: epriestley Reviewed By: epriestley CC: aran Maniphest Tasks: T1114 Differential Revision: https://secure.phabricator.com/D2229 --- ...rRepositorySvnCommitChangeParserWorker.php | 82 ++++++++++--------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/src/applications/repository/worker/commitchangeparser/svn/PhabricatorRepositorySvnCommitChangeParserWorker.php b/src/applications/repository/worker/commitchangeparser/svn/PhabricatorRepositorySvnCommitChangeParserWorker.php index e06759d717..a1f20f4bfb 100644 --- a/src/applications/repository/worker/commitchangeparser/svn/PhabricatorRepositorySvnCommitChangeParserWorker.php +++ b/src/applications/repository/worker/commitchangeparser/svn/PhabricatorRepositorySvnCommitChangeParserWorker.php @@ -140,9 +140,49 @@ class PhabricatorRepositorySvnCommitChangeParserWorker } } - $path_file_types = $this->lookupPathFileTypes($repository, $lookup); - $effects = array(); + + $path_file_types = $this->lookupPathFileTypes($repository, $lookup); + foreach ($raw_paths as $path => $raw_info) { + if ($raw_info['rawChangeType'] == 'D' && + $path_file_types[$path] == DifferentialChangeType::FILE_DIRECTORY) { + + // Bad. Child paths aren't enumerated in "svn log" so we need + // to go fishing. + $list = $this->lookupRecursiveFileList( + $repository, + $lookup[$path]); + + foreach ($list as $deleted_path => $path_file_type) { + $deleted_path = rtrim($path.'/'.$deleted_path, '/'); + if (!empty($raw_paths[$deleted_path])) { + // We somehow learned about this deletion explicitly? + // TODO: Unclear how this is possible. + continue; + } + $effect_type = DifferentialChangeType::TYPE_DELETE; + $effect_target_path = null; + if (isset($copied_or_moved_map[$deleted_path])) { + $effect_target_path = $path; + if (count($copied_or_moved_map[$deleted_path]) > 1) { + $effect_type = DifferentialChangeType::TYPE_MULTICOPY; + } else { + $effect_type = DifferentialChangeType::TYPE_MOVE_AWAY; + } + } + $effects[$deleted_path] = array( + 'rawPath' => $deleted_path, + 'rawTargetPath' => $effect_target_path, + 'rawTargetCommit' => null, + 'rawDirect' => true, + 'changeType' => $effect_type, + 'fileType' => $path_file_type, + ); + $deleted_paths[$deleted_path] = $effects[$deleted_path]; + } + } + } + $resolved_types = array(); $supplemental = array(); foreach ($raw_paths as $path => $raw_info) { @@ -160,44 +200,6 @@ class PhabricatorRepositorySvnCommitChangeParserWorker } else { $type = DifferentialChangeType::TYPE_DELETE; } - $file_type = $path_file_types[$path]; - - if ($file_type == DifferentialChangeType::FILE_DIRECTORY) { - // Bad. Child paths aren't enumerated in "svn log" so we need - // to go fishing. - - $list = $this->lookupRecursiveFileList( - $repository, - $lookup[$path]); - - foreach ($list as $deleted_path => $path_file_type) { - $deleted_path = rtrim($path.'/'.$deleted_path, '/'); - if (!empty($raw_paths[$deleted_path])) { - // We somehow learned about this deletion explicitly? - // TODO: Unclear how this is possible. - continue; - } - $effect_type = $type; - $effect_target_path = null; - if (isset($copied_or_moved_map[$deleted_path])) { - $effect_target_path = $path; - if (count($copied_or_moved_map[$deleted_path]) > 1) { - $effect_type = DifferentialChangeType::TYPE_MULTICOPY; - } else { - $effect_type = DifferentialChangeType::TYPE_MOVE_AWAY; - } - } - $effects[$deleted_path] = array( - 'rawPath' => $deleted_path, - 'rawTargetPath' => $effect_target_path, - 'rawTargetCommit' => null, - 'rawDirect' => true, - - 'changeType' => $effect_type, - 'fileType' => $path_file_type, - ); - } - } break; case 'A': $copy_from = $raw_info['rawTargetPath'];