Richard Deurwaarder
Richard Deurwaarder

Reputation: 2040

mercurial copying an existing branch

We have 3 branches, default bugfix and release.

After some bad merges bugfix is now in a very broken state. We've kind of ignored this branch for a while but now it's needed again. I'd like it to be exactly like default but merging doesn't work, because it now has the same ancestor as default.

I've tried to just copypaste default branch to bugfix branch, and commit that.

That seems to work in the sense that

hg up --rev commitB
hg diff --rev commitA

hg diff gives back nothing, and

hg up --rev commitA
hg diff --rev commitB

hg diff gives back nothing

but when I hg up from one commit to the other I still see "42 files updated" which makes me think there are differences...

How can I know for sure that there aren't any differences? and if there are how do I make the branches identical?

Upvotes: 0

Views: 175

Answers (1)

Ry4an Brase
Ry4an Brase

Reputation: 78350

Branches are more fluid than you're imaging them. When you talk about what is in branch X what you're really saying is "what the working directory looks like if I check out the most recent (technically tipward) commit whose branch: label is set to X.

So, if I'm understanding what you want your easiest solution is to just create a new (and thus most recent) commit with the branch name bugfix. This should do that:

hg update default
hg branch --force bugfix
...make a tiny change (perhaps to the readme)...
hg commit -m 'reinvogorating bugfix'

Then when you hg update bugfix it will be exactly like deafult was at the time you did that.

What you're doing isn't working because files that have been removed and/or added in default weren't removed or added in your bugfix via copypaste, but reallly don't copy paste, just re-create bugfix off of default and be done with it.

Upvotes: 1

Related Questions