From 66af361f10d870fdff8b53caa8e29e7fa425e976 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 3 Jun 2014 17:07:49 -0700 Subject: [PATCH] Fix a Mercurial issue where split heads would be detected incorrectly Summary: Ref T5197. When searching for split branch heads, we incorrectly consider descendant heads of other branches. This can cause us to detect a split tip when one does not exist (the old tip is the branch tip, but other descendant heads exist). Instead, consider only heads on the same branch. Test Plan: Repro is something like this: - `hg update default` - `hg branch branch1; hg commit ...` - `hg push` - `hg update default; hg commit ...` - `hg push` - Previously, we would find the head of `branch1` and incorrectly account for it as a head of `default`. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5197 Differential Revision: https://secure.phabricator.com/D9308 --- .../diffusion/engine/DiffusionCommitHookEngine.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php index d8c8f79a11..1845f6e2f3 100644 --- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php +++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php @@ -760,10 +760,15 @@ final class DiffusionCommitHookEngine extends Phobject { // repository that's already full of garbage (strongly discouraged but // not as inherently dangerous). These cases should be very uncommon. + // NOTE: We're only looking for heads on the same branch. The old + // tip of the branch may be the branchpoint for other branches, but that + // is OK. + $dfutures = array(); foreach ($old_heads as $old_head) { $dfutures[$old_head] = $repository->getLocalCommandFuture( - 'log --rev %s --template %s', + 'log --branch %s --rev %s --template %s', + $ref, hgsprintf('(descendants(%s) and head())', $old_head), '{node}\1'); }