如何在 Mercurial 中添加远程存储库?

发布于 2024-10-16 16:02:18 字数 154 浏览 2 评论 0原文

我通过以下方式使用 Git 存储库:

  • 我在不同的生产计算机上拥有主存储库和多个遥控器。
  • 我将生产代码推送到远程并重新启动服务以使更改生效。

我即将从 Git 切换到 Mercurial,我想提前知道如何实现类似的目标。

I am working with Git repositories in the following way:

  • I have the master repository and several remotes on the different production machines.
  • I am pushing the production code to the remotes and restart the services for the changes to take effect.

I am about to switch from Git to Mercurial and I would like to know ahead how I can achieve something like that.

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

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

发布评论

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

评论(4

倾城°AllureLove 2024-10-23 16:02:18

您将条目添加到本地克隆的 .hg/hgrc 文件的 [paths] 部分。以下是 .hg/hgrc 文件中的部分示例:

[paths]
remote1 = http://path/to/remote1
remote2 = http://path/to/remote2

然后,您可以使用 hg Push Remote1 等命令将变更集发送到该存储库。如果您希望远程存储库更新工作目录,则需要在执行更新的远程位置放置一个 changegroup 挂钩。这看起来像:

[hooks]
changegroup = hg update 2>&1 > /dev/null && path/to/script/restart-server.sh

并不是每个人都热衷于让远程存储库在推送时自动更新其工作目录,而且它肯定不是默认设置。

You add entries to the [paths] section of your local clone's .hg/hgrc file. Here's an example of a section that would go in the .hg/hgrc file:

[paths]
remote1 = http://path/to/remote1
remote2 = http://path/to/remote2

You can then use commands like hg push remote1 to send changesets to that repo. If you want that remote repo to update is working directory you'd need to put a changegroup hook in place at that remote location that does an update. That would look something like:

[hooks]
changegroup = hg update 2>&1 > /dev/null && path/to/script/restart-server.sh

Not everyone is a big fan of having remote repos automatically update their working directories on push, and it's certainly not the default.

酒解孤独 2024-10-23 16:02:18

如果要添加默认路径,则必须在 ~project/.hg/hgrc 文件中使用 default 。如下:

[paths]
default = https://path/to/your/repo

祝你好运。

if you want to add default path, you have to work with default in your ~project/.hg/hgrc file. As Follows:

[paths]
default = https://path/to/your/repo

Good Luck.

〗斷ホ乔殘χμё〖 2024-10-23 16:02:18

你可以看看 hg-git GitHub 插件

hg-git 总体思路

添加了从 Mercurial 向 Git 服务器存储库推送和拉取的功能。
这意味着您可以在 Mercurial 中协作处理基于 Git 的项目,或者使用 Git 服务器作为与同时使用 Git 和 Mercurial 的开发人员一起的团队的协作点。

注意:我尚未使用最新版本的 Mercurial 测试该工具。

You could have a look at hg-git GitHub plugin:

hg-git general idea

adding the ability to push to and pull from a Git server repository from Mercurial.
This means you can collaborate on Git based projects from Mercurial, or use a Git server as a collaboration point for a team with developers using both Git and Mercurial.

Note: I haven't tested that tool with the latest versions of Mercurial.

心碎无痕… 2024-10-23 16:02:18

如果您使用的是 Unix 并且安装了 Git,则可以使用此 bash 函数轻松添加远程路径,而无需使用文本编辑器:

add-hg-path() {
    git config -f $(hg root)/.hg/hgrc --add paths.$1 $2
    awk '{$1=$1}1' $(hg root)/.hg/hgrc > /tmp/hgrc.tmp
    mv /tmp/hgrc.tmp $(hg root)/.hg/hgrc
}

然后使用以下命令调用它:

$ add-hg-path remote1 https://path.to/remote1

如果有人想构建一个 Powershell 等效项,我愿意也包括这一点。其他潜在的改进包括对参数的错误检查以及分解对 $(hg root) 的调用。

If you're on Unix and you have Git installed, you can use this bash function to readily add a path to the remotes without a text editor:

add-hg-path() {
    git config -f $(hg root)/.hg/hgrc --add paths.$1 $2
    awk '{$1=$1}1' $(hg root)/.hg/hgrc > /tmp/hgrc.tmp
    mv /tmp/hgrc.tmp $(hg root)/.hg/hgrc
}

Then invoke it with:

$ add-hg-path remote1 https://path.to/remote1

If someone would like to build a Powershell equivalent, I'd like to include that as well. Other potentials improvements include error checking on the parameters and factoring out the call to $(hg root).

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