]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix arc handling of "\n" files on Windows in SVN
authorepriestley <git@epriestley.com>
Wed, 18 Jul 2012 13:53:07 +0000 (06:53 -0700)
committerepriestley <git@epriestley.com>
Wed, 18 Jul 2012 13:53:07 +0000 (06:53 -0700)
Summary:
On Windows, a diff may have "\n" newlines (from the file itself) but "\r\n" blocks (from svn).

NOTE: indents are funky since I edited this with Notepad++, I'll fix before landing.

Test Plan: Diffed an edit to a "\n" newline file on Windows in SVN.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran
Differential Revision: https://secure.phabricator.com/D2998

src/parser/ArcanistDiffParser.php

index 441a170b598e979f968e9647b723fccf3b7b0b85..da9623517fe60a95e0498b7472147af8dfbe9b5f 100644 (file)
@@ -991,13 +991,13 @@ final class ArcanistDiffParser {
       $text = preg_replace('/'.$ansi_color_pattern.'/', '', $text);
     }
 
-    // TODO: This is a hack for SVN + Windows.
-    if (strpos($text, "\r\n") !== false) {
-      $this->text = explode("\r\n", $text);
-    } else {
-      $this->text = explode("\n", $text);
-    }
+    // TODO: This is a hack for SVN + Windows. Eventually, we should retain line
+    // endings and preserve them through the patch lifecycle or something along
+    // those lines.
 
+    // NOTE: On Windows, a diff may have \n delimited lines (because the file
+    // uses \n) but \r\n delimited blocks. Split on both.
+    $this->text = preg_split('/\r?\n/', $text);
     $this->line = 0;
   }