Skip to content

Commit 0ecfb75

Browse files
author
epriestley
committed
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
1 parent 0902543 commit 0ecfb75

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/applications/diffusion/request/DiffusionMercurialRequest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@ protected function didInitialize() {
1616
$this->raiseCloneException();
1717
}
1818

19+
// Expand abbreviated hashes to full hashes so "/rXnnnn" (i.e., fewer than
20+
// 40 characters) works correctly.
21+
if (!$this->commit) {
22+
return;
23+
}
24+
25+
if (strlen($this->commit) == 40) {
26+
return;
27+
}
28+
29+
list($full_hash) = $this->repository->execxLocalCommand(
30+
'log --template=%s --rev %s',
31+
'{node}',
32+
$this->commit);
33+
34+
$full_hash = explode("\n", trim($full_hash));
35+
36+
// TODO: Show "multiple matching commits" if count is larger than 1. For
37+
// now, pick the first one.
38+
39+
$this->commit = head($full_hash);
40+
41+
1942
return;
2043
}
2144

0 commit comments

Comments
 (0)