2011-03-31 02:36:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionSvnDiffQuery extends DiffusionDiffQuery {
|
|
|
|
|
|
|
|
protected function executeQuery() {
|
|
|
|
$drequest = $this->getRequest();
|
2011-10-28 17:04:57 +02:00
|
|
|
$repository = $drequest->getRepository();
|
2011-03-31 02:36:16 +02:00
|
|
|
|
2012-03-27 06:58:02 +02:00
|
|
|
$effective_commit = $this->getEffectiveCommit();
|
|
|
|
if (!$effective_commit) {
|
|
|
|
return null;
|
2011-04-03 02:11:51 +02:00
|
|
|
}
|
|
|
|
|
2012-03-27 06:58:02 +02:00
|
|
|
$drequest = clone $drequest;
|
|
|
|
$drequest->setCommit($effective_commit);
|
|
|
|
|
2011-03-31 02:36:16 +02:00
|
|
|
$path_change_query = DiffusionPathChangeQuery::newFromDiffusionRequest(
|
|
|
|
$drequest);
|
|
|
|
$path_changes = $path_change_query->loadChanges();
|
|
|
|
|
|
|
|
$path = null;
|
|
|
|
foreach ($path_changes as $change) {
|
|
|
|
if ($change->getPath() == $drequest->getPath()) {
|
|
|
|
$path = $change;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$path) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$change_type = $path->getChangeType();
|
|
|
|
switch ($change_type) {
|
|
|
|
case DifferentialChangeType::TYPE_MULTICOPY:
|
|
|
|
case DifferentialChangeType::TYPE_DELETE:
|
|
|
|
if ($path->getTargetPath()) {
|
|
|
|
$old = array(
|
|
|
|
$path->getTargetPath(),
|
|
|
|
$path->getTargetCommitIdentifier());
|
|
|
|
} else {
|
|
|
|
$old = array($path->getPath(), $path->getCommitIdentifier() - 1);
|
|
|
|
}
|
|
|
|
$old_name = $path->getPath();
|
|
|
|
$new_name = '';
|
|
|
|
$new = null;
|
|
|
|
break;
|
|
|
|
case DifferentialChangeType::TYPE_ADD:
|
|
|
|
$old = null;
|
|
|
|
$new = array($path->getPath(), $path->getCommitIdentifier());
|
|
|
|
$old_name = '';
|
|
|
|
$new_name = $path->getPath();
|
|
|
|
break;
|
|
|
|
case DifferentialChangeType::TYPE_MOVE_HERE:
|
|
|
|
case DifferentialChangeType::TYPE_COPY_HERE:
|
|
|
|
$old = array(
|
|
|
|
$path->getTargetPath(),
|
|
|
|
$path->getTargetCommitIdentifier());
|
|
|
|
$new = array($path->getPath(), $path->getCommitIdentifier());
|
|
|
|
$old_name = $path->getTargetPath();
|
|
|
|
$new_name = $path->getPath();
|
|
|
|
break;
|
2011-07-20 21:07:26 +02:00
|
|
|
case DifferentialChangeType::TYPE_MOVE_AWAY:
|
|
|
|
$old = array(
|
|
|
|
$path->getPath(),
|
|
|
|
$path->getCommitIdentifier() - 1);
|
|
|
|
$old_name = $path->getPath();
|
|
|
|
$new_name = null;
|
|
|
|
$new = null;
|
|
|
|
break;
|
2011-03-31 02:36:16 +02:00
|
|
|
default:
|
|
|
|
$old = array($path->getPath(), $path->getCommitIdentifier() - 1);
|
|
|
|
$new = array($path->getPath(), $path->getCommitIdentifier());
|
|
|
|
$old_name = $path->getPath();
|
|
|
|
$new_name = $path->getPath();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$futures = array(
|
|
|
|
'old' => $this->buildContentFuture($old),
|
|
|
|
'new' => $this->buildContentFuture($new),
|
|
|
|
);
|
|
|
|
$futures = array_filter($futures);
|
|
|
|
|
|
|
|
foreach (Futures($futures) as $key => $future) {
|
2012-03-24 00:28:42 +01:00
|
|
|
$stdout = '';
|
2012-03-13 21:32:17 +01:00
|
|
|
try {
|
|
|
|
list($stdout) = $future->resolvex();
|
|
|
|
} catch (CommandException $e) {
|
|
|
|
if ($path->getFileType() != DifferentialChangeType::FILE_DIRECTORY) {
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
2011-07-20 20:43:44 +02:00
|
|
|
$futures[$key] = $stdout;
|
2011-03-31 02:36:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$old_data = idx($futures, 'old', '');
|
|
|
|
$new_data = idx($futures, 'new', '');
|
|
|
|
|
2011-07-20 20:43:44 +02:00
|
|
|
$engine = new PhabricatorDifferenceEngine();
|
|
|
|
$engine->setOldName($old_name);
|
|
|
|
$engine->setNewName($new_name);
|
|
|
|
$raw_diff = $engine->generateRawDiffFromFileContent($old_data, $new_data);
|
2011-03-31 02:36:16 +02:00
|
|
|
|
|
|
|
$parser = new ArcanistDiffParser();
|
2011-10-28 17:04:57 +02:00
|
|
|
|
|
|
|
$try_encoding = $repository->getDetail('encoding');
|
|
|
|
if ($try_encoding) {
|
|
|
|
$parser->setTryEncoding($try_encoding);
|
|
|
|
}
|
|
|
|
|
2011-03-31 02:36:16 +02:00
|
|
|
$parser->setDetectBinaryFiles(true);
|
|
|
|
|
2011-03-31 04:32:51 +02:00
|
|
|
$arcanist_changes = DiffusionPathChange::convertToArcanistChanges(
|
|
|
|
$path_changes);
|
|
|
|
|
|
|
|
$parser->setChanges($arcanist_changes);
|
|
|
|
$parser->forcePath($path->getPath());
|
|
|
|
$changes = $parser->parseDiff($raw_diff);
|
|
|
|
|
|
|
|
$change = $changes[$path->getPath()];
|
2011-03-31 02:36:16 +02:00
|
|
|
|
|
|
|
$diff = DifferentialDiff::newFromRawChanges(array($change));
|
|
|
|
$changesets = $diff->getChangesets();
|
|
|
|
$changeset = reset($changesets);
|
|
|
|
|
Move "Rendering References" to the DifferentialChangesetParser level
Summary:
Separates changeset IDs from rendering. Now each changeset has a "rendering
reference" which is basically a description of what the ajax endpoint should
render. For Differential, it's in the form "id/vs". For Diffusion,
"branch/path;commit".
I believe this fixes pretty much all of the bugs related to "show more" breaking
in various obscure ways, although I never got a great repro for T153.
Test Plan:
Clicked "show more" in diffusion change and commit views and differential diff,
diff-of-diff, standalone-diff, standalone-diff-of-diff views. Verified refs and
'whitespace' were always sent correctly.
Made inline comments on diffs and diffs-of-diffs. Used "Reply".
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: aran, tuomaspelkonen, epriestley
Differential Revision: 274
2011-05-12 06:46:29 +02:00
|
|
|
$this->renderingReference = $drequest->getPath().';'.$drequest->getCommit();
|
2011-03-31 02:36:16 +02:00
|
|
|
|
|
|
|
return $changeset;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildContentFuture($spec) {
|
|
|
|
if (!$spec) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$drequest = $this->getRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
list($ref, $rev) = $spec;
|
2011-09-08 21:46:48 +02:00
|
|
|
return $repository->getRemoteCommandFuture(
|
|
|
|
'cat %s%s@%d',
|
|
|
|
$repository->getRemoteURI(),
|
2013-02-13 11:30:11 +01:00
|
|
|
phutil_escape_uri($ref),
|
2011-03-31 02:36:16 +02:00
|
|
|
$rev);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|