将 .svn 目录从签出目录复制到非签出目录以使其成为签出目录
我在生产环境中有一个大型应用程序,我试图将其移至版本控制之下。因此,我创建了一个新的存储库并导入了应用程序,减去了不应受版本控制的各种目录和文件。现在,我需要将已安装的副本签出(但仍保留额外的文件)。此时,在最新版本的 SVN 中,我只需使用 --force 选项在现有目录之上进行签出。但遗憾的是,我有一个古老版本的 SVN,是在添加 --force 选项之前添加的(并且还无法升级......长话短说)。
因此,我将应用程序检出到另一个目录,并希望将所有 .svn 目录复制到原始目录中,从而将原始目录转为检出,同时保留额外的文件。现在,也许我只是度过了艰难的一天,错过了普通网站中的一些内容,但我似乎无法弄清楚这一点。以下是我到目前为止尝试过的方法:
使用 rsync:我似乎无法找到包含和排除指令的正确组合来递归捕获所有 .svn 目录,但没有其他内容。
使用 cp:我想不出一个好方法让它遍历整个应用程序中的所有 .svn 目录。
将 find 与 -exec cp 结合使用:我遇到了问题,因为找到的文件的路径名的前导部分弄乱了目标路径。我可以使用 -printf '%P' 排除它,但这似乎并不适用于 exec 的 {} 替换。
使用 find 和 xargs 来 cp:我在发送父目录之前发送子目录时遇到了麻烦。不幸的是,find 没有 --breadth 选项。
有什么想法吗?
其他信息:
- bash 3.0.0.14
- rsync 2.6.3 p28
- cp 5.2.1
- svn 1.3.2
I have a large application in a production environment that I'm trying to move under version control. So, I created a new repo and imported the app, minus various directories and files that shouldn't be under version control. Now, I need to make the installed copy a checkout (but still retain the extra files). At this point, in a recent version of SVN, I'd simply do a checkout over top the existing directory using the --force option. But sadly, I have an ancient version of SVN, from before when the --force option was added (and can't yet upgrade... long story).
So, I checked out the app to another directory, and want to simply copy all of the .svn directories into the original directory, thus turning the original into a checkout whilst leaving alone the extra files. Now, maybe I'm just having a rough day and missing something that's in plain site, but I can't seem to be able to figure this out. Here are the approaches I've tried so far:
Use rsync: I can't seem to hit the right combination of include and exclude directives to recursively capture all the .svn directories but nothing else.
Use cp: I can't figure out a good way to have it hit all the .svn directories across and down through the whole app.
Use find with -exec cp: I'm running into trouble with the leading part of the pathnames of the found files messing up the destination paths. I can exclude it using -printf '%P', but that doesn't seem to go into the {} replacement for exec.
Use find with xargs to cp: I'm running into trouble with find sending over child directories before sending their parents. Unfortunately, find does not have a --breadth option.
Any thoughts out there?
Other info:
- bash 3.0.0.14
- rsync 2.6.3 p28
- cp 5.2.1
- svn 1.3.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 tar 和 find 在干净的签出中捕获 .svn 目录,然后解压到您的应用程序中。
编辑:切换 find/tar 命令以使用 NUL 终止符,以在面对包含空格的文件名时保持鲁棒性。原来的命令是:
Use tar and find to capture the .svn dirs in a clean checkout, then untar into your app.
Edit: switched find/tar command to use NUL terminator for robustness in the face of filenames containing spaces. Original command was:
(5) 难道你不能只签出到另一个目录,然后将额外的文件复制到该目录,验证一切正常,然后再切换到从新目录运行应用程序吗?
(5) Can't you just make a checkout to a different directory, then copy the extra files to that directory, verify that everything's fine before switching to running the app from the new directory?