Question

In the beginning, my local repo looked like:
C1 -> C2 -> My1
and the remote repository looked like:
C1 -> C2 -> R1 -> R2
So I did:
$ hg pull
$ hg rebase
Now the repo looks like:
C1 -> C2 -> R1 -> R2 -> My1

Now I have made some changes to a file "File1.java" and want these changes to be a part of the last commit My1. When I do a:
$ hg commit File1.java --amend
the error message I get is:
abort: cannot amend merge changesets
On googling I found this, according to which it looks like an issue in mercurial but I am sure there is a way around it.
Please tell me the set of steps to amend the new changes in the last local commit.

Was it helpful?

Solution

It look like My1 is a merge but your diagram does not highlight that at all. Can you check the state of your repo with:

hg log --graph

If My1 is a merge (and you expected it to be merge). Mercurial 2.6 should be able to edit a merge changeset. So if you upgrade to Mercurial 2.6.1 or above your original command will work.

   hg commit --amend  File1.java

OTHER TIPS

Was the My1 changeset a merge changeset before rebasing? rebase does attempt to preserve the number of parents between branches (you can see Section 10 under rebase for more info).

Assuming that you haven't pushed your changeset (i.e. it still has a phase of draft using hg phase) and you are willing to use hg's patch extension mq, you can do it thus:

hg qimport -r tip
hg qrefresh 
hg qfinish -a

This imports the tip changeset into the patch queue and then updates that patch to include the current changes in the working directory. Finally, it moves the (now updated) changeset back into the repo, ready to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top