Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SVN部分分支_Svn_Branch - Fatal编程技术网

SVN部分分支

SVN部分分支,svn,branch,Svn,Branch,我是SVN的新手,所以这可能是一个简单的问题 我们有一个带有一级目录的“主干”: 10 <-- documents 20 <-- source code, db scripts, ... 30 <-- documents 40 <-- referenced 3rd party library-es temp, 531> find . | grep -v svn . ./tags ./trunk ./trunk/10 ./trunk/10/dontchange.tx

我是SVN的新手,所以这可能是一个简单的问题

我们有一个带有一级目录的“主干”:

10 <-- documents
20 <-- source code, db scripts, ...
30 <-- documents
40 <-- referenced 3rd party library-es
temp, 531> find . | grep -v svn
.
./tags
./trunk
./trunk/10
./trunk/10/dontchange.txt
./trunk/30
./trunk/20
./trunk/20/change.txt
./trunk/40
./branches

10您可以通过仅使工作副本的源代码子目录指向其分支来实现这一点

svn cp http://example.com/svnrepo/trunk/source_code http://example.com/svnrepo/branches/development/source_code

cd ./source_code
svn sw http://example.com/svnrepo/branches/development/source_code
进行更改,提交。然后,让我们合并到主干:

svn sw http://example.com/svnrepo/trunk/source_code
cd ..
svn merge -r [start_rev]:HEAD http://example.com/svnrepo/branches/development/source_code ./source_code
svn co ${REPO}/trunk trunk
cd trunk
检查以确保一切正常:

svn diff | less
然后提交。
完成。

您要做的是在svn树中的某个位置创建“20”的副本,您可以在其中来回合并。一个常见的结构是

repo
---> trunk
    ---> 10 
    ---> 20
    ---> 30
---> branches
    ---> sandboxes
        ---> develop <branch of 20>
---> tags
回购 --->树干 ---> 10 ---> 20 ---> 30 --->分支机构 --->沙箱 --->发展 --->标签

当您想要更新“develop”时,您可以在沙盒下创建一个新的“20”分支,或者执行从20到develop的合并。当您希望“开发”中的更改回到主干中时,您可以通过另一种方式进行合并。您的开发人员应该签出一份“develope”(或基于“develope”创建自己的分支)

理想情况下,您应该在较低级别上进行分支。i、 分支20不是主干。这样,您只会对应该分支的内容进行分支。i、 e.您希望分支。

如果您无法使用当前的存储库结构,则无法进行分支


我建议您重组您的存储库,以便将10&20、40&其他与代码相关的资产移动到新的第一级文件夹下。这样可以避免这种情况,并简化仅获取代码相关资产的过程。

我们可以这样做:

-repo: Assemblies
--SomeAssembly
---Current
---v1.0
---v1.1
-repo: Source
--trunk
---Code
---Assemblies (external from Assemblies repo)
--branches
---v1.0
----Code
----Assemblies (external from Assemblies repo)
--Documents
trunk
    10
    20
    30
    40
branches
    sandbox
        20
        40
tags
file:///home/kgregory/Workspace/temp.repo
temp, 539> find . | grep -v svn
.
./tags
./trunk
./trunk/10
./trunk/10/dontchange.txt
./trunk/30
./trunk/20
./trunk/20/change.txt
./trunk/40
./branches
./branches/sandbox
./branches/sandbox/20
./branches/sandbox/20/change.txt
./branches/sandbox/40
在本例中,第三方程序集有自己的存储库。这样,您就不会在每个分支和主干中维护不同的版本。作为旁注,任何程序集的最新版本都会复制到每个程序集的“当前”文件夹中。这允许更新程序集,而不必更新所有项目中的引用。这在你们的领域可能不是一个问题,但在我们的领域却是一个巨大的痛苦


还要注意,文档在层次结构中与主干和分支处于同一级别。这样这些文件就不会被复制。如果这不是一个选项,那么也可以将它们外部化,这将允许它们出现在主干和分支中,而无需单独进行源代码控制。

如果我正确理解了您的问题,这是一个简单的问题,即使用svn copy只将所需目录复制到分支中——基本上,Mike Kushner和Ivan Krechetov的答案组合。但是,我认为,在自己完成这些步骤之后,可能更容易理解,因此本文的其余部分将创建一个示例存储库,并显示副本和合并

我假设您使用的是“标准”存储库布局,它在顶层有三个子目录、主干、分支和标记。您的10、20、30和40个目录位于主干之下。换言之:

trunk
    10
    20
    30
    40
branches
tags
正如Mike指出的,你的目标是建立一个如下结构:

-repo: Assemblies
--SomeAssembly
---Current
---v1.0
---v1.1
-repo: Source
--trunk
---Code
---Assemblies (external from Assemblies repo)
--branches
---v1.0
----Code
----Assemblies (external from Assemblies repo)
--Documents
trunk
    10
    20
    30
    40
branches
    sandbox
        20
        40
tags
file:///home/kgregory/Workspace/temp.repo
temp, 539> find . | grep -v svn
.
./tags
./trunk
./trunk/10
./trunk/10/dontchange.txt
./trunk/30
./trunk/20
./trunk/20/change.txt
./trunk/40
./branches
./branches/sandbox
./branches/sandbox/20
./branches/sandbox/20/change.txt
./branches/sandbox/40
从你的帖子(至少在当前编辑时)看不清楚,但你可能有一个目录结构,其中10、20等处于顶层。在本例中,您需要创建一个新的顶级目录,我将其称为dev,以便您的整个存储库如下所示:

10
20
30
40
dev
    20
    40
请注意,您不能在20以下创建dev。好吧,从身体上来说你可以,但这样做几乎肯定会破坏你的身材

好的,让我们来看一个例子,在这个例子中,我们创建了一个新的存储库并在其中放置了一些文件。您必须能够运行svnadmin命令(您应该能够这样做,除非您有一个偏执狂系统管理员)。因此,选择一个临时目录,并执行以下命令(我运行的是Linux;如果您运行的是Windows,则这些命令将是相同的,但您需要在REPO变量中放置一个特定于Windows的路径):

这将创建一个新的(空)存储库,并签出它的工作副本。第二行需要一些解释:它只是从当前目录创建存储库URL。在我的工作区目录中,URL如下所示:

-repo: Assemblies
--SomeAssembly
---Current
---v1.0
---v1.1
-repo: Source
--trunk
---Code
---Assemblies (external from Assemblies repo)
--branches
---v1.0
----Code
----Assemblies (external from Assemblies repo)
--Documents
trunk
    10
    20
    30
    40
branches
    sandbox
        20
        40
tags
file:///home/kgregory/Workspace/temp.repo
temp, 539> find . | grep -v svn
.
./tags
./trunk
./trunk/10
./trunk/10/dontchange.txt
./trunk/30
./trunk/20
./trunk/20/change.txt
./trunk/40
./branches
./branches/sandbox
./branches/sandbox/20
./branches/sandbox/20/change.txt
./branches/sandbox/40
好的,现在您已经有了一个工作副本,让我们创建示例目录结构和一些文件:

cd temp
svn mkdir trunk
svn mkdir branches
svn mkdir tags
svn commit -m "standard repo structure"

pushd trunk
svn mkdir 10
svn mkdir 20
svn mkdir 30
svn mkdir 40
svn commit -m "example sub-project structure"

echo "this doesn't change" > 10/dontchange.txt
svn add 10/dontchange.txt
echo "this does change" > 20/change.txt
svn add 20/change.txt
svn status
svn commit -m "example files"
popd
此时,我们有示例目录和其中的两个文件。以下是find的输出,不包括subversion的隐藏目录:

10 <-- documents
20 <-- source code, db scripts, ...
30 <-- documents
40 <-- referenced 3rd party library-es
temp, 531> find . | grep -v svn
.
./tags
./trunk
./trunk/10
./trunk/10/dontchange.txt
./trunk/30
./trunk/20
./trunk/20/change.txt
./trunk/40
./branches
下一步是创建沙盒目录,并复制将要在其中的两个目录:

svn mkdir branches/sandbox
pushd branches/sandbox
svn copy ${REPO}/trunk/20 .
svn copy ${REPO}/trunk/40 .
svn commit -m "make development branch"
popd
这是重要的一部分:我在我的工作目录中创建分支和副本,作为存储库的副本。通常,您只需将
主干
复制到
分支
的子级,使用带有两个存储库参数的svn copy即可。这在这里不起作用,因为我们只需要两个
trunk
的孩子

执行此操作后,我的工作副本如下所示:

-repo: Assemblies
--SomeAssembly
---Current
---v1.0
---v1.1
-repo: Source
--trunk
---Code
---Assemblies (external from Assemblies repo)
--branches
---v1.0
----Code
----Assemblies (external from Assemblies repo)
--Documents
trunk
    10
    20
    30
    40
branches
    sandbox
        20
        40
tags
file:///home/kgregory/Workspace/temp.repo
temp, 539> find . | grep -v svn
.
./tags
./trunk
./trunk/10
./trunk/10/dontchange.txt
./trunk/30
./trunk/20
./trunk/20/change.txt
./trunk/40
./branches
./branches/sandbox
./branches/sandbox/20
./branches/sandbox/20/change.txt
./branches/sandbox/40
此时,您通常会将开发分支签出到一个新的工作目录中,并在那里工作。因此,我将这样做(在cd返回到我的工作区目录后):

现在做一些修改:

vi 20/change.txt
svn commit -m "changed on branch"
好的,现在是时候合并回主干了。因此,返回工作区,只查看主干:

svn sw http://example.com/svnrepo/trunk/source_code
cd ..
svn merge -r [start_rev]:HEAD http://example.com/svnrepo/branches/development/source_code ./source_code
svn co ${REPO}/trunk trunk
cd trunk
并从沙箱中合并。合并过程在以下章节中描述:


最后一个命令应该显示只有文件
20/change.txt
受合并影响。由于您没有将10或30个目录复制到分支中,因此合并不会触及它们。

您构建项目的方式以及docs dir限制不适合SVN的开箱即用模型

一些想法:

  • 将docs目录移到主干外,并将其添加为
    svn:external
  • 将docs目录移到trunk之外,并使用一个构建脚本将trunk和docs目录组合起来
  • 使用脚本进行合并(而不是直接
    svn Merge
    ),并让脚本强制执行规则
根据您的评论:

我们希望防止在10和30中修改文档。Th