]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix exception on diff parse on FreeBSD
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 17 Jan 2014 10:37:55 +0000 (16:37 +0600)
committerepriestley <git@epriestley.com>
Sat, 18 Jan 2014 19:13:28 +0000 (11:13 -0800)
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: <https://github.com/facebook/arcanist/pull/139>

Reviewed by: epriestley

src/parser/ArcanistDiffParser.php
src/parser/__tests__/ArcanistDiffParserTestCase.php
src/parser/__tests__/diff/svn-binary-diff-freebsd.svndiff [new file with mode: 0644]

index 45d2520b3430bc34d070318bfc8e9867348f1090..df548bab665130265a893da97f001f77ab41ff94 100644 (file)
@@ -220,7 +220,7 @@ final class ArcanistDiffParser {
         '(?P<type>rcsdiff -u) (?P<oldnew>.*)',
         // This is a unified diff, probably from "diff -u" or synthetic diffing.
         '(?P<type>---) (?P<old>.+)\s+\d{4}-\d{2}-\d{2}.*',
-        '(?P<binary>Binary) files '.
+        '(?P<binary>Binary files|Files) '.
           '(?P<old>.+)\s+\d{4}-\d{2}-\d{2} and '.
           '(?P<new>.+)\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
index a4becd86fa34d161edb0439de601444fbea1eef1..24b410895f734bf24c2e5d2e97b0249be4694d55 100644 (file)
@@ -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 (file)
index 0000000..6b67e7d
--- /dev/null
@@ -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