@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix a commit hook issue with the initial commit to Mercurial repositories

Summary:
Fixes T4257. The `hg heads` command exits with an error code and no output in an empty repository.

Just ignore the error code: we don't have a great way to distinguish between errors, and we ran another `hg` command moments before, so we have at least some confidence it isn't a PATH sort of thing.

Test Plan: Created a new Mercurial repository and pushed to hit the error in T4257. Applied this fix and got a clean push with an accurate push log.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4257

Differential Revision: https://secure.phabricator.com/D7817

+8 -3
+8 -3
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
··· 583 583 // Resolve all of the futures now. We don't need the 'commits' future yet, 584 584 // but it simplifies the logic to just get it out of the way. 585 585 foreach (Futures($futures) as $future) { 586 - $future->resolvex(); 586 + $future->resolve(); 587 587 } 588 588 589 589 list($commit_raw) = $futures['commits']->resolvex(); 590 590 $commit_map = $this->parseMercurialCommits($commit_raw); 591 591 $this->mercurialCommits = $commit_map; 592 592 593 - list($old_raw) = $futures['old']->resolvex(); 593 + // NOTE: `hg heads` exits with an error code and no output if the repository 594 + // has no heads. Most commonly this happens on a new repository. We know 595 + // we can run `hg` successfully since the `hg log` above didn't error, so 596 + // just ignore the error code. 597 + 598 + list($err, $old_raw) = $futures['old']->resolve(); 594 599 $old_refs = $this->parseMercurialHeads($old_raw); 595 600 596 - list($new_raw) = $futures['new']->resolvex(); 601 + list($err, $new_raw) = $futures['new']->resolve(); 597 602 $new_refs = $this->parseMercurialHeads($new_raw); 598 603 599 604 $all_refs = array_keys($old_refs + $new_refs);