简体   繁体   English

SVN中继,分支和标签文件夹问题

[英]SVN Trunk, Branches, and Tags Folder Question

I'm reading the red bean SVN book , and it says to layout trunk, branches, and tags folders like so: 我正在阅读Red bean SVN书 ,它说要布局主干,分支和标签文件夹,如下所示:

$ svn list file:///var/svn/multi-project-repo
project-A/
project-B/
$ svn list file:///var/svn/multi-project-repo/project-A
trunk/
branches/
tags/
$ svn list file:///var/svn/multi-project-repo/project-B
trunk/
branches/
tags/
$

Now, that's all well and good, but what if I want to make a local working copy of just the trunk folders for project-A and project-B. 现在,一切都很好,但是如果我只想为项目A和项目B创建主干文件夹的本地工作副本,该怎么办。 If I update with the URL pointing to "multi-project-repo", I will additionally get the branches and tags folders that I don't need. 如果我使用指向“ multi-project-repo”的URL更新,则还将获得不需要的分支和标签文件夹。 Is what I'm asking unreasonable (getting only the trunk files) or am I being reasonable, and is there an easy way to do this? 我要问的是不合理的(仅获取主干文件)还是我很合理,有没有简单的方法可以做到这一点?

svn co http://mycompany.com/svn/Projects/Project1/trunk ./project1-trunk

That'll put a working copy of Project1/trunk in the local directory ./project1-trunk. 这会将Project1 / trunk的工作副本放入本地目录./project1-trunk中。 There's nothing inherently special about any of the directories -- as far as SVN cares, they're just directories, and you can copy any one of them. 对于任何目录,天生就没有什么特别的-就SVN而言,它们只是目录,您可以复制其中的任何一个。

Another option (also in the svnbook ) is to have one set of trunk, tags, and branches. 另一个选择(同样在svnbook中 )是拥有组中继线,标签和分支。

In the name of full disclosure, though, we'll mention another very common layout. 但是,以全面披露的名义,我们将提到另一个非常常见的布局。 In this layout, the trunk, tags, and branches directories live in the root directory of your repository, and your projects are in subdirectories beneath those, like so: 在这种布局中,主干目录,标签目录和分支目录位于存储库的根目录中,而项目位于这些目录下的子目录中,如下所示:

/
   trunk/
      calc/
      calendar/
      spreadsheet/
      …
   tags/
      calc/
      calendar/
      spreadsheet/
      …
   branches/
      calc/
      calendar/
      spreadsheet/
      …

This is another common layout, and might make more sense if the projects are more closely related or worked with together. 这是另一种常见的布局,如果项目之间的关系更紧密或一起工作,则可能更有意义。

In this case, get the trunk, you get all of the projects. 在这种情况下,获得主干,您将获得所有项目。 This is how we have our repository set up. 这就是我们建立存储库的方式。

Use the URL to the repository directory you care about. 使用指向您关注的存储库目录的URL。 If you want the "trunk" directory, check out that subdirectory, not the entire repository. 如果需要“ trunk”目录,请检出该子目录,而不是整个存储库。

Keep reading! 继续阅读!

Assuming you are using mentioned layout and want to checkout all the trunks of all the projects with one command, consider the following technique: 假设您使用的是上面提到的布局,并且想用一个命令检出所有项目的所有干线,请考虑以下技术:

  1. Create an additional project in SVN, eg call it all-trunks : 在SVN中创建另一个项目,例如,将其称为all-trunks

     svn mkdir file:///var/svn/multi-project-repo/all-trunks 
  2. Make a working copy of all-trunks : 制作all-trunks的工作副本:

     svn co file:///var/svn/multi-project-repo/all-trunks 
  3. Edit svn:externals property of the working copy of all-trunks to add all the project trunks you have: 编辑all-trunks的工作副本的svn:externals属性,以添加您拥有的所有项目主干:

     svn propedit svn:externals . ... ^/project-A/trunk project-A ^/project-B/trunk project-B ... 
  4. Commit: 承诺:

     svn ci 

Now every time you want to get a working copy with trunks of all the projects you'll only need to checkout the all-trunks : 现在,每次您想要获得包含所有项目主干的工作副本时,只需签出all-trunks

svn co file:///var/svn/multi-project-repo/all-trunks

Every time you create a new project don't forget to add it to svn:externals. 每次创建新项目时,请不要忘记将其添加到svn:externals中。

You can write a script that gets a list of all the projects svn ls file:///var/svn/multi-project-repo (excluding all-trunks ) and builds a command to update svn:externals of all-trunks . 您可以编写一个脚本来获取所有项目svn ls file:///var/svn/multi-project-repo (不包括all-trunks )的列表,并构建一个命令来更新all-trunks svn:externals

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

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