开发者

Mercurial update will overwrite my changes instead of merging

I am coming from CVS background.

Currently, I have 2 mercurial repositories developed parallel. hello-world-bugfix and hello-world-feature (This one is being cloned from hello-world-bugfix)

Now, I want to merge the bug fixed code from hello-world-bugfix into hello-world-feature, so that end of the day, I will get a merged file.

[BUG2 BUG2 BUG2]

START
[BUG1 BUG1 BUG1]

[FEATURE2 FEATURE2 FEATURE2]

Here is how all the things looks like before, pulling and merging. The below two files had already been committed.

Mercurial update will overwrite my changes instead of merging


Mercurial update will overwrite my changes instead of merging


Now, I perform pull from hello-world-feature, to pull changes from hello-world-bugfix.

Mercurial update will overwrite my changes instead of merging

Then, I perform update, with always merge options turned on.

Mercurial update will overwrite my changes instead of merging

Here is my merged file???

[BUG2 BUG2 BUG2]

START
[BUG1 BUG1 BUG1]

It seems that my previous committed [FEATURE2 FEATURE2 FEATURE2] being overwritten.

It seems that I shouldn't perform update step, which will not merge feature with bug, but overwrite feature away with bug. What is the next correct step I should do after pulling? (through TortoiseHg), so that I can get bug fix code, and remain feature code there?

Here is the final repository view o开发者_JS百科f hello-world-feature

Mercurial update will overwrite my changes instead of merging


The "always merge" option doesn't do what you think it does.

It only merges uncommitted changes.

When you update, committed files are replaced with the new version.

To merge committed changes, ie. merge branches, you need to do an explicit merge.

So, I would select the BUG2 BUG2 BUG2 changeset in the log, then right-click on the FEATURE2 FEATURE2 FEATURE2 changeset and click Merge, and follow the instructions.

Let me expand on what the "Always merge" checkbox does.

Let's say I have two changesets in my repository, I update to the first of them, then I start modifying one of the files.

At some point I decide it would be better to have started from the other changeset instead, so I want to update to it, keeping my modifications.

If I simply do an update, with uncommitted changes, I get this dialog box when I try to update:

Mercurial update will overwrite my changes instead of merging

However, if I check the "Always merge (when possible)" checkbox, it will simply assume that I clicked on the Merge button in that dialog and not prompt me.

So the "Always merge" does not have any function at all on committed files, it won't introduce merges for you, it will only try to move your local changes along with the update.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜