TortoiseHG: cannot partially commit a merge
Asked Answered
B

6

11

I tried to merge two heads in Mercurial. After merging, I didn't commit and did some more changes. Then I tried to commit and got the following message:

abort: cannot partially commit a merge (do not specify files or patterns)

I'm using TortoiseHG as visual shell, and Beyond Compare for comparing and merging. And I'm relatively new to all of them.

What should I do to finish commit successfully?

Benthos answered 29/7, 2010 at 15:13 Comment(6)
did you use the command line 'hg commit' command to commit your changes - or the TortoiseHG GUI?Guacin
I've googled before posting this question, and found these two links: earthli.com/news/view_article.php?id=2360 and mercurial.selenic.com/bts/issue1226. They are relevant, but I didn't find any useful information there.Benthos
@dls: I used GUI. Switching to command line solved the issue! Could you post this as answer? Thanks :)Benthos
good, i'm glad the CLI helped. It could have been that using the GUI caused you to try to edit or commit something other than your final merged result...Guacin
encountered same error. command line worked for me as well. Thanks!Khorma
Have same error NOT specifying any filesAnaclinal
G
3

What should I do to finish commit successfully?

One of the benefits of Mercurial (or git or any other DVCS) is that you can perform a commit at any point in your development process and it will be both fast and private. It will be fast because you should be committing to a local copy of the repository residing on your hard drive, and it will be private because no-one will see your change set until you push them to the server (or other master repository).

Therefore, to partially answer your question, the appropriate thing to do would have been to commit the merge without your addition changes, and then apply and commit your next wave of changes. If you are using TortoiseHG to peform the merge it will actually prompt you to commit the merge before leaving the GUI because this is the intended HG workflow.

That being said, I made some changes on a named branch (ie: new head), merged it back into the default branch, exited the TortoiseHG GUI without committing, made some more changes, and then committed with no problem. I will ask some clarifying questions below your original inquiry.

Guacin answered 29/7, 2010 at 15:31 Comment(2)
Your comment for using command line (CLI) to commit solved the issue. Usually I try to commit via CLI when I have problems with TortoiseHG, but this time I was so worried about the problem, that I forgot to do this :).Benthos
if someone is lookign at these old threads, Mercurial is buggy as hell. netbeans.org/bugzilla/show_bug.cgi?id=132984, bitbucket.org/jfh/machg/issue/240/fails-to-commit-after-merge stay away from it. A ton of unresolved serious issues, that hit right from the beginningMilano
M
13

Mercurial/TortoiseHg is correct in telling you that you should not partially commit a merge. Partial means that you do not commit all files at once.

The underlying reason for this message is that is gives you the wrong results. When you merge two changesets in Mercurial, you are creating a new changeset with two parent changesets. This merge changeset shows others how you want everybody else to combine the two changesets.

Let us imagine that you start with changesets A and B and want to merge them. This creates a graph like this:

... --- [A]
           \
            [M]
           /
... --- [B]

Pretend that we added the line A! to a.txt in the A changeset and that we added B! to b.txt in the B changeset. Just two independent changes that does not conflict. If Mercurial allowed you to do a partial commit, then you could do this:

hg merge
hg commit -m 'Added A!' a.txt  # creates M
hg commit -m 'Added B!' b.txt  # creates M'

and the result is this graph:

... --- [A]
           \
            [M] --- [M']
           /
... --- [B]

If you look at b.txt along the path B, M, M', then you will see that the line with B! was introduced in B, removed in M and reintroduced in M'!

This is not what you want from a merge changeset: a partial merge throws away changes from one branch just to introduce them again in a followup commit. Mercurial trusts you when you create M: it really believes that M contains the correct mix of A and B. In particular, if the B! line is removed in M, then it will remain gone when you merge M with other changesets.

So Mercurial is trying to protect you from creating a bad history by not allowing partial merges.

Masha answered 12/8, 2010 at 12:1 Comment(0)
D
7

I think you have aliases in hgrc file. Try to remove [alias] section and commit again.

Discoloration answered 24/8, 2011 at 7:46 Comment(3)
I don't think this answer's Roman's question, but it was very helpful to me. In my .hgrc in the [default] section I had: "commit = -X index.php". HG wasn't smart enough to figure out that the merge didn't involve index.php. And yes, I know it's very kludgy even having that line... ;)Sokotra
this was it for me, thanks @Discoloration and fazy. It drove me nuts for a while.Ewell
Also [default] section can contain command aliases ;) Well seen @kbh, that's a common problem an difficult to guess if you don't remember you changed your Mercurial settings or if you are working in another machine who is not yours.Knowledge
G
3

What should I do to finish commit successfully?

One of the benefits of Mercurial (or git or any other DVCS) is that you can perform a commit at any point in your development process and it will be both fast and private. It will be fast because you should be committing to a local copy of the repository residing on your hard drive, and it will be private because no-one will see your change set until you push them to the server (or other master repository).

Therefore, to partially answer your question, the appropriate thing to do would have been to commit the merge without your addition changes, and then apply and commit your next wave of changes. If you are using TortoiseHG to peform the merge it will actually prompt you to commit the merge before leaving the GUI because this is the intended HG workflow.

That being said, I made some changes on a named branch (ie: new head), merged it back into the default branch, exited the TortoiseHG GUI without committing, made some more changes, and then committed with no problem. I will ask some clarifying questions below your original inquiry.

Guacin answered 29/7, 2010 at 15:31 Comment(2)
Your comment for using command line (CLI) to commit solved the issue. Usually I try to commit via CLI when I have problems with TortoiseHG, but this time I was so worried about the problem, that I forgot to do this :).Benthos
if someone is lookign at these old threads, Mercurial is buggy as hell. netbeans.org/bugzilla/show_bug.cgi?id=132984, bitbucket.org/jfh/machg/issue/240/fails-to-commit-after-merge stay away from it. A ton of unresolved serious issues, that hit right from the beginningMilano
H
1

I had this problem because I had deleted some files. I reverted the files to restore them, then was able to commit. I then deleted the files and did a second commit.

Hearsh answered 23/10, 2015 at 8:32 Comment(0)
A
0

I had the same problem and I was NOT specifying any files and using command-line.

The problem was the [default] section in my .hgrc

[defaults]
commit = -X project/web.config

So it added specific files to every commit-operation by default.

Review your defaults section for potential problems.

Anaclinal answered 5/9, 2014 at 10:52 Comment(0)
L
0

I had the same problem and the command I gave was

hg commit -m Merge with 1234

I figured it out after sometime that the commit message "Merge with 1234" has to be given in quotes as the command takes "with" and "1234" as file name params.

please check it in your case.

Lupine answered 15/11, 2018 at 10:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.