3

The Situation: I am new to Mercurial. I recently setup and have started using a repository in a model recommended to me (see Rudi's diagram below). Things have been going fine but I have run into my first practical application problem. Mercurial seems to be geared toward forward/blended merges and I would like to backup. I want to clean up our default and stable branch by starting with the vendor branch, re-make our changes and check it in as default. Then merge that into stable.

V1----V2-------------V3---------V4     Vendor
 \     \              \          \
  D1----D2---D3--D4-D5-D6-D7-D8---D9   default
                  \           \    \
                   S1----------S2---S3 stable

The Question: How do I start with the vendor branch as the parent, merge the default changes and commit them to the default branch?

I thought the following would do it, but the update changes the working directory.

hg update -C vendor
hg update default
hg merge
Community
  • 1
  • 1
Nathan Hartley
  • 4,005
  • 2
  • 43
  • 46

2 Answers2

4

There are two ways to go this. The right one and the expedient one. I'll do the right one first:

hg update default
hg --config ui.merge=internal:other merge vendor

That updates your parent to default and the working directory to default and then merges in the contents from vendor, but does so using an internal merge tool that always picks the other option when there's any difference, so you'll have default looking like vendor after that merge (and commit).

The sneaky way is:

hg update -C vendor
hg debugsetparent default
hg commit

Where debugsetparent is a powertool that does the "parent change" part of update without actually updating the files in the working directory.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • Both seem sneaky or at least out of the ordinary to me. And I was worried that I was asking something extremely obvious. – Nathan Hartley Nov 01 '10 at 20:47
  • Heh, if you had accepted the suggested repo layout I presented in your original question there would have been an obvious answer. :) – Ry4an Brase Nov 01 '10 at 21:47
  • 1
    [hanging head in shame] Though I am the only one maintaining this package, I am supposed to have the process documented to the point my non-developer co-workers could pick it up and do it in my absence. It would be hard enough to get them to issue a few commands against a single repository. Adding juggling directories to the mix seemed like a stretch. How would the separate vendor repository have made this any more obvious? You would still have to make the default working directory look like the vendor branch. – Nathan Hartley Nov 02 '10 at 13:26
  • Actually, while lying awake in bed last night, I realized all I had to do was update (or would it be revert) to the revision in the default branch which contained only the vendors code. D1 in the above diagram. It was one of those "DUH!" moments. After which I fell right to sleep. – Nathan Hartley Nov 02 '10 at 13:32
  • Oh... but I forgot to check in the default branch creation before adding our changes. So the branch and the changes are in the same change set! – Nathan Hartley Nov 02 '10 at 14:03
0

Though it lacks the context this question and its answers provides, I found the official answer on Mercurial's Wiki.

Nathan Hartley
  • 4,005
  • 2
  • 43
  • 46