The difference between update and merge
Martin Geisler
mg at lazybytes.net
Tue Dec 6 22:07:34 UTC 2011
Isaac Jurado <diptongo at gmail.com> writes:
> On Tue, Dec 6, 2011 at 10:53 AM, Martin Geisler <mg at aragost.com> wrote:
>>
>>> Unless there is something I don't know about, updating a dirty
>>> working copy is only one way.
>>
>> You can use 'hg resolve' after the update to re-do the merge and even
>> resurrect the old version of your modified files.
>>
>> I haven't tested this right now, but I would expect
>>
>> hg resolve --all --tool internal:local
>> hg update OLDREV
>>
>> to get you safely back to where you were before you ran 'hg update
>> NEW'. Please let us know if you test this.
>
> Well, either one of us is not understanding the other or I wasn't clear
> enough from the beginning. Take the following command sequence:
>
> hg init killme
> cd killme
> cat >afile <<KAN
> asdf asdf asdf asdf asdf a
> asdf asdf asdf asdf
> poiua pioaiusdf puasf -lqwer
> qer -.qmwe-.q,mweer m
> qwer-,m qwew-r.,m
> KAN
> hg add afile
> hg commit -m "A"
> sed '2 c jjjjjjjjjjjjjjjjjjjjj' afile >bfile
> mv bfile afile
> hg commit -m "AA"
> hg update 0
> sed '2 c kkkkkkkkkkkkkkkkkkkkkkkk' afile >bfile
> cp bfile afile
> hg update
>
> After the last command the merge tool should be launched. Now, for the
> sake of the exercise, screw it up by just editing the conflicting line
> manually (in kdiff3, by writing something like "foobar" after selecting
> between local, base and other).
>
> And now, imagining that bfile does not exist, tell me how would you
> recover afile to have the same contents as bfile.
It was a little more complicated than I remembered -- you have to first
mark the file as unresolved before 'hg resolve --tool internal:local'
has any effect. So
hg resolve --unmark afile
hg resolve --tool internal:local afile
brings back the original diff. Updating back to the OLD revision
triggers another merge conflict, but this time picking the local version
in the merge tool is the right thing to do:
HGMERGE=internal:local hg update 0
So it's definitely not something to play around with on your first try
with Mercurial, but we do have remarkably good support for preserving
changes in a dirty working copy.
--
Martin Geisler
Mercurial links: http://mercurial.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20111206/f3566ace/attachment.asc>
More information about the Mercurial
mailing list