mercurial 每次提交时自动推送 [英] mercurial automatic push on every commit

查看:33
本文介绍了mercurial 每次提交时自动推送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常熟悉 subversion 工作流程以及我的计算机 99.9% 的时间都连接到 Internet 的事实,我不喜欢分别执行hg ci"和hg push".

Being very familiar with the subversion workflow and that fact that 99.9% of the time my computer is connected to the internet, I don't like doing 'hg ci' and 'hg push' separately.

我记得 bzr 有一个checkout"命令,它会绑定后续的commit"命令以自动直接提交到服务器(push").

I remember bzr had a 'checkout' command that would bind subsequent 'commit' commands to automatically commit directly to the server ('push').

mercurial 有没有类似的东西?

Does mercurial have something similar to this?

PS:编写一个运行 'hg ci $* && 的 shell 脚本或别名hg push' 将是我做的最后一件事.

PS: Writing a shell script or alias that runs 'hg ci $* && hg push' would be the last thing I'd do.

推荐答案

您可以添加一个 hook 以在成功提交后运行推送.

You could add a hook to run push after a successful commit.

我刚刚试了一下,它似乎工作正常.我将以下内容添加到要激活自动推送的存储库的 .hg/hgrc 文件中:

I just tried it out and it seems to work fine. I added the following to the .hg/hgrc file of the repository I wanted to activate automatic pushing for:

[hooks]
commit.autopush = hg push

编辑 2:此外,您不必担心这样的事情:

EDIT 2: Also, you don't have to worry about something like this:

  • 您位于不想自动推送的存储库中.
  • 您使用 hg -R ~/another-repo-that-autopushes commit 在另一个执行自动推送的存储库中提交.
  • hg push 挂钩最终会推送当前目录中的更改而不是您提交的更改吗?
  • You're in a repository that you don't want to automatically push.
  • You use hg -R ~/another-repo-that-autopushes commit to commit in a different repo that does automatically push.
  • Will the hg push hook end up pushing the changes in the current directory instead of the one you're committing in?

不,不会.根据我链接的页面:

No, it won't. According to the page I linked:

一个可执行钩子总是以其当前目录设置为存储库的根目录运行.

An executable hook is always run with its current directory set to a repository's root directory.

这是一个极端情况,但 Mercurial 可以正确处理它.

It's an edge case, but Mercurial handles it correctly.

这篇关于mercurial 每次提交时自动推送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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