]> khamidou — GitHub mirrors - arcanist.git/commitdiff
[svn1.7] Handle changes to svn properties in svn1.7 working copies
authorNick Harper <nharper@fb.com>
Tue, 13 Mar 2012 23:05:57 +0000 (16:05 -0700)
committerNick Harper <nharper@fb.com>
Tue, 13 Mar 2012 23:34:13 +0000 (16:34 -0700)
Summary: svn changed the format of property changes for svn1.7.

Test Plan: arc diff on a working copy with svn property changes

Reviewers: epriestley, jungejason

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1885

src/parser/diff/ArcanistDiffParser.php
src/parser/diff/__tests__/ArcanistDiffParserTestCase.php
src/parser/diff/__tests__/__init__.php
src/parser/diff/__tests__/data/svn-1.7-property-added.svndiff [new file with mode: 0644]

index 231f657617bbdc3c0bdff23b97f5bbefd0b11e1b..716139a9b0c975ebca557e1fa3df5e968e075a7c 100644 (file)
@@ -402,19 +402,28 @@ final class ArcanistDiffParser {
       if ($done) {
         break;
       }
+      $prop_index = 2;
       $trimline = ltrim($line);
+      if ($trimline && $trimline[0] == '#') {
+        // in svn1.7, a line like ## -0,0 +1 ## is put between the Added: line
+        // and the line with the property change. If we have such a line, we'll
+        // just ignore it (:
+        $line = $this->nextLine();
+        $prop_index = 1;
+        $trimline = ltrim($line);
+      }
       if ($trimline && $trimline[0] == '+') {
         if ($op == 'Deleted') {
           $this->didFailParse('Unexpected "+" section in property deletion.');
         }
         $target = 'new';
-        $line = substr($trimline, 2);
+        $line = substr($trimline, $prop_index);
       } else if ($trimline && $trimline[0] == '-') {
         if ($op == 'Added') {
           $this->didFailParse('Unexpected "-" section in property addition.');
         }
         $target = 'old';
-        $line = substr($trimline, 2);
+        $line = substr($trimline, $prop_index);
       } else if (!strncmp($trimline, 'Merged', 6)) {
         if ($op == 'Added') {
           $target = 'new';
@@ -758,6 +767,18 @@ final class ArcanistDiffParser {
         $matches);
 
       if (!$ok) {
+        // It's possible we hit the style of an svn1.7 property change.
+        // This is a 4-line Index block, followed by an empty line, followed
+        // by a "Property changes on:" section similar to svn1.6.
+        if ($line == '') {
+          $line = $this->nextNonemptyLine();
+          $ok = preg_match('/^Property changes on:/', $line);
+          if (!$ok) {
+            $this->didFailParse("Confused by empty line");
+          }
+          $line = $this->nextLine();
+          return $this->parsePropertyHunk($change);
+        }
         $this->didFailParse("Expected hunk header '@@ -NN,NN +NN,NN @@'.");
       }
 
index 58bba54b8494b8c6d65ce596110bef10228287b5..3903de08caf5ec7426e39944c93c2243e63a827d 100644 (file)
@@ -515,6 +515,15 @@ EOTEXT
           ArcanistDiffChangeType::TYPE_CHANGE,
           $change->getType());
         break;
+      case 'svn-1.7-property-added.svndiff':
+        $this->assertEqual(1, count($changes));
+        $change = head($changes);
+        $new_properties = $change->getNewProperties();
+        $this->assertEqual(2, count($new_properties));
+        $this->assertEqual('*', idx($new_properties, 'svn:executable'));
+        $this->assertEqual('text/html', idx($new_properties, 'svn:mime-type'));
+        print_r($changes);
+        break;
       default:
         throw new Exception("No test block for diff file {$diff_file}.");
         break;
index 70b73e47bf93eb4033d0ad4d185ebf6f563ccf93..9661fc5f33a1d0430920fe8a2dd5d199f269d404 100644 (file)
@@ -11,6 +11,7 @@ phutil_require_module('arcanist', 'parser/diff/changetype');
 phutil_require_module('arcanist', 'unit/engine/phutil/testcase');
 
 phutil_require_module('phutil', 'filesystem');
+phutil_require_module('phutil', 'utils');
 
 
 phutil_require_source('ArcanistDiffParserTestCase.php');
diff --git a/src/parser/diff/__tests__/data/svn-1.7-property-added.svndiff b/src/parser/diff/__tests__/data/svn-1.7-property-added.svndiff
new file mode 100644 (file)
index 0000000..17cee65
--- /dev/null
@@ -0,0 +1,23 @@
+Index: test/testing
+===================================================================
+--- test/testing        (revision 0)
++++ test/testing        (working copy)
+@@ -0,0 +1,4 @@
++This
++is
++a
++test
+Index: test/testing
+===================================================================
+--- test/testing        (revision 0)
++++ test/testing        (working copy)
+
+Property changes on: test/testing
+___________________________________________________________________
+Added: svn:executable
+## -0,0 +1 ##
++*
+Added: svn:mime-type
+## -0,0 +1 ##
++text/html
+