Skip to content

Regression 0.10.x -> 1.0.x: "merging" a GitHub PR using the "rebase" workflow and then deleting the PR's branch causes the deleted commits to reappear

Hg-git v1.0.x introduces a regression when interfacing with github PRs using a "rebase" workflow. The problem does not happen in v0.10.x. I was not able to replicate the problem using a local git repo (sorry), but my git fluency is also very scant.

Procedure (no scripted, local-only version for now, sorry):

  • clone a project on github (it must be a project for which you are able to merge PRs) hg clone git+https://github.com/user/reponame

  • do some changes locally, commit them to a new mercurial bookmark (let's say "pr1"), and push it. It will be pushed to the git branch "pr1" as expected.

    echo "something" > somefile
    hg bookmark pr1
    hg add somefile
    hg commit somefile -m "new feature"
    hg push
  • open a PR for that branch: https://github.com/user/reponame/pull/new/pr1

  • in github, merge the PR choosing "Rebase and merge": the changes in the PR will be copied on top of the master branch. I do not know exactly what GitHub does here, so I was not able to replicate it on local git repositories

  • delete the pr1 branch on github

  • go back to the mercurial repo and pull: hg pull. On top of the main bookmark a new commit "new feature" will appear. The main bookmark will be moved there. This is correct

  • update to the new main head, for example with hg up -r main

Behaviour with hg-git 1.0.x

  • hg-git will see that the remote pr1 branch was deleted in github and will remove the pr1 bookmark. Nice & Correct.
  • the mercurial commit will obviously not be deleted: strip it via hg strip and clean the hg-git commit map via hg git-cleanup
  • perform an hg pull
  • the stripped commit will reappear. This is not correct

Behaviour with hg-git 0.10.x

  • hg-git will not delete the remotely deleted branch: manually remove the pr1 bookmark
  • strip the removed commit via hg strip and clean the hg-git commit map via hg git-cleanup
  • perform an hg pull
  • no commit will reappear. This is correct.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information