Merge which should abandon one of the parents

Marcin Kasperski Marcin.Kasperski at mekk.waw.pl
Wed Nov 14 15:21:59 UTC 2018


(IIRC this subject was already discussed more than once, but having
 faced it once more, I'd like to revisit it)

The situation:
- there are two heads, say XXXX and YYYY
- I want to merge them, but I want the resulting code to be
  identical to XXXX

{ That's fairly realistic case: YYYY was some experiment or sideline,
  I am killing it for good, but I also mark that here and there
  I reviewed it… }

So I read `hg help merge` and `hg help merge-tools`, and after some
consideration (and especially after noticing difference between :local
and :merge-local) I try:

   hg update XXXX
   hg merge --tool :local  YYYY

I review the results, just to be sure:

   hg diff -r XXXX

… and, to my confusion, some differences show up. All files which were
changed in YYYY, but untouched on XXXX, are changed.

After some consideration I guess that this is caused by the fact that
merge tool is not spawned if changes are made only on one branch.
Still, I am confused.

I work around this by

   hg revert -r XXXX --all

(plus hg rm of files created on YYYY branch) before commiting.

Then I forget about this, a year or two passes, and I fall into the trap
once more. Or see some colleague confused this way.

~~~~~~~~~~

The problem is not new, see for example „crossed” section in
   https://stackoverflow.com/questions/4197744/how-to-merge-to-get-rid-of-head-with-mercurial-command-line-like-i-can-do-with
which also suggests that 
   hg debugsetparents XXXX YYYY
does exactly what I want.

~~~~~~~~~~~

So mayhaps it could be possible to have 
   hg merge --take-local
or
   hg merge --tool :local-only
or sth similar to do exactly that (equivalent of debugsetparents)
under more user-friendly umbrella?

Or at least, merge and mergetools help would benefit from some section
mentioning this problem…




More information about the Mercurial mailing list