== Steps to Reproduce ==
1. With hosted Mercurial repository, ensure local clone is in matching state (local `master` bookmark points to same changeset upstream)
2. Ensure `master` bookmark is active (`hg up master`)
3. Modify some file, commit
4. Attempt to push the changeset upstream using the SSH protocol
```lang=console,name=ssh-push-exception,counterexample,lines=10
cspeckrun@specktop ~/P/n/hgtest> hg pus
pushing to ssh://phab-devel.code/diffusion/HGTEST/hgtest/
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
remote: [2015-10-26 22:49:01] EXCEPTION: (CommandException) Command failed with error #255!
remote: COMMAND
remote: hg log --template '{node}' --rev 'ancestor('\''e924773ad453bceb5122c5ac67f1fd5859f3e609'\'', '\''fb1da8a86b9ca51cb9f201b52edd0470ee808eda'\'')'
remote:
remote: STDOUT
remote: (empty)
remote:
remote: STDERR
remote: abort: unknown revision 'fb1da8a86b9ca51cb9f201b52edd0470ee808eda'!
remote: at [<phutil>/src/future/exec/ExecFuture.php:416]
remote: arcanist(head=master, ref.master=3308da5f8fbe), phabricator(head=master, ref.master=cea633f698da), phutil(head=master, ref.master=d5b4421792e5)
remote: #0 ExecFuture::resolvex() called at [<phabricator>/src/applications/repository/storage/PhabricatorRepository.php:346]
remote: #1 PhabricatorRepository::execxLocalCommand(string, string, string) called at [<phabricator>/src/applications/diffusion/engine/DiffusionCommitHookEngine.php:968]
remote: #2 DiffusionCommitHookEngine::findMercurialPushKeyRefUpdates() called at [<phabricator>/src/applications/diffusion/engine/DiffusionCommitHookEngine.php:693]
remote: #3 DiffusionCommitHookEngine::findMercurialRefUpdates() called at [<phabricator>/src/applications/diffusion/engine/DiffusionCommitHookEngine.php:222]
remote: #4 DiffusionCommitHookEngine::findRefUpdates() called at [<phabricator>/src/applications/diffusion/engine/DiffusionCommitHookEngine.php:124]
remote: #5 DiffusionCommitHookEngine::execute() called at [<phabricator>/scripts/repository/commit_hook.php:133]
remote: pushkey-abort: prepushkey.phabricator hook exited with status 255
remote: transaction abort!
remote: rollback completed
abort: updating bookmark master failed!
```
According to the output, the two arguments passed into the `ancestor` revset are
1. `e924773ad453bceb5122c5ac67f1fd5859f3e609` is the current `master` upstream, prior to any updates
2. `fb1da8a86b9ca51cb9f201b52edd0470ee808eda` is the new changeset being pushed.
It looks like the `prepushkey` Mercurial hook might be running prior to the commit/changeset being applied, but from what I can tell this execution path is the first thing it does when the hook is executed, and hasn't changed recently.
As a precaution to the recent `bundle2` changes, I tried commenting out these lines (and restarting services) - however that did not seem to affect anything:
https://secure.phabricator.com/diffusion/P/browse/master/src/applications/diffusion/ssh/DiffusionMercurialServeSSHWorkflow.php;cea633f698daad27d5e2b781124198d9f0767878$112-113
|**phabricator**|cea633f698daad27d5e2b781124198d9f0767878|
|**arcanist**|3308da5f8fbe9de8c9c2a25646a5704eca323851|
|**libphutil**|d5b4421792e5829b7a760c55dbf9adbc70669455|
|**server hg**|Mercurial Distributed SCM (version 3.5.1)|
|**client hg**|Mercurial Distributed SCM (version 3.5.2)|
== Workaround ==
1. Align the `master` bookmark with server: `hg book -r xxx master -f`
2. Push outgoing commits: `hg pus`
3. Update `master` to now-public changeset: `hg book -r tip master`
4. Push just the bookmark: `hg pus -r master`
What's weird is that pushing over http seems to work fine:
```lang=console,name=http-push,lines=10
cspeckrun@specktop ~/P/n/hgtest> hg pus http
pushing to http://Administrator:***@192.168.0.133/diffusion/HGTEST/hgtest
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
updating bookmark master
```
== Testing on rHGTEST ==
I could not reproduce this on rHGTEST. When I try to push I get a different error:
```lang=console,name=rHGTEST push exception,counterexample,lines=10
cspeckrun@specktop ~/P/p/hg-test> hg pus
pushing to ssh://dweller@secure.phabricator.com/diffusion/HGTEST/hg-test/
searching for changes
remote: abort: stream ended unexpectedly (got 0 bytes, expected 6)
abort: unexpected response: empty string
```