mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 10:12:41 +01:00
[svn1.7] Handle changes to svn properties in svn1.7 working copies
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
This commit is contained in:
parent
ec9a3ddb23
commit
6dd511d0ef
4 changed files with 56 additions and 2 deletions
|
@ -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 @@'.");
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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
|
||||
|
Loading…
Reference in a new issue