From 2c2c5663cbaffaf790ed6b86327547d995f2fa9c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 17 Jan 2014 16:37:55 +0600 Subject: [PATCH] Fix exception on diff parse on FreeBSD FreeBSD 9.2 comes with diff tool version 2.8.7 which behaves a bit different from how it is expected to. Namely for diff between two binary files it says: Files A and B are differ This was leading to an exception when browsing revisions with changes in binary files. Tweaked parse patterns in order to fix this issue. Now both older and newer diff tools are supported. See: Reviewed by: epriestley --- src/parser/ArcanistDiffParser.php | 4 ++-- src/parser/__tests__/ArcanistDiffParserTestCase.php | 1 + src/parser/__tests__/diff/svn-binary-diff-freebsd.svndiff | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 src/parser/__tests__/diff/svn-binary-diff-freebsd.svndiff diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php index 45d2520b..df548bab 100644 --- a/src/parser/ArcanistDiffParser.php +++ b/src/parser/ArcanistDiffParser.php @@ -220,7 +220,7 @@ final class ArcanistDiffParser { '(?Prcsdiff -u) (?P.*)', // This is a unified diff, probably from "diff -u" or synthetic diffing. '(?P---) (?P.+)\s+\d{4}-\d{2}-\d{2}.*', - '(?PBinary) files '. + '(?PBinary files|Files) '. '(?P.+)\s+\d{4}-\d{2}-\d{2} and '. '(?P.+)\s+\d{4}-\d{2}-\d{2} differ.*', // This is a normal Mercurial text change, probably from "hg diff". It @@ -705,7 +705,7 @@ final class ArcanistDiffParser { // We can get this in git, or in SVN when a file exists in the repository // WITHOUT a binary mime-type and is changed and given a binary mime-type. $is_binary_diff = preg_match( - '/^Binary files .* and .* differ$/', + '/^(Binary files|Files) .* and .* differ$/', rtrim($line)); if ($is_binary_diff) { $this->nextNonemptyLine(); // Binary files x and y differ diff --git a/src/parser/__tests__/ArcanistDiffParserTestCase.php b/src/parser/__tests__/ArcanistDiffParserTestCase.php index a4becd86..24b41089 100644 --- a/src/parser/__tests__/ArcanistDiffParserTestCase.php +++ b/src/parser/__tests__/ArcanistDiffParserTestCase.php @@ -217,6 +217,7 @@ EOTEXT $change->getNewProperties()); break; case 'svn-binary-diff.svndiff': + case 'svn-binary-diff-freebsd.svndiff': $this->assertEqual(1, count($changes)); $change = reset($changes); $this->assertEqual( diff --git a/src/parser/__tests__/diff/svn-binary-diff-freebsd.svndiff b/src/parser/__tests__/diff/svn-binary-diff-freebsd.svndiff new file mode 100644 index 00000000..6b67e7d1 --- /dev/null +++ b/src/parser/__tests__/diff/svn-binary-diff-freebsd.svndiff @@ -0,0 +1,3 @@ +Index: html/images/sprite/autogen/8f2jjp.png +=================================================================== +Files trunk/lib/tests/tracking/synthetic-point-motion.blend 9999-99-99 and trunk/lib/tests/tracking/synthetic-point-motion.blend 9999-99-99 differ