Hi, My repository looks like r0-r1-r2-r3, workdir, I want to start again from r1 but still want r2, r3 in my repos, Is there an easy way to do that? I am still using hg version 1.4.3, and I look at the command backout and follow the example in the Mercurial Book, http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html, however, I get different behavior,, that is what I did,
>>hg init testhg >>cd testhg >>echo first change >> a; >>hg add a ; >>hg ci -m "first" >>echo second change >> a; >>hg ci -m "second" >>echo third change >> a; cat a; hg ci -m "third" >>hg backout 1 --merge
instead of geting
>>cat a
first change third change as in the book, I got a conflict =============================== reverting a created new head changeset 3:aa3afab03e79 backs out changeset 1:c3ec16461c36 merging with changeset 3:aa3afab03e79 merging a warning: conflicts during merge. merging a failed! 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C' to abandon =======================================================
Even if merge failed, it changed the content of the file
>>cat a
first change <<<<<<< local second change third change =======
>>>>>>> other
========================================================= If I just want to restart from r1(but still keep r2,r3 in the repos), in this simple case, I can do
>> hg revert -a -r 0 >> hg resolve -a -m >> hg ci -m
However, in the FAQ, "http://mercurial.selenic.com/wiki/FAQ#FAQ.2BAC8-CommonProblems.I_want..." hg revert is not advisable for retrieving old revision. What's the problem? Is what revert does is changing the content of files back to a certain version and the effect is just like manually editing the files? Thanks.
On Tue, Sep 27, 2011 at 06:26:52PM -0500, Shiyuan wrote: > Hi, > My repository looks like r0-r1-r2-r3, workdir, I want to start again > from r1 but still want r2, r3 in my repos, Is there an easy way to do that? > I am still using hg version 1.4.3, and I look at the command backout and > follow the example in the Mercurial Book, > http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html, however, > I get different behavior,, that is what I did,
If I understood what you want to do, you don't really need to back out anything. Backout would work more like an "undo" action (that would be recorded in the repository's history). If you want to create another line of development, you can do so by just updating to the desired revision and commiting your changes like:
$ hg up -r 1 # Make the changes you want to make $ hg commit -m 'decided to start all over again.'
And that's pretty much it. The just commited changeset will become the tip and you can continue development from there.
Your graph history would be something like this now:
$ hg commit a -m 'decided to start all over again.' created new head $ hg glog @ changeset: 3:c68dd6b55cd8 | tag: tip | parent: 1:f6e35b1dcab0 | user: Renato Cunha | date: Tue Sep 27 21:59:37 2011 -0300 | summary: decided to start all over again. | | o changeset: 2:91649f9b434b |/ user: Renato Cunha | date: Tue Sep 27 21:57:56 2011 -0300 | summary: some other stuff | o changeset: 1:f6e35b1dcab0 | user: Renato Cunha | date: Tue Sep 27 21:57:25 2011 -0300 | summary: added some content | o changeset: 0:f60cb12a29d2 user: Renato Cunha date: Tue Sep 27 21:56:55 2011 -0300 summary: created a
If you have ever used subversion, it might be instructing to take a look at Joel's list of conceptual differences between subversion and mercurial at http://hginit.com/00.html.
> However, in the FAQ, > "http://mercurial.selenic.com/wiki/FAQ#FAQ.2BAC8-CommonProblems.I_want..." > hg revert is not advisable for retrieving old revision. What's the > problem? Is what revert does is changing the content of files back to a > certain version and the effect is just like manually editing the files?
That's what the FAQ entry said. If you want to retrieve an old revision, just update to it. "Because revert does not change the working directory parents, this will cause these files to appear modified." (Excerpt from "hg help revert".)
> Hi, > My repository looks like r0-r1-r2-r3, workdir, I want to start > again from r1 but still want r2, r3 in my repos, Is there an easy way to > do that? I am still using hg version 1.4.3, and I look at the command
I think you want:
hg update -r r1 <hack> hg commit
This creates a new changeset on top of r1. The old r2 and r3 stay in the repository, but are no longer used.
Best regards Andreas -- ("`-''-/").___..--''"`-._ `o_ o ) `-. ( ).`-.__.`) (_Y_.)' ._ ) `._ `. ``-..-' _..`--'_..-_/ /--'_.' .' (il).-'' (li).' ((!.-'