在源代码控制存储库中模拟类似符号链接的行为

发布于 2024-07-27 04:11:28 字数 791 浏览 4 评论 0原文

假设我有以下(所需的)文件夹结构:

*CommonProject
*Project#1
----> CommonProject(link)
*Project#2
----> CommonProject(link)

其中 CommonProject 是属于该项目的源的位置,而 CommonProject(link) 只是到主位置的软链接。 如果我们将其想象为可视客户端中的树视图,如果我展开 Project#1,我将看到 CommonProject 作为子目录,即使文件实际上并未存储在那里。

这样做的目的是为了实现以下行为:

当我签出 Project#1 时,我会获取与该项目关联的文件以及包含其所有文件的子文件夹 CommonProject(就像 Project#1包含版本控制存储库中文件的副本)。 现在,如果我要修改 Project#1 内的 CommonProject 文件并将更改提交到存储库,则更改将进入 CommonProject 位置(实际上没有文件存储在存储库中的 Project#1 下本地)。 现在,如果我要同步 Project#2,因为它还包含 CommonProject 的符号链接,它现在将获取我的更新。 本质上,重复的文件只存在于我的机器上,但在存储库中只有一个版本的 CommonProject。

我知道如果不兼顾 3 个规格,Perforce 就无法做到这一点。 这是非常复杂且容易出错的,尤其是当很多人这样做时。 是否有源代码控制存储库可以做到这一点? (指向一些有关如何完成此操作的文档的指针是一个优点)

谢谢。

Suppose I have the following (desired) folder structure:

*CommonProject
*Project#1
----> CommonProject(link)
*Project#2
----> CommonProject(link)

Where the CommonProject is the location of the source belonging to that project, and CommonProject(link) is merely a soft link to the main location. If we imagine this as a tree-view in a visual client, if I expand Project#1 I will see CommonProject there as a subdirectory, even though the files are not actually stored there.

The purpose of this is to enable the following behaviour:

When I check out Project#1 I get the files associated with that project as well as a subfolder CommonProject containing all of its files (as if Project#1 contained the copy of the files in the Version Control repository). Now if I were to modify CommonProject's files inside of Project#1 and was to submit my changes to the repository, the changes would go into the CommonProject location (no file is actually stored locally under Project#1 in the repository). Now if I was to sync Project#2, as it also contains symlink to CommonProject, it will now get my updates.
Essentially the duplication of files only exists on my machine, but in the repository there is only one version of CommonProject.

I know Perforce can’t do this, without juggling 3 specs. This is very complicated and error prone, especially when a lot of people do it. Is there a source control repository out there that can do this? (a pointer to some docs on how it can be done is a plus)

Thank you.

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

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

发布评论

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

评论(2

拿命拼未来 2024-08-03 04:11:28

Subversion 可以直接在存储库中存储符号链接。 但这仅适用于支持符号链接的操作系统,因为 svn 只是以与任何其他文件相同的方式存储符号链接。

我认为你真正想要的是链接到单独的项目。 Subversion 通过 externals 和 git 通过 子模块。 另一种选择是在构建过程中管理此类事情,以便在初始化构建时收集一些静态资源。 一般来说,更新经常更改的实用程序库会导致稳定性问题,因此您可以在需要时手动(或使用巧妙的脚本)执行此操作

Subversion can directly store symlinks in the repository. This only works for operating systems that support symlinks though, as svn just stores the symlink the same way it would with any other file.

I think what you really want is to link to separate projects though. Subversion supports this through externals and git through submodules. Another alternative is to manage this sort of thing with in your build process, so that some static resources are gathered when you initialize the build. Generally, updating a utilities library that changes often is going to cause stability problems, so you can do this manually (or with clever scripts) when you need to

最单纯的乌龟 2024-08-03 04:11:28

您最好将项目存储在一个平面目录中(每个项目 1 个目录,全部位于同一级别),然后使用您构建的系统或 IDE 将所有内容链接在一起。

You'd probably be much better off just storing the projects in a flat directory (1 directory per project, all at the same level), and using whatever you build system or IDE is to link all the stuff together.

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