From: epriestley Date: Wed, 18 Jul 2012 13:53:07 +0000 (-0700) Subject: Fix arc handling of "\n" files on Windows in SVN X-Git-Tag: conduit-6~198 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=9997dd7830d9a6ece14db56cbba3443305955c2c;p=arcanist.git 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 --- 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; }