Page MenuHomePhabricator

D7513.id16939.diff

D7513.id16939.diff

diff --git a/resources/sql/patches/20131106.diffphid.1.col.sql b/resources/sql/patches/20131106.diffphid.1.col.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/patches/20131106.diffphid.1.col.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_differential.differential_diff
+ ADD phid VARCHAR(64) NOT NULL COLLATE utf8_bin AFTER id;
diff --git a/resources/sql/patches/20131106.diffphid.2.key.sql b/resources/sql/patches/20131106.diffphid.2.key.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/patches/20131106.diffphid.2.key.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_differential.differential_diff
+ ADD KEY `key_phid` (phid);
diff --git a/resources/sql/patches/20131106.diffphid.3.mig.php b/resources/sql/patches/20131106.diffphid.3.mig.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/patches/20131106.diffphid.3.mig.php
@@ -0,0 +1,24 @@
+<?php
+
+$diff_table = new DifferentialDiff();
+$conn_w = $diff_table->establishConnection('w');
+
+foreach (new LiskMigrationIterator($diff_table) as $diff) {
+ $id = $diff->getID();
+ echo "Migrating diff ID {$id}...\n";
+
+ $phid = $diff->getPHID();
+ if (!strlen($phid)) {
+ $type_diff = DifferentialPHIDTypeDiff::TYPECONST;
+ $new_phid = PhabricatorPHID::generateNewPHID($type_diff);
+
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET phid = %s WHERE id = %d',
+ $diff_table->getTableName(),
+ $new_phid,
+ $id);
+ }
+}
+
+echo "Done.\n";
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
@@ -396,6 +396,7 @@
'DifferentialMailPhase' => 'applications/differential/constants/DifferentialMailPhase.php',
'DifferentialManiphestTasksFieldSpecification' => 'applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php',
'DifferentialNewDiffMail' => 'applications/differential/mail/DifferentialNewDiffMail.php',
+ 'DifferentialPHIDTypeDiff' => 'applications/differential/phid/DifferentialPHIDTypeDiff.php',
'DifferentialPHIDTypeRevision' => 'applications/differential/phid/DifferentialPHIDTypeRevision.php',
'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php',
'DifferentialPathFieldSpecification' => 'applications/differential/field/specification/DifferentialPathFieldSpecification.php',
@@ -2604,6 +2605,7 @@
'DifferentialMail' => 'PhabricatorMail',
'DifferentialManiphestTasksFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail',
+ 'DifferentialPHIDTypeDiff' => 'PhabricatorPHIDType',
'DifferentialPHIDTypeRevision' => 'PhabricatorPHIDType',
'DifferentialParseRenderTestCase' => 'PhabricatorTestCase',
'DifferentialPathFieldSpecification' => 'DifferentialFieldSpecification',
diff --git a/src/applications/differential/phid/DifferentialPHIDTypeDiff.php b/src/applications/differential/phid/DifferentialPHIDTypeDiff.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/phid/DifferentialPHIDTypeDiff.php
@@ -0,0 +1,45 @@
+<?php
+
+final class DifferentialPHIDTypeDiff extends PhabricatorPHIDType {
+
+ const TYPECONST = 'DIFF';
+
+ public function getTypeConstant() {
+ return self::TYPECONST;
+ }
+
+ public function getTypeName() {
+ return pht('Differential Diff');
+ }
+
+ public function newObject() {
+ return new DifferentialDiff();
+ }
+
+ protected function buildQueryForObjects(
+ PhabricatorObjectQuery $query,
+ array $phids) {
+
+ return id(new DifferentialDiffQuery())
+ ->withPHIDs($phids);
+ }
+
+ public function loadHandles(
+ PhabricatorHandleQuery $query,
+ array $handles,
+ array $objects) {
+
+ foreach ($handles as $phid => $handle) {
+ $diff = $objects[$phid];
+
+ $id = $diff->getID();
+
+ $handle->setName(pht('Diff %d', $id));
+ }
+ }
+
+ public function canLoadNamedObject($name) {
+ return false;
+ }
+
+}
diff --git a/src/applications/differential/query/DifferentialDiffQuery.php b/src/applications/differential/query/DifferentialDiffQuery.php
--- a/src/applications/differential/query/DifferentialDiffQuery.php
+++ b/src/applications/differential/query/DifferentialDiffQuery.php
@@ -4,6 +4,7 @@
extends PhabricatorCursorPagedPolicyAwareQuery {
private $ids;
+ private $phids;
private $revisionIDs;
private $needChangesets = false;
private $needArcanistProjects = false;
@@ -13,6 +14,11 @@
return $this;
}
+ public function withPHIDs(array $phids) {
+ $this->phids = $phids;
+ return $this;
+ }
+
public function withRevisionIDs(array $revision_ids) {
$this->revisionIDs = $revision_ids;
return $this;
@@ -126,6 +132,13 @@
$this->ids);
}
+ if ($this->phids) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'phid IN (%Ls)',
+ $this->phids);
+ }
+
if ($this->revisionIDs) {
$where[] = qsprintf(
$conn_r,
diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php
--- a/src/applications/differential/storage/DifferentialDiff.php
+++ b/src/applications/differential/storage/DifferentialDiff.php
@@ -34,6 +34,17 @@
private $arcanistProject = self::ATTACHABLE;
private $revision = self::ATTACHABLE;
+ public function getConfiguration() {
+ return array(
+ self::CONFIG_AUX_PHID => true,
+ ) + parent::getConfiguration();
+ }
+
+ public function generatePHID() {
+ return PhabricatorPHID::generateNewPHID(
+ DifferentialPHIDTypeDiff::TYPECONST);
+ }
+
public function addUnsavedChangeset(DifferentialChangeset $changeset) {
if ($this->changesets === null) {
$this->changesets = array();
diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
--- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
+++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
@@ -1724,6 +1724,18 @@
'type' => 'sql',
'name' => $this->getPatchPath('20131105.buildstep.sql'),
),
+ '20131106.diffphid.1.col.sql' => array(
+ 'type' => 'sql',
+ 'name' => $this->getPatchPath('20131106.diffphid.1.col.sql'),
+ ),
+ '20131106.diffphid.2.key.sql' => array(
+ 'type' => 'sql',
+ 'name' => $this->getPatchPath('20131106.diffphid.2.key.sql'),
+ ),
+ '20131106.diffphid.3.mig.php' => array(
+ 'type' => 'php',
+ 'name' => $this->getPatchPath('20131106.diffphid.3.mig.php'),
+ ),
);
}
}

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/v2/ja/qfdtx777yqcobqwg
Default Alt Text
D7513.id16939.diff (6 KB)

Event Timeline