开发者

How to prevent a file from automatically merging when switching branches in Mercurial?

开发者 https://www.devze.com 2023-01-10 18:32 出处:网络
Let\'s say I have two branches named default and newfeature. I have a file called readme.txt in both branches. I\'m working on the newfeature branch and I make a change to readme.txt. If I run hg up d

Let's say I have two branches named default and newfeature. I have a file called readme.txt in both branches. I'm working on the newfeature branch and I make a change to readme.txt. If I run hg up default without committing the change, Mercurial autom开发者_运维知识库atically merges the version of readme.txt in newfeature directly into default.

How can I change this behavior? What I'm worried about is developers forgetting to commit before they switch branches, thus merging whatever they've been working on.

This is what the process looks like:

C:\source\BranchTest\Main>hg branch
Exams

C:\source\BranchTest\Main>hg status
M readme.txt

C:\source\BranchTest\Main>hg up default
merging readme.txt
0 files updated, 1 files merged, 0 files removed, 0 files unresolved

C:\source\BranchTest\Main>

Notice the automatic merge because I didn't commit the change to readme.txt. Mercurial doesn't warn me that this will happen.

Any suggestions?


Use hg up -c (lower-case 'c'). This will check your working directory before updating.

You can make this the default in your hgrc file.

0

精彩评论

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