hg 0.9.3: pull, revert to pre-merged version, pull expected behavior?

Shane Holloway shane.holloway at ieee.org
Thu Apr 26 10:26:36 CDT 2007


On Apr 25, 2007, at 10:58 PM, Allan Wind wrote:

> I was trying this variation of the merge tutorial
> (http://www.selenic.com/mercurial/wiki/index.cgi/TutorialConflict):

Okay, I'm attempting to track your progress through the tutorial.   
I'm assuming that the repo you are in is the my-hello-not-cvs part of  
the tutorial as a clone of http://www.selenic.com/repo/hello

My I added the 'printf("sure am glad I'm not using CVS!\n");' and  
committed.  My hg log looks like so:

changeset:   2:127bff2d471f
tag:         tip
user:        "Shane Holloway <shane.holloway at ieee.org>"
date:        Thu Apr 26 08:49:17 2007 -0600
summary:     Give thanks for dodging bullet

changeset:   1:82e55d328c8c
user:        mpm at selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

changeset:   0:0a04b987be5a
user:        mpm at selenic.com
date:        Fri Aug 26 01:20:50 2005 -0700
summary:     Create a standard "hello, world" program


I also replicated my-hello-new-output repository from that tutorial.   
It's hg log looks like so:

changeset:   2:ffd77fa2c410
tag:         tip
user:        "Shane Holloway <shane.holloway at ieee.org>"
date:        Thu Apr 26 08:45:08 2007 -0600
summary:     Express great joy at existence of Mercurial

changeset:   1:82e55d328c8c
user:        mpm at selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

changeset:   0:0a04b987be5a
user:        mpm at selenic.com
date:        Fri Aug 26 01:20:50 2005 -0700
summary:     Create a standard "hello, world" program


Notice that the first two changesets are identical.  Now let's  
continue into your message from the repository of my-hello-not-cvs.  :)

> $ hg pull ../my-hello-new-output

Ok, after the pull, I get the important message "added 1 changesets  
with 1 changes to 1 files (+1 heads)".  My hg log now looks like so:

changeset:   3:ffd77fa2c410
tag:         tip
parent:      1:82e55d328c8c
user:        "Shane Holloway <shane.holloway at ieee.org>"
date:        Thu Apr 26 08:45:08 2007 -0600
summary:     Express great joy at existence of Mercurial

changeset:   2:127bff2d471f
user:        "Shane Holloway <shane.holloway at ieee.org>"
date:        Thu Apr 26 08:49:17 2007 -0600
summary:     Give thanks for dodging bullet

changeset:   1:82e55d328c8c
user:        mpm at selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

changeset:   0:0a04b987be5a
user:        mpm at selenic.com
date:        Fri Aug 26 01:20:50 2005 -0700
summary:     Create a standard "hello, world" program


Notice the new changeset #3: ffd77fa2c410 -- it is the same changeset  
from the ../my-hello-new-output repository we just pulled from.  The  
hash id is the changeset identifier.  The number '3' is a number for  
convenience.  It has no meaning outside of this repository, and is  
simply a number reflecting the order it was pulled into this  
repository.  So now we have the head changesets from both  
repositories, and thus have +1 heads.  If we run hg heads:

changeset:   3:ffd77fa2c410
tag:         tip
parent:      1:82e55d328c8c
user:        "Shane Holloway <shane.holloway at ieee.org>"
date:        Thu Apr 26 08:45:08 2007 -0600
summary:     Express great joy at existence of Mercurial

changeset:   2:127bff2d471f
user:        "Shane Holloway <shane.holloway at ieee.org>"
date:        Thu Apr 26 08:49:17 2007 -0600
summary:     Give thanks for dodging bullet


And hg id reports that we are currently updated to changeset  
127bff2d471f


> $ hg update

When I run this command, I get the message "abort: update spans  
branches, use 'hg merge' or 'hg update -C' to lose changes".  I can  
merge from either this head or the other head.  Assuming you did "hg  
update -C" after  the error message, my hg id now reports  
"ffd77fa2c410 tip"

> $ hg merge

Whiz-bang file-merge tool appears, I choose my modifications.  My hg  
id now reports:

"ffd77fa2c410+127bff2d471f+ tip"

Signaling that it is a merge of those two heads, and modified.

> The merge, strangely, cause revision 3, and the commit revision 4.
>
> $ hg commit -m 'merged stuff'

I now have a new hg head:

changeset:   4:bb5551e150d0
tag:         tip
parent:      3:ffd77fa2c410
parent:      2:127bff2d471f
user:        "Shane Holloway <shane.holloway at ieee.org>"
date:        Thu Apr 26 09:11:33 2007 -0600
summary:     Merged stuff





> Anyways, now I want to revert to the pre-merge version (2):

I'm guessing you don't actually want to revert, which means to create  
a changeset that reverses the change of that version, and then merge  
it into the current head.  What I think you want to do is try the  
operation again.  You cannot do that from this repository because it  
already contains the changesets recording the merge and the pull.   
Mercurial is very conservative about not loosing changesets.  What  
you need to do is to hg clone again to start clean.

$ cd ..
$ hg clone -r 2 my-hello-not-cvs 2nd-hello-not-cvs
$ cd 2nd-hello-not-cvs
$ hg log

changeset:   2:127bff2d471f
tag:         tip
user:        "Shane Holloway <shane.holloway at ieee.org>"
date:        Thu Apr 26 08:49:17 2007 -0600
summary:     Give thanks for dodging bullet

changeset:   1:82e55d328c8c
user:        mpm at selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

changeset:   0:0a04b987be5a
user:        mpm at selenic.com
date:        Fri Aug 26 01:20:50 2005 -0700
summary:     Create a standard "hello, world" program



Now you can see that you are back to were you started, before the  
merge, and you can play with it some more.


> If I try to pull it in again I get a different behavior than the first
> time around:
>
> $ hg pull ../my-hello-new-output
> pulling from ../my-hello-new-output
> searching for changes
> no changes found

That is expected.  You are pulling again from the same (unchanged)  
repository.  You current repository contains all the changes from my- 
hello-new-output, a merged changeset 4: bb5551e150d0, and a revert  
changeset to reverse the merge changeset.  Since it contains all of  
these, there are now new changesets to be pulled.  The repository has  
it recorded that they are already integrated.


I hope this helps you out Allan!  It can be a bit confusing, but I've  
found the system very reliable, and pretty understandable once I  
broke myself of thinking of things in terms of SourceSafe, CVS, or  
Subversion... ;)  It was hard, but we have been using it very  
successfully at my company.

-Shane Holloway



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial/attachments/20070426/151a88ea/attachment-0001.htm 


More information about the Mercurial mailing list