如何避免意外“hg推”?而不是“hg qpush”?

发布于 2024-08-24 04:24:13 字数 461 浏览 8 评论 0原文

对于那些使用带有 MQ 扩展的 Mercurial 的用户:

这是我第二次不小心将更改提交到中央存储库 (hg Push),而不是将补丁应用到我的工作目录 (hg qpush)。

我认为这是非常不幸的,因为这是一个非常简单的错误,并且会产生非常严重的后果(至少需要执行 hg backout 和额外的 hg Push 为了生成一个新的提交,将 las 的提交“撤消”到中央存储库,但历史记录变得复杂且令人不快。

每个提交的更改都是 因为这是一个完全主观的问题,所以

你有什么建议吗?我在想:

[alias]
push=      <-- how to NOP the push command??
pushtoserver=push

这是社区维基

For those of you that use Mercurial with the MQ extension:

This is the second time I accidentally submit changes to the central repository (hg push) instead of applying a patch to my working directory (hg qpush).

I think this is very unfortunate, because it is a very simple error to make and has very severe consequences (the least having to do a hg backout and an extra hg push for each submitted change in order to generate a new commit that "undoes" the las one to the central repository, but the history becomes convoluted and unpleasant.

My goal is to configure some alias or something in my environment in orden to make hg push harder to do by accident.

Do you have any suggestions? I was thinking something like:

[alias]
push=      <-- how to NOP the push command??
pushtoserver=push

As this is a completely subjective question, this goes as community wiki.

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

提笔落墨 2024-08-31 04:24:13

一些模糊的想法:

  • 您可以从存储库中删除默认推送位置,
  • 您可以编写“您是说 qpush 吗?是,否”预推送 hook

此钩子(bash 命令行)要求在将更改推送到远程之前进行确认(使用 Mercurial 1.4 进行测试):

[hooks]
preoutgoing.confirm = read -p 'Are you sure you want to push to remote? (y/n): '; echo $REPLY | grep -q 'y'
  • 您可以别名推送到 qpush 和别名 pushtoserver 进行推送(我认为这可行,但现在无法尝试)

some vague ideas:

  • you could remove the default push location from your repo
  • you could write a "did you mean qpush? yes, no" pre-push hook

This hook (bash command line) asks for confirmation before pushing changes to the remote (tested with mercurial 1.4):

[hooks]
preoutgoing.confirm = read -p 'Are you sure you want to push to remote? (y/n): '; echo $REPLY | grep -q 'y'
  • you could alias push to qpush and alias pushtoserver to push (i think this works but can't try it now)
度的依靠╰つ 2024-08-31 04:24:13

将以下内容放入 .hgrc 中:

[alias]
pushtoserver = push
push = 'Did you mean qpush or pushtoserver?'

工作方式如下:

$ hg push
alias 'push' resolves to unknown command 'Did you mean qpush or pushtoserver?'

$ hg pushtoserver
abort: repository default-push not found!

另请参阅 alias 部分hgrc 联机帮助页

Put the following in your .hgrc:

[alias]
pushtoserver = push
push = 'Did you mean qpush or pushtoserver?'

Works like this:

$ hg push
alias 'push' resolves to unknown command 'Did you mean qpush or pushtoserver?'

$ hg pushtoserver
abort: repository default-push not found!

See also the alias section of the hgrc manpage.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文