]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Parse the output of `svnlook diff ...`
authorepriestley <git@epriestley.com>
Wed, 18 Dec 2013 22:20:59 +0000 (14:20 -0800)
committerepriestley <git@epriestley.com>
Wed, 18 Dec 2013 22:20:59 +0000 (14:20 -0800)
Summary: Ref T4195. When figuring out changed content in SVN, the easiest approach is to use `svnlook diff`, but it has a slightly different header than we're used to. Adjust the parser for it and add some tests.

Test Plan: Clean unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T4195

Differential Revision: https://secure.phabricator.com/D7790

src/parser/ArcanistDiffParser.php
src/parser/__tests__/ArcanistDiffParserTestCase.php
src/parser/__tests__/diff/svnlook-add.svndiff [new file with mode: 0644]
src/parser/__tests__/diff/svnlook-basics.svndiff [new file with mode: 0644]
src/parser/__tests__/diff/svnlook-delete.svndiff [new file with mode: 0644]

index b6e8cbcd1b7c21cb02ec9f40b42d745735884973..45d2520b3430bc34d070318bfc8e9867348f1090 100644 (file)
@@ -207,6 +207,8 @@ final class ArcanistDiffParser {
       $patterns = array(
         // This is a normal SVN text change, probably from "svn diff".
         '(?P<type>Index): (?P<cur>.+)',
+        // This is an SVN text change, probably from "svnlook diff".
+        '(?P<type>Modified|Added|Deleted): (?P<cur>.+)',
         // This is an SVN property change, probably from "svn diff".
         '(?P<type>Property changes on): (?P<cur>.+)',
         // This is a git commit message, probably from "git show".
@@ -285,6 +287,9 @@ final class ArcanistDiffParser {
 
       switch ($match['type']) {
         case 'Index':
+        case 'Modified':
+        case 'Added':
+        case 'Deleted':
           $this->parseIndexHunk($change);
           break;
         case 'Property changes on':
index 32010f67c71cb97e17d21a37697ef3080a4edc1d..a4becd86fa34d161edb0439de601444fbea1eef1 100644 (file)
@@ -570,6 +570,11 @@ EOTEXT
           ArcanistDiffChangeType::TYPE_CHANGE,
           $change->getType());
         break;
+      case 'svnlook-basics.svndiff':
+      case 'svnlook-add.svndiff':
+      case 'svnlook-delete.svndiff':
+        $this->assertEqual(1, count($changes));
+        break;
       default:
         throw new Exception("No test block for diff file {$diff_file}.");
         break;
diff --git a/src/parser/__tests__/diff/svnlook-add.svndiff b/src/parser/__tests__/diff/svnlook-add.svndiff
new file mode 100644 (file)
index 0000000..fbfb1f4
--- /dev/null
@@ -0,0 +1,7 @@
+Added: OTHER
+===================================================================
+--- OTHER                              (rev 0)
++++ OTHER      2013-12-18 21:00:43 UTC (txn 18-y)
+@@ -0,0 +1 @@
++other
+
diff --git a/src/parser/__tests__/diff/svnlook-basics.svndiff b/src/parser/__tests__/diff/svnlook-basics.svndiff
new file mode 100644 (file)
index 0000000..e7c45c6
--- /dev/null
@@ -0,0 +1,10 @@
+Modified: README
+===================================================================
+--- README     2013-12-18 20:56:12 UTC (rev 17)
++++ README     2013-12-18 20:56:47 UTC (txn 17-x)
+@@ -17,3 +17,4 @@
+ j
+ j
+ j
++j
+
diff --git a/src/parser/__tests__/diff/svnlook-delete.svndiff b/src/parser/__tests__/diff/svnlook-delete.svndiff
new file mode 100644 (file)
index 0000000..c3e7f7a
--- /dev/null
@@ -0,0 +1,7 @@
+Deleted: OTHER
+===================================================================
+--- OTHER      2013-12-18 21:00:43 UTC (rev 19)
++++ OTHER      2013-12-18 21:01:18 UTC (txn 19-z)
+@@ -1 +0,0 @@
+-other
+