Unable to merge in mercurial
Solution 1
Your local clone of the repo is probably not up-to-date. Do a
hg pull
to change that. Now you have two heads locally (your own previous tip and the tip of the bitbucket repo). Now
hg merge
to merge the two heads and
hg commit -m "Merged before pushing"
Now your local repo has only one head, and this head is a child of the bitbucket head, so pushing will not create a remote head anymore:
hg push
and you're done.
Solution 2
Before you push code to a remote repository, first ensure your local repo is clean and has no outstanding merges.
Then, do a hg pull from the remote repository. This will create 2 heads on your local repository.
Do a local merge, and commit (resolving any conflicts).
Finally, push to the remote repository.
Do not, in general, push to a remote repository if multiple heads will be created there.
Solution 3
You might not want to commit the merge even locally. The way to clean out and start over again (from https://www.mercurial-scm.org/bts/issue1533) seems to be "hg update -C ".
As alluded to above, it seems as if "hg revert -a" ought to work, but doesn't seem to.
Comments
-
peter.murray.rust about 4 years
I am a newcomer to mercurial. I have recently set up a repository with 2 colleagues and am having difficulty with pushing my code. [I am using command-line hg in Windows]. In particular when I push I get a dialogue like the following:
>hg commit -u petermr >hg push pushing to http://bitbucket.org/petermr/polyinfo/ searching for changes abort: push creates new remote heads! (did you forget to merge? use push -f to force) >hg merge abort: there is nothing to merge >hg status
I am afraid to commit using push -f as I think that will create multiple heads and cause problems for our group.
When I try to merge I get a dialogue something like:
>hg merge -f merging src/test/resources/PMR/algorithm/cmlAll.xml output file src/test/resources/PMR/algorithm/cmlAll.xml appears unchanged was merge successful (yn)? y merging src/test/resources/PMR/irregular/cmlAll.xml output file src/test/resources/PMR/irregular/cmlAll.xml appears unchanged was merge successful (yn)? y merging src/test/resources/PMR/massChange/cmlAll.xml output file src/test/resources/PMR/massChange/cmlAll.xml appears unchanged was merge successful (yn)? y
Since there are several hundred files I cannot type "y" for each and I can't find a way of merging them all together.
UPDATE I have tried the first (2) answers and still have a problem:
>hg pull pulling from http://bitbucket.org/petermr/polyinfo/ searching for changes no changes found >hg merge abort: outstanding uncommitted merges
UPDATE in response to @tonfa I cannot commit:
>hg commit abort: unresolved merge conflicts (see hg resolve)
UPDATE @balpha (I have changed the name of the owner to Foo)
>hg parent changeset: 24:9ec904d2d5a2 tag: tip user: petermr date: Sat Jan 09 16:40:38 2010 +0000 summary: trying to sync changeset: 22:360aedb72f0e parent: 21:89c4bd671bd3 parent: 18:3cffa8ca3a2a user: Foo (not me) date: Fri Jan 08 16:15:50 2010 +0000 summary: merged >hg tip changeset: 24:9ec904d2d5a2 tag: tip user: petermr date: Sat Jan 09 16:40:38 2010 +0000 summary: trying to sync
UPDATE
hg heads
changeset: 24:9ec904d2d5a2 tag: tip user: petermr date: Sat Jan 09 16:40:38 2010 +0000 summary: trying to sync changeset: 22:360aedb72f0e parent: 21:89c4bd671bd3 parent: 18:3cffa8ca3a2a user: Foo (not me) date: Fri Jan 08 16:15:50 2010 +0000 summary: merged
UPDATE following @balpha comments below who suggests revert which asks for a revison (is this a number? If so how do I find it?)
>hg revert --all abort: uncommitted merge - please provide a specific revision
UPDATE still cannot merge...
>hg revert --all -r tip reverting .hgignore reverting .hgignore~ reverting src\test\java\org\xmlcml\cml\converters\polyinfo\RegressionTest.java reverting src\test\resources\PMR\algorithm\cmlAll.xml reverting src\test\resources\PMR\irregular\cmlAll.xml reverting src\test\resources\PMR\massChange\cmlAll.xml reverting src\test\resources\PMR\massChangeOk\cmlAll.xml reverting src\test\resources\PMR\ok\P340076.both.svg reverting src\test\resources\PMR\ok\P340076.p.svg reverting src\test\resources\PMR\ok\P340076.r.svg reverting src\test\resources\PMR\ratio\cmlAll.xml >hg status M .hgignore M .hgignore~ M src\test\resources\PMR\algorithm\cmlAll.xml M src\test\resources\PMR\irregular\cmlAll.xml M src\test\resources\PMR\massChange\cmlAll.xml M src\test\resources\PMR\massChangeOk\cmlAll.xml M src\test\resources\PMR\ok\P340076.both.svg M src\test\resources\PMR\ok\P340076.p.svg M src\test\resources\PMR\ok\P340076.r.svg M src\test\resources\PMR\ratio\cmlAll.xml ? src\test\resources\PMR\bug\P020006work.both.svg ? src\test\resources\PMR\irregular\cmlAll.xml.resolve >hg merge abort: outstanding uncommitted merges >hg commit abort: unresolved merge conflicts (see hg resolve)
Note that
hg resolve -all
brings up the original problem of having to answer "y" to hundreds of individual questions and I don't know then whether it will resolve the problem. Your help is much appreciated!
UPDATE @balpha suggested cleaning - this seems to have made progress
>hg update --clean -r tip 10 files updated, 0 files merged, 0 files removed, 0 files unresolved >hg merge merging src/test/resources/PMR/algorithm/cmlAll.xml output file src/test/resources/PMR/algorithm/cmlAll.xml appears unchanged was merge successful (yn)? y merging src/test/resources/PMR/irregular/cmlAll.xml output file src/test/resources/PMR/irregular/cmlAll.xml appears unchanged was merge successful (yn)? y merging src/test/resources/PMR/massChange/cmlAll.xml output file src/test/resources/PMR/massChange/cmlAll.xml appears unchanged was merge successful (yn)? y merging src/test/resources/PMR/massChangeOk/cmlAll.xml output file src/test/resources/PMR/massChangeOk/cmlAll.xml appears unchanged was merge successful (yn)? y merging src/test/resources/PMR/ok/P340076.both.svg output file src/test/resources/PMR/ok/P340076.both.svg appears unchanged was merge successful (yn)? y merging src/test/resources/PMR/ok/P340076.p.svg output file src/test/resources/PMR/ok/P340076.p.svg appears unchanged was merge successful (yn)? y merging src/test/resources/PMR/ok/P340076.r.svg output file src/test/resources/PMR/ok/P340076.r.svg appears unchanged was merge successful (yn)? y merging src/test/resources/PMR/ratio/cmlAll.xml output file src/test/resources/PMR/ratio/cmlAll.xml appears unchanged was merge successful (yn)? y 2 files updated, 8 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) >hg merge abort: outstanding uncommitted merges >hg merge -f abort: outstanding uncommitted merges >hg commit -u petermr -m "still trying to sy nc" >hg merge abort: there is nothing to merge >hg push pushing to http://bitbucket.org/petermr/polyinfo/ searching for changes http authorization required realm: Bitbucket.org HTTP user: petermr password: adding changesets adding manifests adding file changes added 4 changesets with 298 changes to 290 files bb/acl: petermr is allowed. accepted payload. quota: 13.3 MB in use, 150.0 MB available (8.87% used)
-
peter.murray.rust over 14 yearsThis doesn't seem to allow me a merge - see UPDATE
-
peter.murray.rust over 14 yearsAccepted answer, but see discussion on the question for details
-
balpha over 14 years+1 because the "repo must be clean" part was the crucial thing in this case
-
MikeSchinkel over 12 years@Tarydon: "First ensure your local repo is clean and has no outstanding merges." Can you explain how to do that?
-
davetapley over 12 yearsI had exactly the problem described atop the original question, and found that copying all my changed files out,
hg update -C
, and then copying back changes worked for me.