Page MenuHomePhabricator

D21572.id.diff
No OneTemporary

D21572.id.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -6519,7 +6519,7 @@
'DarkConsoleXHProfPluginAPI' => 'Phobject',
'DifferentialAction' => 'Phobject',
'DifferentialActionEmailCommand' => 'MetaMTAEmailTransactionCommand',
- 'DifferentialAdjustmentMapTestCase' => 'PhutilTestCase',
+ 'DifferentialAdjustmentMapTestCase' => 'PhabricatorTestCase',
'DifferentialAffectedPath' => 'DifferentialDAO',
'DifferentialAsanaRepresentationField' => 'DifferentialCustomField',
'DifferentialAuditorsCommitMessageField' => 'DifferentialCommitMessageCustomField',
diff --git a/src/applications/differential/parser/DifferentialLineAdjustmentMap.php b/src/applications/differential/parser/DifferentialLineAdjustmentMap.php
--- a/src/applications/differential/parser/DifferentialLineAdjustmentMap.php
+++ b/src/applications/differential/parser/DifferentialLineAdjustmentMap.php
@@ -78,7 +78,7 @@
// If we're tracing the first line and this block is collapsing,
// compute the offset from the top of the block.
if (!$is_end && $this->isInverse) {
- $offset = 0;
+ $offset = 1;
$cursor = $line - 1;
while (isset($nmap[$cursor])) {
$prev = $nmap[$cursor];
diff --git a/src/applications/differential/storage/__tests__/DifferentialAdjustmentMapTestCase.php b/src/applications/differential/storage/__tests__/DifferentialAdjustmentMapTestCase.php
--- a/src/applications/differential/storage/__tests__/DifferentialAdjustmentMapTestCase.php
+++ b/src/applications/differential/storage/__tests__/DifferentialAdjustmentMapTestCase.php
@@ -1,6 +1,7 @@
<?php
-final class DifferentialAdjustmentMapTestCase extends PhutilTestCase {
+final class DifferentialAdjustmentMapTestCase
+ extends PhabricatorTestCase {
public function testBasicMaps() {
$change_map = array(
@@ -62,7 +63,6 @@
DifferentialLineAdjustmentMap::newFromHunks($hunks)->getMap());
}
-
public function testInverseMaps() {
$change_map = array(
1 => array(1),
@@ -221,6 +221,45 @@
$this->assertEqual(3, $map->getFinalOffset());
}
+ public function testUnchangedUpdate() {
+ $diff1 = $this->loadHunks('insert.diff');
+ $diff2 = $this->loadHunks('insert.diff');
+
+ $map = DifferentialLineAdjustmentMap::newInverseMap(
+ DifferentialLineAdjustmentMap::newFromHunks($diff1));
+
+ $map->addMapToChain(
+ DifferentialLineAdjustmentMap::newFromHunks($diff2));
+
+ $actual = array();
+ for ($ii = 1; $ii <= 16; $ii++) {
+ $actual[$ii] = array(
+ $map->mapLine($ii, false),
+ $map->mapLine($ii, true),
+ );
+ }
+
+ $expect = array(
+ 1 => array(array(false, false, 1), array(false, false, 1)),
+ 2 => array(array(false, false, 2), array(false, false, 2)),
+ 3 => array(array(false, false, 3), array(false, false, 3)),
+ 4 => array(array(false, false, 4), array(false, false, 4)),
+ 5 => array(array(false, false, 5), array(false, false, 5)),
+ 6 => array(array(false, false, 6), array(false, false, 6)),
+ 7 => array(array(false, false, 7), array(false, false, 7)),
+ 8 => array(array(false, false, 8), array(false, false, 8)),
+ 9 => array(array(false, false, 9), array(false, false, 9)),
+ 10 => array(array(false, false, 10), array(false, false, 13)),
+ 11 => array(array(false, 1, 10), array(false, false, 14)),
+ 12 => array(array(false, 2, 10), array(false, false, 14)),
+ 13 => array(array(false, 3, 10), array(false, false, 14)),
+ 14 => array(array(false, false, 14), array(false, false, 14)),
+ 15 => array(array(false, false, 15), array(false, false, 15)),
+ 16 => array(array(false, false, 16), array(false, false, 16)),
+ );
+
+ $this->assertEqual($expect, $actual);
+ }
public function testChainMaps() {
// This test simulates porting inlines forward across a rebase.
@@ -258,9 +297,9 @@
5 => array(array(false, false, 3), array(false, false, 3)),
6 => array(array(false, false, 4), array(false, false, 4)),
7 => array(array(false, false, 5), array(false, false, 8)),
- 8 => array(array(false, 0, 5), array(false, false, 9)),
- 9 => array(array(false, 1, 5), array(false, false, 9)),
- 10 => array(array(false, 2, 5), array(false, false, 9)),
+ 8 => array(array(false, 1, 5), array(false, false, 9)),
+ 9 => array(array(false, 2, 5), array(false, false, 9)),
+ 10 => array(array(false, 3, 5), array(false, false, 9)),
11 => array(array(false, false, 9), array(false, false, 9)),
12 => array(array(false, false, 10), array(false, false, 10)),
13 => array(array(false, false, 11), array(false, false, 11)),

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 28, 8:10 PM (1 w, 3 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7722488
Default Alt Text
D21572.id.diff (4 KB)

Event Timeline