1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Expand abbreviated Mercurial hashes to full hashes

Summary:
If you go to `/rXnnnn` in Git, we expand the hash. If you go to `/rXnnnn` in Mercurial, we give you a confusing error message.

Reconcile Mercurial behavior with Git. Fixes T2265.

Test Plan: Viewed partial hash, full hash commit in Diffusion. Viewed very short hash, got reasonable behaviors.

Reviewers: btrahan, tido

Reviewed By: tido

CC: aran

Maniphest Tasks: T2265

Differential Revision: https://secure.phabricator.com/D4330
This commit is contained in:
epriestley 2013-01-03 06:01:53 -08:00
parent 0902543fc8
commit 0ecfb75101

View file

@ -16,6 +16,29 @@ final class DiffusionMercurialRequest extends DiffusionRequest {
$this->raiseCloneException();
}
// Expand abbreviated hashes to full hashes so "/rXnnnn" (i.e., fewer than
// 40 characters) works correctly.
if (!$this->commit) {
return;
}
if (strlen($this->commit) == 40) {
return;
}
list($full_hash) = $this->repository->execxLocalCommand(
'log --template=%s --rev %s',
'{node}',
$this->commit);
$full_hash = explode("\n", trim($full_hash));
// TODO: Show "multiple matching commits" if count is larger than 1. For
// now, pick the first one.
$this->commit = head($full_hash);
return;
}