mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Write new hunks to the modern hunk store
Summary: Ref T4045. Ref T5179. Send all new writes into the modern store. Test Plan: - Created a diff. - Verified it went to the modern store. - Destroyed a revision, verified hunks were destroyed. - Also unit tests. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4045, T5179 Differential Revision: https://secure.phabricator.com/D9293
This commit is contained in:
parent
4b39fbe115
commit
40e2a1c800
6 changed files with 18 additions and 11 deletions
|
@ -3,7 +3,7 @@
|
||||||
final class DifferentialChangesetParserTestCase extends PhabricatorTestCase {
|
final class DifferentialChangesetParserTestCase extends PhabricatorTestCase {
|
||||||
|
|
||||||
public function testDiffChangesets() {
|
public function testDiffChangesets() {
|
||||||
$hunk = new DifferentialHunkLegacy();
|
$hunk = new DifferentialHunkModern();
|
||||||
$hunk->setChanges("+a\n b\n-c");
|
$hunk->setChanges("+a\n b\n-c");
|
||||||
$hunk->setNewOffset(1);
|
$hunk->setNewOffset(1);
|
||||||
$hunk->setNewLen(2);
|
$hunk->setNewLen(2);
|
||||||
|
@ -20,7 +20,7 @@ final class DifferentialChangesetParserTestCase extends PhabricatorTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($tests as $changes => $expected) {
|
foreach ($tests as $changes => $expected) {
|
||||||
$hunk = new DifferentialHunkLegacy();
|
$hunk = new DifferentialHunkModern();
|
||||||
$hunk->setChanges($changes);
|
$hunk->setChanges($changes);
|
||||||
$hunk->setNewOffset(11);
|
$hunk->setNewOffset(11);
|
||||||
$hunk->setNewLen(3);
|
$hunk->setNewLen(3);
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class DifferentialHunkParserTestCase extends PhabricatorTestCase {
|
||||||
$new_len,
|
$new_len,
|
||||||
$changes) {
|
$changes) {
|
||||||
|
|
||||||
$hunk = id(new DifferentialHunkLegacy())
|
$hunk = id(new DifferentialHunkModern())
|
||||||
->setOldOffset($old_offset)
|
->setOldOffset($old_offset)
|
||||||
->setOldLen($old_len)
|
->setOldLen($old_len)
|
||||||
->setNewOffset($new_offset)
|
->setNewOffset($new_offset)
|
||||||
|
|
|
@ -76,11 +76,18 @@ final class DifferentialChangeset extends DifferentialDAO
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$this->openTransaction();
|
$this->openTransaction();
|
||||||
|
|
||||||
$hunks = id(new DifferentialHunkLegacy())->loadAllWhere(
|
$legacy_hunks = id(new DifferentialHunkLegacy())->loadAllWhere(
|
||||||
'changesetID = %d',
|
'changesetID = %d',
|
||||||
$this->getID());
|
$this->getID());
|
||||||
foreach ($hunks as $hunk) {
|
foreach ($legacy_hunks as $legacy_hunk) {
|
||||||
$hunk->delete();
|
$legacy_hunk->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
$modern_hunks = id(new DifferentialHunkModern())->loadAllWhere(
|
||||||
|
'changesetID = %d',
|
||||||
|
$this->getID());
|
||||||
|
foreach ($modern_hunks as $modern_hunk) {
|
||||||
|
$modern_hunk->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->unsavedHunks = array();
|
$this->unsavedHunks = array();
|
||||||
|
|
|
@ -132,7 +132,7 @@ final class DifferentialDiff
|
||||||
$hunks = $change->getHunks();
|
$hunks = $change->getHunks();
|
||||||
if ($hunks) {
|
if ($hunks) {
|
||||||
foreach ($hunks as $hunk) {
|
foreach ($hunks as $hunk) {
|
||||||
$dhunk = new DifferentialHunkLegacy();
|
$dhunk = new DifferentialHunkModern();
|
||||||
$dhunk->setOldOffset($hunk->getOldOffset());
|
$dhunk->setOldOffset($hunk->getOldOffset());
|
||||||
$dhunk->setOldLen($hunk->getOldLength());
|
$dhunk->setOldLen($hunk->getOldLength());
|
||||||
$dhunk->setNewOffset($hunk->getNewOffset());
|
$dhunk->setNewOffset($hunk->getNewOffset());
|
||||||
|
|
|
@ -5,7 +5,7 @@ final class DifferentialHunkTestCase extends ArcanistPhutilTestCase {
|
||||||
public function testMakeChanges() {
|
public function testMakeChanges() {
|
||||||
$root = dirname(__FILE__).'/hunk/';
|
$root = dirname(__FILE__).'/hunk/';
|
||||||
|
|
||||||
$hunk = new DifferentialHunkLegacy();
|
$hunk = new DifferentialHunkModern();
|
||||||
$hunk->setChanges(Filesystem::readFile($root.'basic.diff'));
|
$hunk->setChanges(Filesystem::readFile($root.'basic.diff'));
|
||||||
$hunk->setOldOffset(1);
|
$hunk->setOldOffset(1);
|
||||||
$hunk->setNewOffset(11);
|
$hunk->setNewOffset(11);
|
||||||
|
@ -23,7 +23,7 @@ final class DifferentialHunkTestCase extends ArcanistPhutilTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEqual($added, $hunk->getAddedLines());
|
$this->assertEqual($added, $hunk->getAddedLines());
|
||||||
|
|
||||||
$hunk = new DifferentialHunkLegacy();
|
$hunk = new DifferentialHunkModern();
|
||||||
$hunk->setChanges(Filesystem::readFile($root.'newline.diff'));
|
$hunk->setChanges(Filesystem::readFile($root.'newline.diff'));
|
||||||
$hunk->setOldOffset(1);
|
$hunk->setOldOffset(1);
|
||||||
$hunk->setNewOffset(11);
|
$hunk->setNewOffset(11);
|
||||||
|
|
|
@ -382,8 +382,8 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
// -echo "test";
|
// -echo "test";
|
||||||
// -(empty line)
|
// -(empty line)
|
||||||
|
|
||||||
$hunk = id(new DifferentialHunkLegacy())->setChanges($context);
|
$hunk = id(new DifferentialHunkModern())->setChanges($context);
|
||||||
$vs_hunk = id(new DifferentialHunkLegacy())->setChanges($vs_context);
|
$vs_hunk = id(new DifferentialHunkModern())->setChanges($vs_context);
|
||||||
if ($hunk->makeOldFile() != $vs_hunk->makeOldFile() ||
|
if ($hunk->makeOldFile() != $vs_hunk->makeOldFile() ||
|
||||||
$hunk->makeNewFile() != $vs_hunk->makeNewFile()) {
|
$hunk->makeNewFile() != $vs_hunk->makeNewFile()) {
|
||||||
return $vs_diff;
|
return $vs_diff;
|
||||||
|
|
Loading…
Reference in a new issue