Page MenuHomestyx hydra

No OneTemporary

diff --git a/resources/sql/autopatches/20210315.affectedpath.01.epoch.sql b/resources/sql/autopatches/20210315.affectedpath.01.epoch.sql
new file mode 100644
index 0000000000..80c337fd94
--- /dev/null
+++ b/resources/sql/autopatches/20210315.affectedpath.01.epoch.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_differential.differential_affectedpath
+ DROP epoch;
diff --git a/resources/sql/autopatches/20210315.affectedpath.02.repositoryid.sql b/resources/sql/autopatches/20210315.affectedpath.02.repositoryid.sql
new file mode 100644
index 0000000000..1975b7c071
--- /dev/null
+++ b/resources/sql/autopatches/20210315.affectedpath.02.repositoryid.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_differential.differential_affectedpath
+ CHANGE repositoryID repositoryID INT UNSIGNED;
diff --git a/src/applications/differential/engine/DifferentialAffectedPathEngine.php b/src/applications/differential/engine/DifferentialAffectedPathEngine.php
index cdf1c168b1..0ac85e5900 100644
--- a/src/applications/differential/engine/DifferentialAffectedPathEngine.php
+++ b/src/applications/differential/engine/DifferentialAffectedPathEngine.php
@@ -1,137 +1,136 @@
<?php
final class DifferentialAffectedPathEngine
extends Phobject {
private $revision;
private $diff;
public function setRevision(DifferentialRevision $revision) {
$this->revision = $revision;
return $this;
}
public function getRevision() {
return $this->revision;
}
public function setDiff(DifferentialDiff $diff) {
$this->diff = $diff;
return $this;
}
public function getDiff() {
return $this->diff;
}
public function updateAffectedPaths() {
$revision = $this->getRevision();
$diff = $this->getDiff();
$repository = $revision->getRepository();
if ($repository) {
$repository_id = $repository->getID();
} else {
- return;
+ $repository_id = null;
}
$paths = $this->getAffectedPaths();
$path_ids =
PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths(
$paths);
$table = new DifferentialAffectedPath();
$conn = $table->establishConnection('w');
$sql = array();
foreach ($path_ids as $path_id) {
$sql[] = qsprintf(
$conn,
- '(%d, %d, %d, %d)',
+ '(%nd, %d, %d)',
$repository_id,
$path_id,
- PhabricatorTime::getNow(),
$revision->getID());
}
queryfx(
$conn,
'DELETE FROM %R WHERE revisionID = %d',
$table,
$revision->getID());
if ($sql) {
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx(
$conn,
- 'INSERT INTO %R (repositoryID, pathID, epoch, revisionID) VALUES %LQ',
+ 'INSERT INTO %R (repositoryID, pathID, revisionID) VALUES %LQ',
$table,
$chunk);
}
}
}
public function destroyAffectedPaths() {
$revision = $this->getRevision();
$table = new DifferentialAffectedPath();
$conn = $table->establishConnection('w');
queryfx(
$conn,
'DELETE FROM %R WHERE revisionID = %d',
$table,
$revision->getID());
}
public function getAffectedPaths() {
$revision = $this->getRevision();
$diff = $this->getDiff();
$repository = $revision->getRepository();
$path_prefix = null;
if ($repository) {
$local_root = $diff->getSourceControlPath();
if ($local_root) {
// We're in a working copy which supports subdirectory checkouts (e.g.,
// SVN) so we need to figure out what prefix we should add to each path
// (e.g., trunk/projects/example/) to get the absolute path from the
// root of the repository. DVCS systems like Git and Mercurial are not
// affected.
// Normalize both paths and check if the repository root is a prefix of
// the local root. If so, throw it away. Note that this correctly
// handles the case where the remote path is "/".
$local_root = id(new PhutilURI($local_root))->getPath();
$local_root = rtrim($local_root, '/');
$repo_root = id(new PhutilURI($repository->getRemoteURI()))->getPath();
$repo_root = rtrim($repo_root, '/');
if (!strncmp($repo_root, $local_root, strlen($repo_root))) {
$path_prefix = substr($local_root, strlen($repo_root));
}
}
}
$changesets = $diff->getChangesets();
$paths = array();
foreach ($changesets as $changeset) {
$paths[] = $path_prefix.'/'.$changeset->getFilename();
}
// Mark this as also touching all parent paths, so you can see all pending
// changes to any file within a directory.
$all_paths = array();
foreach ($paths as $local) {
foreach (DiffusionPathIDQuery::expandPathToRoot($local) as $path) {
$all_paths[$path] = true;
}
}
$all_paths = array_keys($all_paths);
return $all_paths;
}
}
diff --git a/src/applications/differential/storage/DifferentialAffectedPath.php b/src/applications/differential/storage/DifferentialAffectedPath.php
index b8de95629b..400a09fe82 100644
--- a/src/applications/differential/storage/DifferentialAffectedPath.php
+++ b/src/applications/differential/storage/DifferentialAffectedPath.php
@@ -1,32 +1,32 @@
<?php
/**
* Denormalized index table which stores relationships between revisions in
* Differential and paths in Diffusion.
*/
final class DifferentialAffectedPath extends DifferentialDAO {
protected $repositoryID;
protected $pathID;
- protected $epoch;
protected $revisionID;
protected function getConfiguration() {
return array(
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_COLUMN_SCHEMA => array(
'id' => null,
+ 'repositoryID' => 'id?',
),
self::CONFIG_KEY_SCHEMA => array(
'PRIMARY' => null,
- 'repositoryID' => array(
- 'columns' => array('repositoryID', 'pathID', 'epoch'),
- ),
'revisionID' => array(
'columns' => array('revisionID'),
),
+ 'key_path' => array(
+ 'columns' => array('pathID', 'repositoryID'),
+ ),
),
) + parent::getConfiguration();
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 26, 6:00 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1224
Default Alt Text
(6 KB)

Event Timeline