SVN部分分支
我是 SVN 新手,所以这可能是一个简单的问题。
我们有一个带有一级目录的“主干”:
10 <-- documents
20 <-- source code, db scripts, ...
30 <-- documents
40 <-- referenced 3rd party library-es
我从“主干”创建了一个“开发”分支。 在“开发”中,我们更改源代码,并在测试后将其合并到“主干”。
问题在于目录“10”和“30”中存储了开发不需要的 *.doc 文件,因此要求“develop”分支没有这些目录。
解决方案仍然应该:
- 允许“develop”工作副本的根文件夹上的“svn update”,(20和40)
- 该更新不应重新创建 目录 10 和 30,
- 当然将“develop”合并到“trunk”不应删除“trunk”中的 10 或 30。
编辑: 我忘了提到“源代码”不仅在 20 中。还有引用的 dll-s 和构建脚本等也在第一级目录中,比如说 40。
I'm new to SVN so this could be an easy question.
We have a "trunk" with 1st level directories:
10 <-- documents
20 <-- source code, db scripts, ...
30 <-- documents
40 <-- referenced 3rd party library-es
I made a "develop" branch from the "trunk".
In "develop" we change our source code and after testing it we merge it to "trunk".
The problem in that in directories "10" and "30" are stored *.doc files that are not needed for development so it is REQUIRED that "develop" branch doesn't have those directories.
The solution should still:
- allow "svn update" on root folder of "develop" working copy, (20 and 40)
- that update should not re-create
directories 10 and 30 and - of course merging "develop" to "trunk" should NOT delete 10 or 30 in "trunk".
EDIT:
I forgot to mention that "source code" is not only in 20. There are referenced dll-s and build scripts etc. that are also on 1st level directory, lets say 40.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
如果我正确地阅读了你的问题,这是一个简单的问题,使用 svn copy 仅将所需的目录复制到分支中 - 基本上,是 Mike Kushner 和 Ivan Krechetov< 的答案的组合/em>.不过,我认为,在自己完成这些步骤之后可能会更容易理解,因此本文的其余部分将创建一个示例存储库并显示副本和合并。
我假设您使用的是“标准”存储库布局,该布局在顶层有三个子目录:trunk、branches 和 >标签。并且您的 10、20、30 和 40 目录位于 trunk 下。换句话说:
并且,正如迈克指出的那样,您的目标将是拥有一个如下所示的结构:
从您的帖子中尚不清楚(至少在当前编辑中),但您可能有一个目录结构,其中 < em>10、20 等处于顶级水平。在这种情况下,您需要创建一个新的顶级目录,我将其称为dev,以便您的整个存储库如下所示:
请注意,您无法创建dev 20以下。好吧,从身体上来说你可以,但是这样做几乎肯定会破坏你的构建。
好的,让我们看一个示例,在该示例中我们创建一个新存储库并在其中放入一些文件。您必须能够运行svnadmin命令(您应该能够执行此操作,除非您有一个偏执的系统管理员)。 ,选择一个临时目录,然后执行以下命令(我运行的是 Linux;如果您运行的是 Windows,命令将是相同的,但您需要在 REPO 变量中放置 Windows 特定的路径):
因此 创建一个新的(空)存储库,并签出它的工作副本。第二行需要一些解释:它只是从当前目录创建存储库 URL。在我的工作区目录中,URL 如下所示:
好的,现在您已经有了工作副本,让我们创建示例目录结构和一些文件:
此时,我们已经有了示例目录和其中的两个文件。这是 find 的输出,不包括 subversion 的隐藏目录:
下一步是创建沙箱目录,并复制其中的两个目录:
这是重要的部分:我创建分支并复制到我的工作目录中,作为存储库的副本。通常,您只需使用带有两个存储库参数的 svn copy 将
trunk
复制到branches
的子级中。这在这里不起作用,因为我们只想要trunk
的两个子节点。完成此操作后,我的工作副本如下所示:
此时,您通常会将开发分支签入新的工作目录并在那里工作。所以我会这样做(在cd回到我的工作区目录之后):
现在进行一些更改:
好的,现在是时候合并回主干了。因此,返回工作区,仅检查主干:
并从沙箱中合并。合并过程在 中描述Subversion 文档:
最后一个命令应该显示只有文件
20/change.txt
受到合并的影响。由于您没有将 10 或 30 个目录复制到分支中,因此合并不会触及它们。If I read your question correctly, this is a simple matter of using svn copy to copy only the desired directories into a branch -- basically, a combination of answers from Mike Kushner and Ivan Krechetov. I think, however, it might be easier to understand after running through the steps yourself, so the rest of this post will create a sample repository and show the copies and merges.
I'm going to assume that you're using the "standard" repository layout, which at the top level has three sub-directories, trunk, branches, and tags. And that your 10, 20, 30, and 40 directories are under trunk. In other words:
And, as Mike pointed out, your goal will be to have a structure that looks like this:
It's unclear from your posting (at least as-of the current edit), but you may have a directory structure in which 10, 20, et al are at the top level. In this case, you'll need to create a new top-level directory, which I'll call dev, so that your overall repository looks like the following:
Note that you cannot create dev under 20. Well, physically you can, but you're almost guaranteed to break your build when doing so.
OK, so let's walk through an example, in which we create a new repository and put some files in it. You have to be able to run the svnadmin command (which you should be able to do, unless you have a paranoid sysadmin). So pick a temporary directory, and execute the following commands (I'm running Linux; if you're running Windows the commands will be the same, but you'll need to put a Windows-specific path in the REPO variable):
This creates a new (empty) repository, and checks out a working copy of it. The second line needs some explanation: it simply creates the repository URL from the current directory. In my workspace directory, the URL looks like this:
OK, now that you've got a working copy, let's create the sample directory structure and some files:
At this point we have the sample directories and two files in them. Here's the output from find, excluding subversion's hidden directories:
Next step is to create the sandbox directory, and make copies of the two directories that are going to be in it:
This is the important part: I creating the branch and copies in my working directory, as a copy from the repository. Normally, you just copy
trunk
into a child ofbranches
, using svn copy with two repository arguments. That doesn't work here, because we want only two children oftrunk
.After doing this, my working copy looks like this:
At this point, you'd normally check out the development branch into a new working directory and work there. So I'll do that (after a cd back to my Workspace directory):
And now make some changes:
OK, now it's time to merge back to the trunk. So go back to the workspace, and check out just the trunk:
And merge from the sandbox. The merge process is described in the Subversion docs:
That last command should show you that only the file
20/change.txt
was affected by the merge. Since you didn't copy the 10 or 30 directories into the branch, they won't be touched by the merge.你想要做的是在你的 svn 树中的某个地方创建一个“20”的副本,你可以与它来回合并。一个常见的结构是
当你想要更新“develop”时,你要么在沙箱下创建一个新的“20”分支,要么从20执行合并到develop。当您希望“开发”中的更改回到您的主干时,您可以以另一种方式合并。您的开发人员应该查看“develop”的副本(或基于“develop”创建自己的分支)
What you want to do is create a copy of "20" somewhere in your svn tree, which you can merge back and forth with. A common structure is
When you want to update "develop", you either create a new branch of "20" under sandboxes or perform a merge from 20 to develop. When you want the changes in "develop" back in your trunk you merge the other way. Your developers should check out a copy of "develop" (or create their own branches based on "develop")
据我所知,您无法使用当前拥有的存储库结构来做到这一点。
我建议你重组你的存储库,所以 10 & 20、40 和其他与代码相关的资产将移至新的一级文件夹下。这样您就可以避免这种情况,并简化获取代码相关资产的过程。
afaik you can't do it with the repository structure you currently have.
I suggest you restructure your repository, so 10 & 20, 40 & the other code related assets are moved under a new 1st level folder. This way you avoid this situation, and simplify being able to grab just the code related assets.
理想情况下,您应该在较低级别分支。即分支 20 不是主干。这样你就只对应该分支的内容进行分支。即你想要分支。
Ideally then you should branch at a lower level. i.e. branch 20 not trunk. That way you're only branching the content that should be branched. i.e. that you want branched.
您可以通过仅使工作副本的源代码子目录指向其分支来实现此目的。
进行更改,提交。然后,让我们合并到主干:
检查以确保一切正常:
然后提交。
完毕。
You can achieve that by making only the source code subdirectory of your working copy point to its branch.
Do the changes, commit. Then, let's merge to the trunk:
Review to make sure all's fine:
And then commit.
Done.
我们这样做:
在这个例子中,第 3 方程序集有自己的存储库。这样您就不会在每个分支和主干中维护不同的版本。顺便说一句,任何程序集的最新版本都会复制到每个程序集的“当前”文件夹中。这允许更新程序集,而无需更新所有项目中的引用。这在您的领域可能不是问题,但在我们的领域却是一个很大的痛苦。
另请注意,文档在层次结构中与主干和分支处于同一级别。这样这些文件就不会重复。如果这不是一个选项,那么它们也可以外部化,这将允许它们存在于主干和分支中,而无需单独进行源控制。
We do something like this:
In this example, the 3rd party assemblies have their own repository. This way you aren't maintaining different versions in each branch and trunk. As a side note, the latest version of any assembly is duplicated in the "Current" folder for each assembly. This allows the assembly to be updated without having to update references in all your projects. This may not be an issue in your domain, but it was a big pain in ours.
Also note that the documents are at the same level in the hierarchy as trunk and the branches. This way those files don't get duplicated. If this is not an option, those can be externaled as well, which would allow them to be present in the trunk and branches without being separately source controlled.
您构建项目的方式以及文档目录限制并不适合开箱即用的 SVN 模型。
一些想法:
svn:external
svn merge
),并让脚本强制执行规则The way you structure your project, along with the docs dir restrictions, doesn't fit with SVN's model out of the box.
Some ideas:
svn:external
svn merge
), and have the script enforce the rules从你的评论来看:
您是否考虑过在 svn:externals 中使用10 和 30 的 code>develop 分支?使用 ^/ 从根进行相对引用可能是一个好方法。
因此,虽然 10、20、30 和 40 可以在分支上访问,但 10 和 30 仍然可以从主干引用。然后,您可以根据需要定义您的授权需求。
From your comment:
Have you considered using svn:externals in the
develop
branch for 10 and 30? Relative referencing from root using ^/ would probably be a good approach.So whilst 10, 20, 30 and 40 would be accessible on the branch, 10 and 30 are still referenced from trunk. You can then define your authorization needs as required.