two heads have no common ancestor

Eric Siegerman pub08-hg at davor.org
Fri Jan 31 16:56:44 UTC 2014


On 01/30/2014 03:38 PM, D Wang wrote:
 > I have a repo where the two heads have no common ancestor [...]

Another way to get this is by pulling from an unrelated repository. By 
default, "hg pull" will refuse to do that, but "--force" overrules its 
objection.  Same goes for pushing to an unrelated repo (--new-branch 
still refuses, as it should; you have to use --force).

I've had occasion to do this on purpose, to combine two previously 
independent histories.  "hg pull --force" to get both histories into one 
repo, then merge corresponding heads to get both file trees into one 
changeset.

After "hg pull --force" your history looks like this (I've deleted the 
user: and date: lines for brevity):
     o  changeset:   5:cb6d5b3e1c05
     |  tag:         tip
     |  summary:     A, cadabra
     |
     o  changeset:   4:65a499bbce55
        parent:      -1:000000000000
        summary:     A, abra

     @  changeset:   3:26e5ea35a562
     |  summary:     B, fum
     |
     o  changeset:   2:763db58de35d
     |  summary:     B, foe
     |
     o  changeset:   1:d6d1b5acfc47
     |  summary:     B, fie
     |
     o  changeset:   0:54a4b8e81ca5
        summary:     B, fee


After merging it looks like this:
     @    changeset:   6:5e7cc364ed2c
     |\   tag:         tip
     | |  parent:      3:26e5ea35a562
     | |  parent:      5:cb6d5b3e1c05
     | |  summary:     Merge magics
     | |
     | o  changeset:   5:cb6d5b3e1c05
     | |  summary:     A, cadabra
     | |
     | o  changeset:   4:65a499bbce55
     |    parent:      -1:000000000000
     |    summary:     A, abra
     |
     o  changeset:   3:26e5ea35a562
     |  summary:     B, fum
     |
     o  changeset:   2:763db58de35d
     |  summary:     B, foe
     |
     o  changeset:   1:d6d1b5acfc47
     |  summary:     B, fie
     |
     o  changeset:   0:54a4b8e81ca5
        summary:     B, fee


   - Eric




More information about the Mercurial mailing list