1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

Improve Diffusion behavior for SVN file moves

Summary:
We just weren't handling these at all reasonably, must have dropped the logic
when they got ported.

This still isn't perfect: we have some display glitches around file names, so
the 'away' part renders as "This file was moved to .". I'll see if I can follow
up and fix that, but this resolves the more immediate issue of the interface
just not working at all.

Test Plan: Moved and copied files in my test repository, verified they rendered
somewhat correctly.
Reviewed By: jungejason
Reviewers: tuomaspelkonen, jungejason, aran
CC: aran, jungejason, epriestley
Differential Revision: 699
This commit is contained in:
epriestley 2011-07-20 12:07:26 -07:00
parent 4dc6552af9
commit ede78b2ccc
2 changed files with 32 additions and 5 deletions

View file

@ -75,6 +75,14 @@ final class DiffusionSvnDiffQuery extends DiffusionDiffQuery {
$old_name = $path->getTargetPath();
$new_name = $path->getPath();
break;
case DifferentialChangeType::TYPE_MOVE_AWAY:
$old = array(
$path->getPath(),
$path->getCommitIdentifier() - 1);
$old_name = $path->getPath();
$new_name = null;
$new = null;
break;
default:
$old = array($path->getPath(), $path->getCommitIdentifier() - 1);
$new = array($path->getPath(), $path->getCommitIdentifier());

View file

@ -49,21 +49,21 @@ class DiffusionPathChangeQuery {
$raw_changes = queryfx_all(
$repository->establishConnection('r'),
'SELECT c.*, p.path pathName, t.path targetPathName
'SELECT c.*, p.path pathName, t.path targetPathName,
i.commitIdentifier targetCommitIdentifier
FROM %T c
LEFT JOIN %T p ON c.pathID = p.id
LEFT JOIN %T t on c.targetPathID = t.id
LEFT JOIN %T t ON c.targetPathID = t.id
LEFT JOIN %T i ON c.targetCommitID = i.id
WHERE c.commitID = %d AND isDirect = 1',
PhabricatorRepository::TABLE_PATHCHANGE,
PhabricatorRepository::TABLE_PATH,
PhabricatorRepository::TABLE_PATH,
$commit->getTableName(),
$commit->getID());
$changes = array();
$raw_changes = isort($raw_changes, 'pathName');
foreach ($raw_changes as $raw_change) {
$type = $raw_change['changeType'];
@ -76,9 +76,28 @@ class DiffusionPathChangeQuery {
$change->setChangeType($raw_change['changeType']);
$change->setFileType($raw_change['fileType']);
$change->setCommitIdentifier($commit->getCommitIdentifier());
$change->setTargetPath(ltrim($raw_change['targetPathName'], '/'));
$change->setTargetCommitIdentifier($raw_change['targetCommitIdentifier']);
$changes[] = $change;
}
// Deduce the away paths by examining all the changes.
$away = array();
foreach ($changes as $change) {
if ($change->getTargetPath()) {
$away[$change->getTargetPath()][] = $change->getPath();
}
}
foreach ($changes as $change) {
if (isset($away[$change->getPath()])) {
$change->setAwayPaths($away[$change->getPath()]);
}
}
return $changes;
}
}