如何更改默认分支以推送到 Mercurial 中?
我喜欢在 Mercurial 中创建命名分支来处理可能需要一段时间编码的功能,因此当我推送时,我会执行 hg push -r default
以确保我只将更改推送到默认分支。然而,每次执行推送或传出命令时都必须记住 -r default
,这很痛苦。
所以我尝试通过将此配置添加到我的 ~/.hgrc 来解决此问题:
[defaults]
push = push -r default
outgoing = outgoing -r default
问题是,这些配置行并不是真正的默认值,它们是别名。它们按预期工作,直到我尝试执行 hg Push -r
。我设置的“默认”只是删除了我传入的修订版。(我看到 默认值已弃用,但别名也有同样的问题)。
我尝试环顾四周,但找不到任何可以让我设置默认分支来推送并允许我在必要时覆盖它的东西。有人知道我还能做些什么吗?
ps:我确实意识到我可以为每个分支拥有单独的克隆,但我宁愿不这样做。必须切换目录很烦人,特别是当您共享配置或编辑器工作区时。
I like creating named branches in Mercurial to deal with features that might take a while to code, so when I push I do a hg push -r default
to ensure I'm only pushing changes to the default branch. However, it is a pain to have to remember -r default
every time I do do a push or outgoing command.
So I tried fix this by adding this config to my ~/.hgrc:
[defaults]
push = push -r default
outgoing = outgoing -r default
The problem is, those config lines are not really defaults, they are aliases. They work as intended until I try to do a hg push -r <some revision>
. And the "default" I've setup just obliterates the revision I passed in. (I see that defaults are deprecated, but aliases have the same problem).
I tried looking around, but I can't find anything that will allow me to set a default branch to push AND allow me to override it when necessary. Anyone know of something else I could do?
ps: I do realize that I could have separate clones for each branch, but I would rather not do that. It's annoying to have to switch directories, particularly when you have shared configuration or editor workspaces.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不认为你可以用纯水银来做到这一点,除非有一个只有那个分支的克隆(我正要建议,直到你说这不是你的那杯茶)。如果它真的让你很烦恼,你可以创建一个小包装脚本,例如:
将其命名为“hg”并将其放在路径的前面。
I don't think you can do it with pure mercurial, short of having a clone with only that branch in it (which I was was about to suggest until you said it wasn't your cup of tea). If it's really killing you you can create a tiny wrapper script like:
name it 'hg' and put it earlier in your path.
您可能正在使用 Tortoise HG 吗?完全恢复到显式分支名称将导致 Tortoise HG 记住您在后续提交期间正在处理的分支。我不确定它从什么元数据中收集这些信息。
例如
Are you using Tortoise HG perhaps? Doing a full revert to an explicit branch name will cause Tortoise HG to remember the branch you're working on during subsequent commits. I'm not sure what metadata it gleans this from.
e.g.
由于通常您应该将变更集推送到您正在工作的当前分支中,因此我修改了 ry4an-brase 所做的上述答案,以带有通知的方式推送当前分支。
Since normally you should push changesets in the current branch you are working, I modified the above answer made by ry4an-brase, to push current branch with a notice.