在 Mercurial 存储库之间共享文件
有一个或两个文件,例如 .hgignore,我通常希望在一堆项目中的每个文件中都相同。
但是,这些文件的性质意味着我不能简单地将它们移动到公共共享项目并让其他项目依赖于该项目。它们必须位于每个项目内。符号链接也不是一个选项,因为我们的一些开发人员使用 Windows。
如何在存储库之间共享这些文件并传播更改(至少在我的本地计算机上)?我正在使用 Eclipse。
There are one or two files, like .hgignore, which I generally want to be the same in each of a bunch of projects.
However, the nature of these files means that I can't simply move them to a common shared project and just make the other projects depend on that project. They have to be inside each project. Symbolic links are not an option either because some of our developers use Windows.
How can I share these files between repositories and have changes propagated across (on my local machine, at least)? I'm using Eclipse.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 hgignore 的具体情况,您可以在每个项目的
.hg/hgrc
文件中放置这样的条目:如果您知道您的公共库将始终位于父目录中,就像通常的情况一样您可以执行的子存储库设置:
或者如果您知道它始终位于项目签出的同级目录中,您可以执行以下操作:
不幸的是,没有绝对的方法来引用在任何地方都有效的文件,但您至少可以做到这一点在您的机器上,您的所有结账都引用了一个常见的忽略。
For your specific case of hgignore you can put an entry like this in each project's
.hg/hgrc
file:If you you know your common library will always the in the parent directory, as is often the case with a subrepo setup you could do:
or if you know it will always be in a sibling directory of project checkouts you could do:
Unforunately there's no absolute way to reference a file that's valid everywhere, but you can at least to to a point where on your machine all your checkouts are referencing a common ignore.
硬链接而不是复制相关文件可以在 Eclipse 中使用 - 尽管您必须刷新每个其他项目才能使其接受更改。 但是,您可以将 Eclipse 配置为监视文件系统并在需要时自动刷新 - 我建议这样做。
默认情况下它不适用于 Emacs,因为 Emacs 会破坏硬链接(这通常是正确的做法)做,但在这种情况下不是你想要的)。不过,您可以使用
(setq backup-by-copying-when-linked t)
对多重链接文件禁用此行为。Hardlinking instead of copying the relevant files sort of works with Eclipse - although you have to refresh each of the other projects to get it to pick up the change. However, you can configure Eclipse to watch the filesystem and automatically refresh whenever it needs to - I recommend this.
It does not work by default with Emacs, because Emacs breaks hard links (which is normally the right thing to do, but is not what you want in this case). However, you can disable this behaviour for multiply-linked files with
(setq backup-by-copying-when-linked t)
.