1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +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:
epriestley 2014-05-25 12:02:34 -07:00
parent 4b39fbe115
commit 40e2a1c800
6 changed files with 18 additions and 11 deletions

View file

@ -3,7 +3,7 @@
final class DifferentialChangesetParserTestCase extends PhabricatorTestCase {
public function testDiffChangesets() {
$hunk = new DifferentialHunkLegacy();
$hunk = new DifferentialHunkModern();
$hunk->setChanges("+a\n b\n-c");
$hunk->setNewOffset(1);
$hunk->setNewLen(2);
@ -20,7 +20,7 @@ final class DifferentialChangesetParserTestCase extends PhabricatorTestCase {
);
foreach ($tests as $changes => $expected) {
$hunk = new DifferentialHunkLegacy();
$hunk = new DifferentialHunkModern();
$hunk->setChanges($changes);
$hunk->setNewOffset(11);
$hunk->setNewLen(3);

View file

@ -14,7 +14,7 @@ final class DifferentialHunkParserTestCase extends PhabricatorTestCase {
$new_len,
$changes) {
$hunk = id(new DifferentialHunkLegacy())
$hunk = id(new DifferentialHunkModern())
->setOldOffset($old_offset)
->setOldLen($old_len)
->setNewOffset($new_offset)

View file

@ -76,11 +76,18 @@ final class DifferentialChangeset extends DifferentialDAO
public function delete() {
$this->openTransaction();
$hunks = id(new DifferentialHunkLegacy())->loadAllWhere(
$legacy_hunks = id(new DifferentialHunkLegacy())->loadAllWhere(
'changesetID = %d',
$this->getID());
foreach ($hunks as $hunk) {
$hunk->delete();
foreach ($legacy_hunks as $legacy_hunk) {
$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();

View file

@ -132,7 +132,7 @@ final class DifferentialDiff
$hunks = $change->getHunks();
if ($hunks) {
foreach ($hunks as $hunk) {
$dhunk = new DifferentialHunkLegacy();
$dhunk = new DifferentialHunkModern();
$dhunk->setOldOffset($hunk->getOldOffset());
$dhunk->setOldLen($hunk->getOldLength());
$dhunk->setNewOffset($hunk->getNewOffset());

View file

@ -5,7 +5,7 @@ final class DifferentialHunkTestCase extends ArcanistPhutilTestCase {
public function testMakeChanges() {
$root = dirname(__FILE__).'/hunk/';
$hunk = new DifferentialHunkLegacy();
$hunk = new DifferentialHunkModern();
$hunk->setChanges(Filesystem::readFile($root.'basic.diff'));
$hunk->setOldOffset(1);
$hunk->setNewOffset(11);
@ -23,7 +23,7 @@ final class DifferentialHunkTestCase extends ArcanistPhutilTestCase {
);
$this->assertEqual($added, $hunk->getAddedLines());
$hunk = new DifferentialHunkLegacy();
$hunk = new DifferentialHunkModern();
$hunk->setChanges(Filesystem::readFile($root.'newline.diff'));
$hunk->setOldOffset(1);
$hunk->setNewOffset(11);

View file

@ -382,8 +382,8 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
// -echo "test";
// -(empty line)
$hunk = id(new DifferentialHunkLegacy())->setChanges($context);
$vs_hunk = id(new DifferentialHunkLegacy())->setChanges($vs_context);
$hunk = id(new DifferentialHunkModern())->setChanges($context);
$vs_hunk = id(new DifferentialHunkModern())->setChanges($vs_context);
if ($hunk->makeOldFile() != $vs_hunk->makeOldFile() ||
$hunk->makeNewFile() != $vs_hunk->makeNewFile()) {
return $vs_diff;