mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 07:11:04 +01:00
Open editor on first modified line
Test Plan: Created diff, opened the file from Differential, opened the file in Diffusion. Reviewers: btrahan, epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3538
This commit is contained in:
parent
cad1eed24a
commit
e0e97b08b8
3 changed files with 16 additions and 4 deletions
|
@ -136,6 +136,7 @@ final class DifferentialDiff extends DifferentialDAO {
|
||||||
$changeset = new DifferentialChangeset();
|
$changeset = new DifferentialChangeset();
|
||||||
$add_lines = 0;
|
$add_lines = 0;
|
||||||
$del_lines = 0;
|
$del_lines = 0;
|
||||||
|
$first_line = PHP_INT_MAX;
|
||||||
$hunks = $change->getHunks();
|
$hunks = $change->getHunks();
|
||||||
if ($hunks) {
|
if ($hunks) {
|
||||||
foreach ($hunks as $hunk) {
|
foreach ($hunks as $hunk) {
|
||||||
|
@ -148,6 +149,10 @@ final class DifferentialDiff extends DifferentialDAO {
|
||||||
$changeset->addUnsavedHunk($dhunk);
|
$changeset->addUnsavedHunk($dhunk);
|
||||||
$add_lines += $hunk->getAddLines();
|
$add_lines += $hunk->getAddLines();
|
||||||
$del_lines += $hunk->getDelLines();
|
$del_lines += $hunk->getDelLines();
|
||||||
|
$added_lines = $hunk->getChangedLines('new');
|
||||||
|
if ($added_lines) {
|
||||||
|
$first_line = min($first_line, head_key($added_lines));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$lines += $add_lines + $del_lines;
|
$lines += $add_lines + $del_lines;
|
||||||
} else {
|
} else {
|
||||||
|
@ -155,12 +160,17 @@ final class DifferentialDiff extends DifferentialDAO {
|
||||||
$changeset->attachHunks(array());
|
$changeset->attachHunks(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$metadata = $change->getAllMetadata();
|
||||||
|
if ($first_line != PHP_INT_MAX) {
|
||||||
|
$metadata['line:first'] = $first_line;
|
||||||
|
}
|
||||||
|
|
||||||
$changeset->setOldFile($change->getOldPath());
|
$changeset->setOldFile($change->getOldPath());
|
||||||
$changeset->setFilename($change->getCurrentPath());
|
$changeset->setFilename($change->getCurrentPath());
|
||||||
$changeset->setChangeType($change->getType());
|
$changeset->setChangeType($change->getType());
|
||||||
|
|
||||||
$changeset->setFileType($change->getFileType());
|
$changeset->setFileType($change->getFileType());
|
||||||
$changeset->setMetadata($change->getAllMetadata());
|
$changeset->setMetadata($metadata);
|
||||||
$changeset->setOldProperties($change->getOldProperties());
|
$changeset->setOldProperties($change->getOldProperties());
|
||||||
$changeset->setNewProperties($change->getNewProperties());
|
$changeset->setNewProperties($change->getNewProperties());
|
||||||
$changeset->setAwayPaths($change->getAwayPaths());
|
$changeset->setAwayPaths($change->getAwayPaths());
|
||||||
|
|
|
@ -256,7 +256,8 @@ final class DifferentialChangesetListView extends AphrontView {
|
||||||
$repository = $this->repository;
|
$repository = $this->repository;
|
||||||
if ($repository) {
|
if ($repository) {
|
||||||
$meta['diffusionURI'] = (string)$repository->getDiffusionBrowseURIForPath(
|
$meta['diffusionURI'] = (string)$repository->getDiffusionBrowseURIForPath(
|
||||||
$changeset->getAbsoluteRepositoryPath($repository, $this->diff));
|
$changeset->getAbsoluteRepositoryPath($repository, $this->diff),
|
||||||
|
idx($changeset->getMetadata(), 'line:first'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$change = $changeset->getChangeType();
|
$change = $changeset->getChangeType();
|
||||||
|
@ -283,7 +284,7 @@ final class DifferentialChangesetListView extends AphrontView {
|
||||||
$path = ltrim(
|
$path = ltrim(
|
||||||
$changeset->getAbsoluteRepositoryPath($repository, $this->diff),
|
$changeset->getAbsoluteRepositoryPath($repository, $this->diff),
|
||||||
'/');
|
'/');
|
||||||
$line = 1; // TODO: get first changed line
|
$line = idx($changeset->getMetadata(), 'line:first', 1);
|
||||||
$callsign = $repository->getCallsign();
|
$callsign = $repository->getCallsign();
|
||||||
$editor_link = $user->loadEditorLink($path, $line, $callsign);
|
$editor_link = $user->loadEditorLink($path, $line, $callsign);
|
||||||
if ($editor_link) {
|
if ($editor_link) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDiffusionBrowseURIForPath($path) {
|
public function getDiffusionBrowseURIForPath($path, $line = null) {
|
||||||
$drequest = DiffusionRequest::newFromDictionary(
|
$drequest = DiffusionRequest::newFromDictionary(
|
||||||
array(
|
array(
|
||||||
'repository' => $this,
|
'repository' => $this,
|
||||||
|
@ -70,6 +70,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
||||||
return $drequest->generateURI(
|
return $drequest->generateURI(
|
||||||
array(
|
array(
|
||||||
'action' => 'browse',
|
'action' => 'browse',
|
||||||
|
'line' => $line,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue