SVN 文件夹到新存储库根目录

发布于 2024-07-21 15:47:12 字数 137 浏览 2 评论 0原文

我有一个现有的 SVN 存储库,其中包含一个保存我的项目的文件夹。 我想知道是否有一种方法可以创建一个新的存储库,并将我的项目文件夹设置为其根目录,并保留所有颠覆历史记录(日志)。 请注意,我不介意丢失原始存储库修订号。

谢谢。

I have an existing SVN repository which contains a folder that holds my project.
I wish to know if there's a way of creating a new repository with my project's folder set as its root and preserve all subversion history (log) along with it. Notice that I do not mind loosing the original repository revision numbers.

Thanks.

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

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

发布评论

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

评论(3

巨坚强 2024-07-28 15:47:12

您可以手动复制存储库,或使用 svnadmin。

然后,您可以将项目的子目录移动到根目录下,并删除其他所有内容,从而保留您想要的目录结构。 每个文件的历史记录都会被保留,但它会记住这些文件曾经有不同的路径(这可能是一件好事)。

You can copy the repository manually, or using svnadmin.

You can then move the sub-directories of your project to be under the root, and delete everything else, and thus remain with the directory structure you want. The history will be preserved, per-file, but it will remember that the files used to have a different path (which is probably a good thing).

浅唱々樱花落 2024-07-28 15:47:12

Avi 的解决方案可能是最简单的,但有一个缺点,即新存储库将包含该项目之外的所有内容的完整历史记录。 在下面的示例中,我假设您位于 *NIX 计算机的命令行,并且位于包含现有存储库的目录中。

svnadmin create new-project-repo  # create new repo next to old repo
svnadmin dump old-project-repo | svnadmin load new-project-repo
svn mv file://$PWD/new-project-repo/my-project/trunk    file://$PWD/new-project-repo/trunk
svn mv file://$PWD/new-project-repo/my-project/branches file://$PWD/new-project-repo/branches
svn mv file://$PWD/new-project-repo/my-project/tags     file://$PWD/new-project-repo/tags
# ... svn rm file://$PWD/new-project-repo/XXX for all the cruft still at the top level.

如果您运行的是 Subversion 1.6.x,svnsync 提供了更好的选择。 在 1.6.x 之前,svnsync 只能用于复制整个存储库。 在 1.6.x 中,它获得了仅复制存储库的给定子树的能力。

svnadmin create new-project-repo
# svnsync needs the ability to set revision properties, so we must install a pre-revprop-change
# hook script which just exits with status 0 (no error).  On *NIX systems, the program `true` will do this.
ln -s /usr/bin/true new-project-repo/hooks/pre-revprop-change  # possibly /bin/true
svnsync init file://$PWD/new-project-repo file://$PWD/old-project-repo/my-project
svnsync sync file://$PWD/new-project-repo
# go drink some coffee

Avi's solution is probably easiest, but has the downside that the new repository will contain the full history of all the stuff outside of this one project. In the example below, I'm assuming that you are at the command line of a *NIX machine and that you are in a directory containing your existing repository.

svnadmin create new-project-repo  # create new repo next to old repo
svnadmin dump old-project-repo | svnadmin load new-project-repo
svn mv file://$PWD/new-project-repo/my-project/trunk    file://$PWD/new-project-repo/trunk
svn mv file://$PWD/new-project-repo/my-project/branches file://$PWD/new-project-repo/branches
svn mv file://$PWD/new-project-repo/my-project/tags     file://$PWD/new-project-repo/tags
# ... svn rm file://$PWD/new-project-repo/XXX for all the cruft still at the top level.

If you are running subversion 1.6.x, svnsync provides a better option. Prior to 1.6.x, svnsync could only be used to copy whole repositories. With 1.6.x it has gained the ability to copy only a given subtree of the repository.

svnadmin create new-project-repo
# svnsync needs the ability to set revision properties, so we must install a pre-revprop-change
# hook script which just exits with status 0 (no error).  On *NIX systems, the program `true` will do this.
ln -s /usr/bin/true new-project-repo/hooks/pre-revprop-change  # possibly /bin/true
svnsync init file://$PWD/new-project-repo file://$PWD/old-project-repo/my-project
svnsync sync file://$PWD/new-project-repo
# go drink some coffee
昵称有卵用 2024-07-28 15:47:12

仅供参考: svnsync 选项对我来说适用于 subversion 1.5.3。

另外,这是一个执行相同操作的 Windows 批处理脚本:

SET OLD_REPO_URL=https://old-project-repo/my-project< br>
SET NEW_REPO_URL=D:/Repositories/new-project-repo
SET NEW_REPO_FILE_PATH=D:\Repositories\new-project-repo

svnadmin 创建%NEW_REPO_FILE_PATH%
回显退出0> %NEW_REPO_FILE_PATH%\hooks\pre-revprop-change.bat

svnsync 初始化文件:///%NEW_REPO_URL% %OLD_REPO_URL%
svnsync 文件:///%NEW_REPO_URL%

注意:在同步完成之前,您将无法浏览新存储库。

FYI: The svnsync option worked for me with subversion 1.5.3.

Also, here is a Windows batch script doing the same thing:

SET OLD_REPO_URL=https://old-project-repo/my-project
SET NEW_REPO_URL=D:/Repositories/new-project-repo
SET NEW_REPO_FILE_PATH=D:\Repositories\new-project-repo

svnadmin create %NEW_REPO_FILE_PATH%
echo exit 0 > %NEW_REPO_FILE_PATH%\hooks\pre-revprop-change.bat

svnsync init file:///%NEW_REPO_URL% %OLD_REPO_URL%
svnsync file:///%NEW_REPO_URL%

Note: You will not be able to browse the new repository until the sync is finished.

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