如何防止 hg 更新无需在 Mercurial 的活动分支中提交?
假设我的本地存储库有 2 个分支,case1 和 case2。我目前正在处理 case1 并有未提交的更改。
当我 hg up case2
时,我希望禁止此导航,除非我选择了是否提交 case1 中的更改。
知道如何做到这一点吗?
Let's say I have 2 branches on my local repo, case1 and case2. I'm currently working on case1 and have uncommitted changes.
When I hg up case2
I want this navigation to be prohibited unless I have made the choice of committing my changes in case1 or not.
Any idea how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您
hg up case2
未提交更改,并且case2
不是case1
的直接祖先/后代,Mercurial 将拒绝执行此操作,您可以然后选择提交更改、使用建议的选项放弃更改或更新到
case1
和case2
的共同祖先。后一种情况是一种两跳方法,在您跳至情况 2 时保留未提交的更改。此外,较新版本的 Mercurial 还为更新命令提供了
--check
选项。这将完全按照您的要求进行:如果您的工作副本脏了,则中止命令。当然,如果您检查
hg help update
,所有这些都是非常明显的。If you
hg up case2
with uncommitted changes, andcase2
is no direct ancestor/descendant ofcase1
, Mercurial will refuse to do it withYou can then opt for either committing your changes, discard them by means of using the proposed option or update to the common ancestor of
case1
andcase2
. The later case is a two-hop approach to take the uncommitted changes with you while you hop to case2.In addition, newer versions of Mercurial have the
--check
option for the update command. This will do exactly what you wanted: abort the command in case your working copy is dirty.Of course, all this is pretty obvious if you check
hg help update
.