Reproducible steps:
- Disallow dangerous changes
- Using mercurial push a set of commits that updates multiple branches at the same time
Expected result:
- The commits get pushed since the change-set doesn't try to create multiple heads on the same branch
Actual result:
- The commits get rejected with
DANGEROUS CHANGE: The change you're attempting to push creates new, divergent heads for the branch 'ADC_float': 25ce5a013456. This is inadvisable and dangerous.
I've done the triage of the issue and I've found that is due to an uninitialized variable in src/applications/diffusion/engine/DiffusionCommitHookEngine.php.
At line 827 and 829 the variable head_map is augmented with a new key-value pair but the container has not been cleared; therefore the map accumulates items at every iteration of the loop, since at line 849 count($head_map) is used to detect the error condition that condition can be spuriously triggered if the pushed change-set involved multiple branches.
The fix consists in clearing the variable at every iteration like its already done in the other branches of the if .. else chain.
The proposed solution is attached as a patch.
Version information:
phabricator fd72a2ff810144a80e396e8d68b41f07234e404a (Sat, Mar 12)
arcanist bb276740e7a87d7af52f9e9295cebf842c247425 (Sat, Mar 12)
phutil 89c7c2072813fd15bc66be8f7acbf2f8bc7e9bb6 (Sat, Mar 12)