hg commit amend creating new branches

500 Views Asked by At

While trying to use the 'hg commit --amend' feature for change the commit message in repo ...

I have created the new branch named as 'hg_amend' and i have commited some changes and pushed to repo. Again i need to do some changes related to that previous commit. So i did some changes & tried to add that files using 'hg add', 'hg commit --amend', 'hg phase --draft --force .' and 'hg push -f'.

After this i checked in bitbucket, the new branch created with same heads.

Advance Thanks !!

enter image description here

enter image description here

1

There are 1 best solutions below

0
On

While there is no actual question in your question, I'll asume those two:

  1. Why are there two heads?

  2. How can change the situation so that there is only one head?

The answer to 1) is simple: You published your changeset. Your bitbucket repository is configured to be a publishing repository (that's default), thus all changesets pushed there become unmutable, thus public phase, both in the bitbucket repo as well as in your local one. You cannot change any changeset which is already pushed to that repository. Using hg push --force only ensured that you actually could push new heads to the repo and that you willingly said 'good bye' to the warning you usually get when trying to push new heads. Using mercurial, a push command is strictly append-only (just unlike git, where it can be a road to lot reconstruction work when forcing the wrong commit).

The answer to 2) is now more difficult and there's several options. Probably easiest is to use the bitbucket interface and strip all changesets which you pushed in your last commit and additionally the one which you tried to amend. Then try the push again. That should fix it for now.

I'm not 100% sure about bitbucket's current capabilities. I heard it (still) does not support exchange of obsolesence markers, thus this situation is very hard to avoid. However it allows to set the repository to non-publishing and it supports phases. Thus if your default phase is draft, too, the phases won't be changed on push. And either you avoid amending changesets which are already pushed. Or you amend and close the now obsolete head with the original changesetID - then it should at least not be shown in bitbucket anymore.