dummy merge (two branches) for dummies

Becker, Mischa J mischa.becker at kroger.com
Thu Aug 18 22:39:51 UTC 2016


> From: Uwe Brauer
> Subject: Re: dummy merge (two branches) for dummies
>
> > [...]
> > Here you've chosen to keep everything exactly as it was in the 'foo' branch.
> That's want I want
>
> > Here you've chosen to keep everything exactly as it was in the 'uwe' branch.
> That's what matt told me. Maybe I misinterpreted him.

It's probably misunderstandings on both sides.  I couldn't tell from your original email that you were wanting to discard data as part of the merge let alone which side you wanted to discard.

Your original example doesn't show the internal:other stuff that Matt talked about yesterday.  To see those differences use the following test.

 hg init
 hg branch uwe
 echo line-which-is-in-both-files > test.txt
 echo uwe-one > uwe1.txt
 hg add test.txt
 hg add uwe1.txt
 hg commit -m "Uwe one"
 hg branch foo
 echo foo-two > foo.txt
 hg add foo.txt
 hg commit -m "Foo two"
 echo foo-three >> test.txt
 echo foo-three >> foo.txt
 hg commit -m "Foo three"
 hg update uwe
 echo uwe-four >> test.txt
 echo uwe-four > uwe2.txt
 hg add uwe2.txt
 hg commit -m "Uwe four"
 echo uwe-five >> uwe1.txt
 echo uwe-five >> uwe2.txt
 hg commit -m "Uwe five"

The log from above looks like this:
> hg glog
  @  changeset:   4:0fdcfb713bf6
  |  branch:      uwe
  |  summary:     Uwe five
  |
  o  changeset:   3:22f0c42c0367
  |  branch:      uwe
  |  parent:      0:92c9c1732695
  |  summary:     Uwe four
  |
o |  changeset:   2:7e7787a42570
| |  branch:      foo
| |  summary:     Foo three
| |
o |  changeset:   1:74a7050676b2
|/   branch:      foo
|    summary:     Foo two
|
o  changeset:   0:92c9c1732695
   branch:      uwe
   summary:     Uwe one


After that here are three example merges that keep foo changes:

1) hg update uwe
   hg merge foo --tool internal:other
   hg commit -m "Merge foo internal:other"

2) hg update foo
   hg debugsetparents uwe foo
   hg branch uwe
   hg commit -m "Merge using debugsetparents"

3) hg update uwe
   hg merge foo --tool internal:other
   hg revert --all -r foo
   hg commit -m "Merge foo, discard uwe changes"

The results of each merge commit are as follows:

1) Internal:other
    > hg manifest
    foo.txt
    test.txt
    uwe1.txt
    uwe2.txt
    > type test.txt
    line-which-is-in-both-files
    foo-three
    > type uwe1.txt
    uwe-one
    > type uwe2.txt
    uwe-four
    uwe-five

2) Debugsetparents
    > hg manifest
    foo.txt
    test.txt
    uwe1.txt
    uwe2.txt
    > type test.txt
    line-which-is-in-both-files
    foo-three
    > type uwe1.txt
    uwe-one
    uwe-five
    > type uwe2.txt
    uwe-four
    uwe-five

3) Revert to foo, discard uwe
    > hg manifest
    foo.txt
    test.txt
    uwe1.txt
    > type test.txt
    line-which-is-in-both-files
    foo-three
    > type uwe1.txt
    uwe-one

Note: The contents of foo.txt is the same in all examples.

In example 1, uwe changes to all files that foo knows about are discarded but new files uwe adds are kept.  In example 2, uwe changes to files also changed by foo are discarded but all other uwe changes are kept. (See contents of uwe1.txt.)  In example 3, all uwe changes after foo was created are discarded.

I hope this makes things more clear.

Mischa

________________________________

This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is confidential and protected by law from unauthorized disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.


More information about the Mercurial mailing list