简体   繁体   English

遵循 SVN 中的符号链接

[英]Follow symlinks in SVN

I have a linux directory (and don't need any windows checkout):我有一个 linux 目录(不需要任何 Windows 结帐):

/home/me/projects/project1

In this project, I need SVN (1.8.8) to follow a symlink "link1":在这个项目中,我需要 SVN (1.8.8) 来跟随符号链接“link1”:

/home/me/projects/project1/link1/<some_directories_and_files>

But SVN won't let me do that, it just add link1 but not its content.但是 SVN 不会让我这样做,它只是添加了link1而不是它的内容。 If I try to add its content, I get an error:如果我尝试添加其内容,则会收到错误消息:

svn add link1/*
svn: E145001: Can't schedule an addition of '/home/me/projects/project1/link1/first_directory' below a not-directory node

I tried converting link1 to hard link but I can't do that either:我尝试将 link1 转换为硬链接,但我也不能这样做:

ln /path/to/my/linked/directory link1
ln: ‘/path/to/my/linked/directory’: hard link not allowed for directory

Any idea?任何的想法? How do you handle this kind of configuration?你如何处理这种配置? I just need to commit everything from /home/me/projects/project1 from a simple svn commit我只需要通过一个简单的svn commit/home/me/projects/project1 svn commit

If I understand your problem, you have:如果我理解你的问题,你有:

project1/
project1/link1 -> ../../some/where/else

If you do a simple svn add link1 it adds a symlink entry to the subversion repository, but what you're trying to accomplish is getting the stuff under somewhere else into the tree.如果您执行一个简单的svn add link1它会向 subversion 存储库添加一个符号链接条目,但是您要完成的是将其他地方的内容放入树中。

If this is the case, then you're fighting in the wrong direction, you should make the real files and directories under link1, and make the target locations symlinks into the link1 directory.如果是这种情况,那么您就在错误的方向上进行斗争,您应该将真实的文件和目录放在 link1 下,并将目标位置符号链接到 link1 目录中。 That would be a simple solution to the problem.这将是解决问题的简单方法。

Another solution would be to make the location ../../some/where/else an svn location in it's own right, and make link1 an externals definition to that location.另一种解决方案是将位置../../some/where/else svn 位置,并使 link1 成为该位置的外部定义。 When you commit in the main directory, the externals would be committed at the same time which would achieve storing the information;当你在主目录中提交时,外部将同时提交,从而实现存储信息; however to ensure that the other location was kept in sync, you would have to make sure to update it to the same version as the stored data.但是,为了确保其他位置保持同步,您必须确保将其更新为与存储数据相同的版本。

In my case, on my desktop, I have a settings directory:就我而言,在我的桌面上,我有一个设置目录:

$HOME/settings

This is a checked out copy of a directory containing .bashrc , .profile , .vimrc , .vim , etc. files and folders from an svn repo.这是包含.bashrc.profile.vimrc.vimsvn库中的文件和文件夹的目录的检出副本。 All my profile files and directories were symlinks into this folder, so for example .profile -> settings/.profile , etc. When I make changes, they are reflected in the svn tree, which I can commit back to in order to ensure that I don't lose my config settings when I go to another system.我所有的配置文件和目录都是到这个文件夹的符号链接,例如.profile -> settings/.profile等。当我进行更改时,它们会反映在 svn 树中,我可以提交回以确保当我转到另一个系统时,我不会丢失我的配置设置。

If you really want svn to follow symlinks as hardlinks (You can't make directory hardlinks because it would be a bad thing ™), then you'll have to hack the svn client source so that it did what you wanted;如果您真的希望 svn 将符号链接作为硬链接(您不能制作目录硬链接,因为这将是一件坏事™),那么您必须破解 svn 客户端源代码,以便它执行您想要的操作; but this would be a maintenance nightmare.但这将是一个维护噩梦。

You could get away with making the symlink into a bind mount point directed at the target, but that has it's own issues - you would need to be root to accomplish this, and it ends up leaving funny entries in your /proc/mounts to accomplish this:可以将符号链接设置为指向目标的绑定安装点,但这有其自身的问题 - 您需要以 root 身份完成此操作,并且最终会在您的 /proc/mounts 中留下有趣的条目来完成这个:

mount --bind /absolute/path/to/some/where/else project1/link1

Bind mounting does not work when mounting to inside the svn tree since the working copy format changes introduced by svn 1.7 - svn operations attempt to move files from .svn/tmp to the target folder, which would be a cross device link.挂载到 svn 树内部时绑定挂载不起作用,因为 svn 1.7 引入的工作副本格式更改 - svn 操作尝试将文件从 .svn/tmp 移动到目标文件夹,这将是跨设备链接。 The workaround in this case is to go from the inside out, ie:这种情况下的解决方法是由内而外,即:

mount --bind project/link1 /absolute/path/to/somewhere/else

With the change in the svn working copy format of a single .svn folder for the checked out tree, you will need to perform all subsequent operations from the true svn location, as it won't work from the bind mounted folder, on the assumption that you have not mounted the entire checked out tree at that target location.随着检出树的单个 .svn 文件夹的 svn 工作副本格式的更改,您将需要从真正的 svn 位置执行所有后续操作,因为它不会从绑定安装的文件夹中工作,假设您尚未在该目标位置安装整个检出的树。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM