将所有项目放在同一个主干中是个好主意吗?

时间:2023-01-13 12:07:45

We understand the default and usually recommended svn repository organization, in case of having multiple projects, is something like this:

我们理解默认的,通常推荐的svn存储库组织,如果有多个项目,则是这样的:

root/projectA/(trunk, branches, tags)
root/projectB/(trunk, branches, tags)
...

Our projects have a lot of interdependence, and that would demand an extense use of svn:externals between them, considering we don't do dll referencing to internal projects, we'd prefer to view their source code instead of working with binaries.

我们的项目有很多相互依赖性,这需要在它们之间大量使用svn:externals,考虑到我们没有参考内部项目,我们更愿意查看它们的源代码而不是使用二进制文件。

Using externals too much, when branching repositores, syncing changes, can become a complex and error-prone experience, so the team didn't trust this solution at all.

使用外部因素太多,在分支存储库时,同步更改可能会变成一种复杂且容易出错的体验,因此团队根本不相信这种解决方案。

So a team member suggested something that we all think this could be a better solution: put all projects in the same trunk.

因此,团队成员建议我们都认为这可能是一个更好的解决方案:将所有项目放在同一个主干中。

At first, we recognized some problems with this approach, but as a whole we agree these problems are based on hypotethical situations that very probably we'd never experience.

起初,我们认识到这种方法存在一些问题,但总的来说,我们同意这些问题是基于我们可能从未体验过的低位情况。

Do you see some serious problems we may have with this solution?

您是否看到我们对此解决方案可能遇到的一些严重问题?

4 个解决方案

#1


We do this at our company and have had a lot of success.

我们在公司做到这一点并取得了很大的成功。

We have 3 top level directories:

我们有3个*目录:

  • tags
  • branches
  • trunk

And then we have each project as a sub-directory of those.

然后我们将每个项目作为这些项目的子目录。

We still branch at the project level though and still use svn:externals. But if we had a smaller source tree we would branch at the trunk level and not use svn:extenrals.

我们仍然在项目级别进行分支,但仍使用svn:externals。但是如果我们有一个较小的源代码树,我们将在trunk级别进行分支,而不是使用svn:extenrals。

It's nice to be able to have all projects' trunk at the same place. You can back it up, you can check it all out and you have all the most recent stuff together. You don't lose the single location for all branches nor single location for all tags either because they are all in subdirectories of /branches/projectX and /tags/projectX

很高兴能够将所有项目的主干放在同一个地方。你可以备份它,你可以检查它,你可以将所有最新的东西放在一起。您不会丢失所有分支的单个位置,也不会丢失所有标记的单个位置,因为它们都位于/ branches / projectX和/ tags / projectX的子目录中

Problems with svn:externals:

svn:externals的问题:

If your projects are not extermely HUGE then you could just branch the whole trunk each time and avoid all of the problems with svn:externals.

如果您的项目不是非常大的,那么您每次都可以分支整个主干并避免svn:externals的所有问题。

The problem with svn:externals is that when you make a branch, it doesn't automatically create a branch for each of the svn:externals for you. This is a problem because then over time all of your old branches won't be able to compile as your trunk gets more updated. Another problem is that if you make a fix in any branch to an svn:external, all your other branches break.

svn:externals的问题在于,当你创建一个分支时,它不会为你自动为每个svn:externals创建一个分支。这是一个问题,因为随着时间的推移,所有旧分支将无法编译,因为您的主干更新。另一个问题是,如果你在svn:external的任何分支中进行修复,那么所有其他分支都会中断。

Another problem with svn externals is that when you do an svn:log at the root level, you don't see any changes from svn externals.

svn externals的另一个问题是,当您在根级别执行svn:log时,您看不到svn externals的任何更改。

Hopefully one day svn externals will be fixed to address the above problems, but until that day branching and svn:externals is an absolute nightmare.

希望有一天svn externals将被解决以解决上述问题,但直到那天分支和svn:externals是一个绝对的噩梦。

#2


What you've done is what I've set up at my company, and it is also referenced as a "very common layout" in the svnbook topic, Strategies for Repository Deployment.

你所做的就是我在我公司设置的内容,它也被引用为svnbook主题“存储库部署策略”中的“非常常见的布局”。

Nothing wrong with it.

它没有错。

#3


to "putting all projects into same trunk":

“将所有项目放入同一主干”:

From my experience this is no good idea - because each project has it's own history and changes and often projects are/will be maintained by different developers. This can lead to conflicts - even if you state out, that currently the projects interfere heavily.

根据我的经验,这不是一个好主意 - 因为每个项目都有自己的历史和变化,并且通常项目由不同的开发人员维护。这可能会导致冲突 - 即使您声明,目前项目会严重干扰。

So why don't you use common tags (with milestones as names to) for all of your projects to ensure a same code base and a build script, which can check out the projects (trunks) automagically? It's more work, but like usual in OOP (capsulation) I would prefer to split the projects into separate SVN directories, too.

那么为什么不为所有项目使用通用标记(里程碑作为名称)来确保相同的代码库和构建脚本,这可以自动检出项目(中继)?这是更多的工作,但与OOP(封装)中的通常情况一样,我更愿意将项目拆分为单独的SVN目录。

But: Collecting a bunch of small libs and apps into a common directory under the same trunk is no problem (see "apps" and "tools" in my example below) - so maybe "small projects" can stay in the shared/big trunk.

但是:将一堆小的lib和应用程序收集到同一主干下的公共目录中是没有问题的(请参阅下面的示例中的“apps”和“tools”) - 所以也许“小项目”可以保留在共享/大型主干中。

Here as example my directory structure of SVN:

这里举例说明我的SVN目录结构:

/projects/
/projects/CustomerA/
/projects/CustomerA/ProjectX/
/projects/CustomerA/ProjectX/trunk/
/projects/CustomerA/ProjectX/tags/
/projects/CustomerA/ProjectX/branches/
/thirdparty/
/thirdparty/ExtLibY/
/thirdparty/ExtLibZ/
/tools/
/tools/trunk/
/tools/tags/
/tools/branches/
/apps/
/apps/trunk/
/apps/tags/
/apps/branches/

So all of the external stuff is stored in /thirdparty/ and all internals (projects, tools, apps) have the subdirs:

所以所有的外部东西都存储在/ thirdparty /中,所有内部(项目,工具,应用程序)都有子目录:

/trunk/
/tags/    
/branches/

...like advised in the Subversion book and the previous post.

...就像在Subversion书和上一篇文章中所建议的那样。

Even if that looks a little bit much efforts at first sight - it is really worth it, especially when your code base grows.

即使这看起来有点乍一看 - 这确实是值得的,特别是当您的代码库增长时。

ciao, Chris

#4


Do you see some serious problems we may have with this solution?

您是否看到我们对此解决方案可能遇到的一些严重问题?

  • Your solution only works as long as you can put everything in a single repository.

    只有将所有内容放在单个存储库中,您的解决方案才有效。

    This means the entire repository has to fit on a single disk (or storage pool) for the foreseeable future. Similar considerations apply for other server resources like network and disk I/O bandwidth.

    这意味着在可预见的未来,整个存储库必须适合单个磁盘(或存储池)。类似的考虑也适用于其他服务器资源,如网络和磁盘I / O带宽。

    Splitting the repository later will require a big overhaul of your whole set-up, and might cause headaches when you need to rebuild or branch old versions.

    稍后拆分存储库将需要对整个设置进行大修,并且当您需要重建或分支旧版本时可能会导致令人头疼的问题。

  • Your solution only works if you don't need to limit read/write permissions on a per-user basis

    只有在不需要限制每个用户的读/写权限时,您的解决方案才有效

    If you need to give read/write permission for projectA, you'll actually have to give permission for /trunk/projectA, and /branch1/projectA, and /branch2/projectA etc.

    如果您需要为projectA提供读/写权限,您实际上必须授予/ trunk / projectA,/ branch1 / projectA和/ branch2 / projectA等权限。

    Branching then becomes a heavy-weight process that requires lots of permission tweaking. Say goodbye to feature branches.

    然后分支成为一个重量级的过程,需要大量的权限调整。告别功能分支。

#1


We do this at our company and have had a lot of success.

我们在公司做到这一点并取得了很大的成功。

We have 3 top level directories:

我们有3个*目录:

  • tags
  • branches
  • trunk

And then we have each project as a sub-directory of those.

然后我们将每个项目作为这些项目的子目录。

We still branch at the project level though and still use svn:externals. But if we had a smaller source tree we would branch at the trunk level and not use svn:extenrals.

我们仍然在项目级别进行分支,但仍使用svn:externals。但是如果我们有一个较小的源代码树,我们将在trunk级别进行分支,而不是使用svn:extenrals。

It's nice to be able to have all projects' trunk at the same place. You can back it up, you can check it all out and you have all the most recent stuff together. You don't lose the single location for all branches nor single location for all tags either because they are all in subdirectories of /branches/projectX and /tags/projectX

很高兴能够将所有项目的主干放在同一个地方。你可以备份它,你可以检查它,你可以将所有最新的东西放在一起。您不会丢失所有分支的单个位置,也不会丢失所有标记的单个位置,因为它们都位于/ branches / projectX和/ tags / projectX的子目录中

Problems with svn:externals:

svn:externals的问题:

If your projects are not extermely HUGE then you could just branch the whole trunk each time and avoid all of the problems with svn:externals.

如果您的项目不是非常大的,那么您每次都可以分支整个主干并避免svn:externals的所有问题。

The problem with svn:externals is that when you make a branch, it doesn't automatically create a branch for each of the svn:externals for you. This is a problem because then over time all of your old branches won't be able to compile as your trunk gets more updated. Another problem is that if you make a fix in any branch to an svn:external, all your other branches break.

svn:externals的问题在于,当你创建一个分支时,它不会为你自动为每个svn:externals创建一个分支。这是一个问题,因为随着时间的推移,所有旧分支将无法编译,因为您的主干更新。另一个问题是,如果你在svn:external的任何分支中进行修复,那么所有其他分支都会中断。

Another problem with svn externals is that when you do an svn:log at the root level, you don't see any changes from svn externals.

svn externals的另一个问题是,当您在根级别执行svn:log时,您看不到svn externals的任何更改。

Hopefully one day svn externals will be fixed to address the above problems, but until that day branching and svn:externals is an absolute nightmare.

希望有一天svn externals将被解决以解决上述问题,但直到那天分支和svn:externals是一个绝对的噩梦。

#2


What you've done is what I've set up at my company, and it is also referenced as a "very common layout" in the svnbook topic, Strategies for Repository Deployment.

你所做的就是我在我公司设置的内容,它也被引用为svnbook主题“存储库部署策略”中的“非常常见的布局”。

Nothing wrong with it.

它没有错。

#3


to "putting all projects into same trunk":

“将所有项目放入同一主干”:

From my experience this is no good idea - because each project has it's own history and changes and often projects are/will be maintained by different developers. This can lead to conflicts - even if you state out, that currently the projects interfere heavily.

根据我的经验,这不是一个好主意 - 因为每个项目都有自己的历史和变化,并且通常项目由不同的开发人员维护。这可能会导致冲突 - 即使您声明,目前项目会严重干扰。

So why don't you use common tags (with milestones as names to) for all of your projects to ensure a same code base and a build script, which can check out the projects (trunks) automagically? It's more work, but like usual in OOP (capsulation) I would prefer to split the projects into separate SVN directories, too.

那么为什么不为所有项目使用通用标记(里程碑作为名称)来确保相同的代码库和构建脚本,这可以自动检出项目(中继)?这是更多的工作,但与OOP(封装)中的通常情况一样,我更愿意将项目拆分为单独的SVN目录。

But: Collecting a bunch of small libs and apps into a common directory under the same trunk is no problem (see "apps" and "tools" in my example below) - so maybe "small projects" can stay in the shared/big trunk.

但是:将一堆小的lib和应用程序收集到同一主干下的公共目录中是没有问题的(请参阅下面的示例中的“apps”和“tools”) - 所以也许“小项目”可以保留在共享/大型主干中。

Here as example my directory structure of SVN:

这里举例说明我的SVN目录结构:

/projects/
/projects/CustomerA/
/projects/CustomerA/ProjectX/
/projects/CustomerA/ProjectX/trunk/
/projects/CustomerA/ProjectX/tags/
/projects/CustomerA/ProjectX/branches/
/thirdparty/
/thirdparty/ExtLibY/
/thirdparty/ExtLibZ/
/tools/
/tools/trunk/
/tools/tags/
/tools/branches/
/apps/
/apps/trunk/
/apps/tags/
/apps/branches/

So all of the external stuff is stored in /thirdparty/ and all internals (projects, tools, apps) have the subdirs:

所以所有的外部东西都存储在/ thirdparty /中,所有内部(项目,工具,应用程序)都有子目录:

/trunk/
/tags/    
/branches/

...like advised in the Subversion book and the previous post.

...就像在Subversion书和上一篇文章中所建议的那样。

Even if that looks a little bit much efforts at first sight - it is really worth it, especially when your code base grows.

即使这看起来有点乍一看 - 这确实是值得的,特别是当您的代码库增长时。

ciao, Chris

#4


Do you see some serious problems we may have with this solution?

您是否看到我们对此解决方案可能遇到的一些严重问题?

  • Your solution only works as long as you can put everything in a single repository.

    只有将所有内容放在单个存储库中,您的解决方案才有效。

    This means the entire repository has to fit on a single disk (or storage pool) for the foreseeable future. Similar considerations apply for other server resources like network and disk I/O bandwidth.

    这意味着在可预见的未来,整个存储库必须适合单个磁盘(或存储池)。类似的考虑也适用于其他服务器资源,如网络和磁盘I / O带宽。

    Splitting the repository later will require a big overhaul of your whole set-up, and might cause headaches when you need to rebuild or branch old versions.

    稍后拆分存储库将需要对整个设置进行大修,并且当您需要重建或分支旧版本时可能会导致令人头疼的问题。

  • Your solution only works if you don't need to limit read/write permissions on a per-user basis

    只有在不需要限制每个用户的读/写权限时,您的解决方案才有效

    If you need to give read/write permission for projectA, you'll actually have to give permission for /trunk/projectA, and /branch1/projectA, and /branch2/projectA etc.

    如果您需要为projectA提供读/写权限,您实际上必须授予/ trunk / projectA,/ branch1 / projectA和/ branch2 / projectA等权限。

    Branching then becomes a heavy-weight process that requires lots of permission tweaking. Say goodbye to feature branches.

    然后分支成为一个重量级的过程,需要大量的权限调整。告别功能分支。