Cannot update pull request with replaced commit in hg (BB-7006)

Issue #5737 resolved
Christian Walther
created an issue

When I make a pull request, an issue is found with it that I need to fix before it can be merged, and I fix the issue by amending a commit of the pull request (rather than adding another commit on top), then I am unable to update the pull request to include the new commit.

Steps to reproduce:

  1. Create repository “prupdate” on Bitbucket
  2. Populate it:

    ~$ hg init prupdate
    ~$ cd prupdate
    ~/prupdate$ echo "Hello" > hello.txt
    ~/prupdate$ hg add hello.txt
    ~/prupdate$ hg ci -m "Initial"
    ~/prupdate$ hg push https://cwalther@bitbucket.org/cwalther/prupdate
    
  3. Fork prupdate as “prupdatefork” on Bitbucket

  4. Create a flawed feature branch:

    ~/prupdate$ echo "Hello Wold" > hello.txt
    ~/prupdate$ hg branch feature
    ~/prupdate$ hg ci -m "Greet the world"
    ~/prupdate$ hg push --new-branch -r 1 https://cwalther@bitbucket.org/cwalther/prupdatefork
    
  5. Create a pull request asking to merge prupdatefork:feature into prupdate:default

  6. Fix the typo discovered in the pull request review by creating an amended version of the flawed commit:

    ~/prupdate$ hg up 0
    ~/prupdate$ echo "Hello World" > hello.txt
    ~/prupdate$ hg branch --force feature
    ~/prupdate$ hg ci -m "Greet the world"
    ~/prupdate$ hg push --force -r 2 https://cwalther@bitbucket.org/cwalther/prupdatefork
    
  7. Strip the replaced revision 1 from Bitbucket

  8. Attempt to edit the pull request to switch it from the flawed to the fixed revision

Expected result:

There should be an “Edit” button on the pull request page.

Actual result:

There is no “Edit” button, the pull request cannot be updated.

Second try:

1. – 6. as above

7. Do not strip the superseded revision, but leave it on Bitbucket (branch “feature” has two heads now)

8. Push the “Edit” button on the pull request page (which is still there this time, good)

9. Open the source branch popup to attempt to switch from the flawed to the fixed head

Expected result:

There should be two entries for the two heads of branch “feature” in the popup.

Actual result:

There is only one “feature” entry, and it seems to still refer to the old head, as when I choose it and save the pull request, nothing happens.

Comments (9)

  1. Maël Valais

    What do you mean by automatic? In my case, pushing the new head does not update the PR. This happens when forking a repo. I tried the evolve feature but it seems to randomly choose the next head it is going to update to. Being able to update manually the head would still help.

  2. Maël Valais

    Hi @Sean Farley,

    I am using bookmarks on 'default' (coming from git, it seemed to be appropriate).

    I pushed commits that I had 'evolved' using histedit (using the extension 'evolve'). I was expecting the Bitbucket PR to follow to the new head (although I did not create a new head thanks to the 'evolve' extension. I did not use hg push -f, just hg push.

    Instead, Bitbucket picked one of the other heads in order to update... I guess this is because I had like 6 heads on 'default' (I had been fiddling with hg push -f before knowing the existence of the evolve extension.

    So if I was to retry this, I would make sure I do not have multiple heads. But how are you supposed to have bookmarks if you don't have multiple heads?

    Conclusion: I would rather use 'fix commits' instead trying to mutate commits. As very well described by Martin Geisler, it is the way to fix things in a PR with mercurial.

  3. Sean Farley staff

    I guess this is because I had like 6 heads on 'default'

    Yes, you are correct (it chose the latest pushed one).

    I had been fiddling with hg push -f before knowing the existence of the evolve extension

    In general (with evolve enabled), -f should never be used.

    But how are you supposed to have bookmarks if you don't have multiple heads?

    Bookmarks are a horrible, shoe-horned idea that has never worked quite right. Use branch names instead.

  4. Log in to comment