Force warnings about crossing branches when runnin

2019-07-29 08:08发布

When getting the latest code from a Mercurial repo on the command line, if there are changesets that need to be merged Mercurial raises a warning:

hg up
abort: crosses branches (merge branches or use --check to force update)

This is what I expect, and from the Mercurial book it says "Mercurial is telling us that the hg update command won't do a merge; it won't update the working directory when it thinks we might want to do a merge, unless we force it to do so." At this point I know I need to merge.

How can I get the same behaviour using TortoiseHg? When I hit "Update", it happily updates me to the most recent changeset. Is there a way to warn me that a merge is probably needed? The "Always merge (when possible)" option seems to only apply when you have uncommitted changes.

2条回答
看我几分像从前
2楼-- · 2019-07-29 08:27

The reason you get an error from hg update on the command-line is that it doesn't know which revision to pick. There are 2 divergent default heads.

If you were to execute hg update -r <specific rev>, the command completes without error.

When using TortoiseHg, you update by:

  1. right-clicking a specific changeset
  2. selecting Update...

This translates to hg update -r <rev>, so there is no error.

Using TortoiseHg, you always have the revision graph in front of you. The graph shows when newly pulled changesets create a new head.

查看更多
beautiful°
3楼-- · 2019-07-29 08:35

The Mercurial abort you are seeing is occurring because you have outstanding (ie: non-committed) changes in your working directory, are trying to perform an update, and Mercurial has decided that you should probably perform a merge instead.

TortoiseHg should also warn you about this, but it will do so in a different way. It will spawn a dialogue that asks if you want to Discard, Merge, or Shelve your outstanding changes. This is what it looks like in TortoiseHg v2.X.X, but it should be similar in v1.1.X:

enter image description here

If you're not seeing this in TortoiseHg, you may not have any outstanding changes. Try it again - are you seeing these options?

查看更多
登录 后发表回答