Question

I started a branch from default before I was out for a day and I didn't commit any changes to it. Since then default has had a number of changes added to it. I would like to either update my branch to the latest from default, rebuild my branch (delete and recreate) from default, or somehow pull in the changes.

So in Mercurial how would I do this?

Was it helpful?

Solution

It sounds like you haven't made any commits, which means that the history looks like this:

... [a] --- [b] --- (wc)
              \
               `--- [c] --- [d]

Here your dirty working copy is based on b and you pulled down c and d.

Since there are no commits, there is nothing to merge. You can simply update:

$ hg update

and your modifications will be merged with the changes in c and d to produce this graph:

... [a] --- [b] --- [c] --- [d] --- (wc)

If you had made one or more commits, but haven't pushed them anywhere, then you could use the rebase extension to rebuild (re-play) the commits onto a different base. There you start with

... [a] --- [b] --- [x] --- [y]

You pull from the main repository to get:

... [a] --- [b] --- [x] --- [y]
              \
               `--- [c] --- [d]

After running hg rebase you end up with

... [a] --- [b] --- [c] --- [d] --- [x'] --- [y']

where x' and y' are the rebased versions of x and y, respectively. You can repeat this procedure as long as you haven't pushed your branch anywhere (Mercurial tracks the "phase" of each changeset, and when you push a changeset somewhere it moves from the draft phase to the public phase).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top