mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01: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:
parent
0902543fc8
commit
0ecfb75101
1 changed files with 23 additions and 0 deletions
|
@ -16,6 +16,29 @@ final class DiffusionMercurialRequest extends DiffusionRequest {
|
||||||
$this->raiseCloneException();
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue