如何使用 Mercurial 进行快速推送

发布于 2024-11-09 11:48:17 字数 166 浏览 0 评论 0原文

本地存储库发生更改后,我使用 hg commit -m 提交,然后使用 hg Push 推送到我的服务器,然后在我的服务器中更新使用 hg update 的工作目录。

有更好的方法吗?

After a change in my local repo, I commit with hg commit -m <message>, then I push to my server with hg push, then in my server I update working dir with hg update.

Is there a better way to do this?

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

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

发布评论

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

评论(3

眼泪都笑了 2024-11-16 11:48:17

您所描述的前两个步骤:

hg commit -m <message>
hg push

是必需的,因为提交与 Mercurial 中的服务器(以及大多数其他 DVCS)完全分开。您可以编写一个提交后挂钩来在每次提交后执行推送,但不建议这样做,因为它会阻止您在提交期间和推送之前纠正简单的错误。

因为您尝试在“服务器”上执行更新,所以我假设您正在服务器上的存储库中执行代码版本。我之所以这么假设,是因为服务器通常只是充当您和您的开发人员访问的主存储库(并且还需要进行备份等......),并且不需要显式的 hg 更新.

假设您正在服务器上执行代码,您可以尝试使用以下命令替换推送和更新:

hg pull; -u

将从本地存储库执行拉取,然后自动更新。根据您的服务器配置,可能很难获取本地存储库的路径。

The first two steps you have described:

hg commit -m <message>
hg push

are required as per the fact that commits are kept completely separate from the server in Mercurial (and most other DVCS as well). You could write a post-commit hook to perform the push after each commit, but this is not advised because it prevents you from correcting simple mistakes during the commit and before the push.

Because you're trying to perform an update on 'the server' I'm assuming you are executing a version of the code in your repository on the server. I'm assuming this because typically the server would simply act as a master repository for you and your developers to access (and also to be subject to backups, etc..), and would not need the explicit hg update.

Assuming you are executing code on the server, you can try and replace the push and the update with this command:

hg pull <path to development repo> -u

which will perform a pull from your local repo and then an automatic update. Depending on your server configuration, it might be difficult to get the path to your local repo.

貪欢 2024-11-16 11:48:17

对于问题的第一部分(即,提交时自动推送),您可以使用此答案中描述的技巧:每次提交都会自动推送

如果您想自动更新工作目录,可以使用钩子来完成。将其添加到存储库的 hgrc 中(服务器目录中的 .hg/hgrc):

[hooks]
changegroup = hg update >&2

每次推送到此服务器时,这都会自动更新工作目录。此挂钩在 中进行了描述Mercurial 常见问题解答

如果您使用这两种解决方案,下次执行hg commit -m "message"时,提交将自动推送到远程服务器,并且服务器上的工作目录将被更新。

For the first part of the question (ie. automatically push when you do a commit), you can use the trick described in this answer : mercurial automatic push on every commit .

If you want to automatically update the working directory, you can do this with a hook. Add this in the hgrc of your repository (.hg/hgrc on your server directory) :

[hooks]
changegroup = hg update >&2

This will automatically update the working directory every time a push is made to this server. This hook is described in the Mercurial FAQ.

If you use these 2 solutions, the next time you do hg commit -m "message", the commit will be automatically pushed to the remote server and the working directory on the server will be updated.

写下不归期 2024-11-16 11:48:17

有一个名为 autosync 的扩展,您可能会觉得有用:

此扩展提供了 autosync 命令,该命令自动连续提交工作副本更改、从另一个存储库获取(拉取、合并、提交)更改并将本地更改推送回另一个存储库。将配置文件或待办事项列表视为要同步的事物的示例。在更高级别上,autosync 命令不仅同步存储库,还同步工作副本。必须使用中央存储库(通常没有工作副本)作为同步中心:

There is an extension called autosync you might find useful:

This extension provides the autosync command which automatically and continuously commits working copy changes, fetches (pull, merge, commit) changes from another repository and pushes local changes back to the other repository. Think of configuration files or to-do lists as examples for things to synchronize. On a higher level the autosync command not only synchronizes repositories but working copies. A central repository (usually without a working copy) must be used as synchronization hub:

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