From 9997dd7830d9a6ece14db56cbba3443305955c2c Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 18 Jul 2012 06:53:07 -0700 Subject: [PATCH] Fix arc handling of "\n" files on Windows in SVN 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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php index 441a170b..da962351 100644 --- a/src/parser/ArcanistDiffParser.php +++ b/src/parser/ArcanistDiffParser.php @@ -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; } -- 2.43.0