views:

44

answers:

1

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 automatically 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?

+4  A: 

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.

Borealid
But beware of the very similar `hg up -C` which will discard any changes you made to your working directory.
Niall C.
So darned deceptively simple. Thanks!
Robert S.