如何更改默认分支以推入水银? [英] How to change the default branch to push in mercurial?

查看:64
本文介绍了如何更改默认分支以推入水银?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢在Mercurial中创建命名分支,以处理可能需要一段时间才能编写代码的功能,因此,当我按下时,我会执行hg push -r default以确保只将更改推送到默认分支.但是,每次执行推入或传出命令时都必须记住-r default是很痛苦的.

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.

所以我尝试通过将配置添加到我的〜/.hgrc中来解决此问题:

So I tried fix this by adding this config to my ~/.hgrc:

[defaults]
push = push -r default
outgoing = outgoing -r default

问题是,那些配置行不是真正的默认值,它们是别名.它们按预期工作,直到我尝试执行hg push -r <some revision>为止.我设置的默认"仅消除了我传入的修订.(我看到

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:我确实意识到我可以为每个分支有单独的克隆,但是我不想这样做.不得不切换目录很烦人,尤其是当您拥有共享的配置或编辑器工作区时.

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.

推荐答案

我不认为只有纯粹的分支才能做到这一点,除非有一个只有该分支的克隆(我本来会建议直到你说那不是你的茶).如果确实要杀死您,则可以创建一个小的包装器脚本,例如:

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:

#!/bin/sh
HG=/full/path/to/hg # executable
if echo $* | grep -P -q -- 'push.*\s-r($|\s)' ; then
   $HG $*
else
   $HG $* -r default
fi

将其命名为"hg",并将其放在路径的前面.

name it 'hg' and put it earlier in your path.

这篇关于如何更改默认分支以推入水银?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆