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) {
|
if ($done) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$prop_index = 2;
|
||||||
$trimline = ltrim($line);
|
$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 ($trimline && $trimline[0] == '+') {
|
||||||
if ($op == 'Deleted') {
|
if ($op == 'Deleted') {
|
||||||
$this->didFailParse('Unexpected "+" section in property deletion.');
|
$this->didFailParse('Unexpected "+" section in property deletion.');
|
||||||
}
|
}
|
||||||
$target = 'new';
|
$target = 'new';
|
||||||
$line = substr($trimline, 2);
|
$line = substr($trimline, $prop_index);
|
||||||
} else if ($trimline && $trimline[0] == '-') {
|
} else if ($trimline && $trimline[0] == '-') {
|
||||||
if ($op == 'Added') {
|
if ($op == 'Added') {
|
||||||
$this->didFailParse('Unexpected "-" section in property addition.');
|
$this->didFailParse('Unexpected "-" section in property addition.');
|
||||||
}
|
}
|
||||||
$target = 'old';
|
$target = 'old';
|
||||||
$line = substr($trimline, 2);
|
$line = substr($trimline, $prop_index);
|
||||||
} else if (!strncmp($trimline, 'Merged', 6)) {
|
} else if (!strncmp($trimline, 'Merged', 6)) {
|
||||||
if ($op == 'Added') {
|
if ($op == 'Added') {
|
||||||
$target = 'new';
|
$target = 'new';
|
||||||
|
@ -758,6 +767,18 @@ final class ArcanistDiffParser {
|
||||||
$matches);
|
$matches);
|
||||||
|
|
||||||
if (!$ok) {
|
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 @@'.");
|
$this->didFailParse("Expected hunk header '@@ -NN,NN +NN,NN @@'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -515,6 +515,15 @@ EOTEXT
|
||||||
ArcanistDiffChangeType::TYPE_CHANGE,
|
ArcanistDiffChangeType::TYPE_CHANGE,
|
||||||
$change->getType());
|
$change->getType());
|
||||||
break;
|
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:
|
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;
|
||||||
|
|
|
@ -11,6 +11,7 @@ phutil_require_module('arcanist', 'parser/diff/changetype');
|
||||||
phutil_require_module('arcanist', 'unit/engine/phutil/testcase');
|
phutil_require_module('arcanist', 'unit/engine/phutil/testcase');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'filesystem');
|
phutil_require_module('phutil', 'filesystem');
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('ArcanistDiffParserTestCase.php');
|
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