I'm trying to dig into fixing some of these mercurial issues (to try and properly work around bundle2 for the time being), and I came across this issue again (T9639).
My set up is
|Server||Mercurial 4.1 (SSH)|
The Mercurial prepushkey hook is failing when pushing a commit which advances a bookmark. This fails when client/server are using bundle2. It appears to be failing due to not recognizing the new commit being added. It's unclear why this seems to be broken only when using bundle2.
This change passes in the HG_PENDING environment variable when running the hg log command so that it can reference the commit being added. Note that this is the same strategy already being used in DiffusionCommitHookEngine.findMercurialChangegroupRefUpdates().