1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-29 10:12:41 +01:00

Fix some regexp issues for parsing SVN diffs with \r\n newlines

Summary: We need to tweak a few patterns to accommodate the possibility that lines end in "\r\n".

Test Plan: Added failing unit test and made it pass.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, mbishopim3

Maniphest Tasks: T1944

Differential Revision: https://secure.phabricator.com/D3772
This commit is contained in:
epriestley 2012-10-22 11:15:36 -07:00
parent 6114d7cf9c
commit 10653d7ff3
3 changed files with 23 additions and 7 deletions

View file

@ -649,7 +649,7 @@ final class ArcanistDiffParser {
$line = $this->getLine(); $line = $this->getLine();
if ($is_svn) { if ($is_svn) {
$ok = preg_match('/^=+$/', $line); $ok = preg_match('/^=+\s*$/', $line);
if (!$ok) { if (!$ok) {
$this->didFailParse("Expected '=======================' divider line."); $this->didFailParse("Expected '=======================' divider line.");
} else { } else {
@ -684,8 +684,8 @@ final class ArcanistDiffParser {
} }
$is_binary_add = preg_match( $is_binary_add = preg_match(
'/^Cannot display: file marked as a binary type.$/', '/^Cannot display: file marked as a binary type\.$/',
$line); rtrim($line));
if ($is_binary_add) { if ($is_binary_add) {
$this->nextLine(); // Cannot display: file marked as a binary type. $this->nextLine(); // Cannot display: file marked as a binary type.
$this->nextNonemptyLine(); // svn:mime-type = application/octet-stream $this->nextNonemptyLine(); // svn:mime-type = application/octet-stream
@ -697,7 +697,7 @@ final class ArcanistDiffParser {
// WITHOUT a binary mime-type and is changed and given a binary mime-type. // WITHOUT a binary mime-type and is changed and given a binary mime-type.
$is_binary_diff = preg_match( $is_binary_diff = preg_match(
'/^Binary files .* and .* differ$/', '/^Binary files .* and .* differ$/',
$line); rtrim($line));
if ($is_binary_diff) { if ($is_binary_diff) {
$this->nextNonemptyLine(); // Binary files x and y differ $this->nextNonemptyLine(); // Binary files x and y differ
$this->markBinary($change); $this->markBinary($change);
@ -710,7 +710,7 @@ final class ArcanistDiffParser {
// can not apply these patches.) // can not apply these patches.)
$is_hg_binary_delete = preg_match( $is_hg_binary_delete = preg_match(
'/^Binary file .* has changed$/', '/^Binary file .* has changed$/',
$line); rtrim($line));
if ($is_hg_binary_delete) { if ($is_hg_binary_delete) {
$this->nextNonemptyLine(); $this->nextNonemptyLine();
$this->markBinary($change); $this->markBinary($change);
@ -723,7 +723,7 @@ final class ArcanistDiffParser {
// patch. // patch.
$is_git_binary_patch = preg_match( $is_git_binary_patch = preg_match(
'/^GIT binary patch$/', '/^GIT binary patch$/',
$line); rtrim($line));
if ($is_git_binary_patch) { if ($is_git_binary_patch) {
$this->nextLine(); $this->nextLine();
$this->parseGitBinaryPatch(); $this->parseGitBinaryPatch();
@ -739,7 +739,7 @@ final class ArcanistDiffParser {
if ($is_git) { if ($is_git) {
// "git diff -b" ignores whitespace, but has an empty hunk target // "git diff -b" ignores whitespace, but has an empty hunk target
if (preg_match('@^diff --git a/.*$@', $line)) { if (preg_match('@^diff --git .*$@', $line)) {
$this->nextLine(); $this->nextLine();
return null; return null;
} }

View file

@ -549,6 +549,9 @@ EOTEXT
'dst/file', 'dst/file',
$change->getCurrentPath()); $change->getCurrentPath());
break; break;
case 'more-newlines.svndiff':
$this->assertEqual(1, count($changes));
break;
default: default:
throw new Exception("No test block for diff file {$diff_file}."); throw new Exception("No test block for diff file {$diff_file}.");
break; break;

View file

@ -0,0 +1,13 @@
Index: Database/tables/dbo.Account.sql
===================================================================
--- Database/tables/dbo.Account.sql (revision 1587)
+++ Database/tables/dbo.Account.sql (working copy)
@@ -23,6 +23,8 @@
GO
CREATE CLUSTERED INDEX IX_Account ON [Account] ([CreationDateTime])
GO
+ALTER TABLE [dbo].[Account] ADD CONSTRAINT [UK_Account_APIKey] UNIQUE ([APIKey])
+GO
ALTER TABLE [dbo].[Account] ADD CONSTRAINT [DF_Account_AccountId] DEFAULT (newid()) FOR [AccountId]
GO
ALTER TABLE [dbo].[Account] ADD CONSTRAINT [DF_Account_CreationDateTime] DEFAULT (getutcdate()) FOR [CreationDateTime]