diff --git a/src/applications/diffusion/request/DiffusionMercurialRequest.php b/src/applications/diffusion/request/DiffusionMercurialRequest.php index 18c7d66b10..891b534a8b 100644 --- a/src/applications/diffusion/request/DiffusionMercurialRequest.php +++ b/src/applications/diffusion/request/DiffusionMercurialRequest.php @@ -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; }