From 4e688b0e0e603b2aaa2c7880206e5cc1230786d3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 19 Feb 2013 07:32:57 -0800 Subject: [PATCH] Parse property change diffs generated with old SVN (prior to 1.5) Summary: Fixes T2565. SVN from before June 2008 generates different looking property changes. See http://subversion.tigris.org/issues/show_bug.cgi?id=3019 for the change. Test Plan: Added a unit test derived from the report in T2565, made it pass. Reviewers: chad, vrana Reviewed By: chad CC: aran Maniphest Tasks: T2565 Differential Revision: https://secure.phabricator.com/D5009 --- src/parser/ArcanistDiffParser.php | 11 +++++++++-- .../__tests__/ArcanistDiffParserTestCase.php | 18 ++++++++++++++++++ .../diff/svn-property-older-than-1.5.svndiff | 4 ++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/parser/__tests__/diff/svn-property-older-than-1.5.svndiff diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php index 2313cb1c..0ba2b247 100644 --- a/src/parser/ArcanistDiffParser.php +++ b/src/parser/ArcanistDiffParser.php @@ -377,10 +377,17 @@ final class ArcanistDiffParser { break; } + // NOTE: Before 1.5, SVN uses "Name". At 1.5 and later, SVN uses + // "Modified", "Added" and "Deleted". + $matches = null; - $ok = preg_match('/^(Modified|Added|Deleted): (.*)$/', $line, $matches); + $ok = preg_match( + '/^(Name|Modified|Added|Deleted): (.*)$/', + $line, + $matches); if (!$ok) { - $this->didFailParse("Expected 'Added', 'Deleted', or 'Modified'."); + $this->didFailParse( + "Expected 'Name', 'Added', 'Deleted', or 'Modified'."); } $op = $matches[1]; diff --git a/src/parser/__tests__/ArcanistDiffParserTestCase.php b/src/parser/__tests__/ArcanistDiffParserTestCase.php index 49443013..7995536c 100644 --- a/src/parser/__tests__/ArcanistDiffParserTestCase.php +++ b/src/parser/__tests__/ArcanistDiffParserTestCase.php @@ -190,6 +190,24 @@ Merged /tfb/branches/ads-create-v3/www/html/js/help/UIFaq.js:r140558-142418 EOTEXT )); break; + case 'svn-property-older-than-1.5.svndiff': + // In SVN 1.5, the format for property diffs changed to use the words + // "Added", "Deleted" and "Modified" instead of "Name". This is an old + // property change diff which uses "Name". + $this->assertEqual(1, count($changes)); + $change = reset($changes); + + $this->assertEqual(count($change->getHunks()), 0); + $this->assertEqual( + $change->getOldProperties(), + array( + )); + $this->assertEqual( + $change->getNewProperties(), + array( + 'svn:executable' => '*', + )); + break; case 'svn-binary-add.svndiff': $this->assertEqual(1, count($changes)); $change = reset($changes); diff --git a/src/parser/__tests__/diff/svn-property-older-than-1.5.svndiff b/src/parser/__tests__/diff/svn-property-older-than-1.5.svndiff new file mode 100644 index 00000000..72a5ae62 --- /dev/null +++ b/src/parser/__tests__/diff/svn-property-older-than-1.5.svndiff @@ -0,0 +1,4 @@ +Property changes on: ancient/crypt/tomb.COBOL +___________________________________________________________________ +Name: svn:executable + + *