dummy merge (two branches) for dummies

Becker, Mischa J mischa.becker at kroger.com
Fri Aug 19 17:54:28 UTC 2016


From: Uwe Brauer
Subject: Re: dummy merge (two branches) for dummies
>
>  > On Fri, Aug 19, 2016 at 1:39 PM, Uwe Brauer <oub at mat.ucm.es> wrote:
>
>  > I think I'm missing something here. Why do you want a dummy merge
>  > (rather than a normal merge) at all? Why are you regularly merging
>  > with a co-author but throwing away his changes? (Or is it *your*
>  > changes you are throwing away?)
>
> The workflow is like this:
>
> The principial file is main.tex which lives on two branches, mine and the
> coauthors one.
>
> I edit main.tex, commit in my branch. Then I send that file to him, (he gave up
> using mercurial for the moment.)
>
>So I start working on other files, I create and delete on my branch. At some
> point the file main.tex file arrives, now with his changes in. (I say arrive,
> since he does not use hg anymore there is no push or pull or sending of
> patches).
>
> I check this file into *his* branch. Now I want to merge unconditionally his
> changes, of that file, into my branch, but of course I don't want my new or
> changed files to be touched by that merge.
>
>
>  > Are there going to be some files that you do actually want to merge,
>  > and others that you want to choose just one side or the other? If so,
>  > you might be better off running the merge as usual, but then reverting
>  > *just the files that ought to be reverted* back to one branch or the
>  > other. You could do this using "hg revert -r <branchname> <file1>
>  > <file2...>" before committing the merge.
>
> Ok that is another possibility I have not thought off. But say if I have
> 10 files, I want to keep 9 files and merge 1, that solutions looks a bit
> cumbersome?

If you want to keep more of his files than yours then you would use internal:other and revert your few files back to uwe.  If you want to keep more of your files than his, use internal:local and revert his files back to foo.  For details about the various merge tools, see hg help mergetools.

  hg up uwe
  hg merge foo --tool internal:local
  hg revert test.txt -r foo
  hg commit -m "keep 9, replace 1"

However, if it turns out he touched a second file and you didn't notice, then you've just discarded his change.

To me it actually sounds like you just want a regular merge.  All files that only you changed will keep your changes and all files that only he changed will keep his changes.  If there really is no overlap in which files were edited hg won't even ask you to resolve anything.  It will do everything correctly all by itself.

The only potential issue with a regular merge is with a file you both touched.  If your changes to that file don't overlap his, hg will keep both and not say anything. (In most cases this is the right thing to do.)  If you really, really want to throw away all of your changes to a file anytime the other person touched the same file, I think this would work:

  hg up uwe
  hg merge foo --tool internal:fail
  hg resolve -l

Then do an hg revert for all files listed as unresolved and mark them as resolved before committing your merge.

  hg revert -r foo file1.txt file2.txt
  hg resolve -a -m
  hg commit -m "Merge foo discard my changes to file1 and file2"

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