简体   繁体   English

具有不同svn存储库的不同项目中的代码管理

[英]Code management in different projects with different svn repositories

First of all I want to tell you what kind of system I have and I want to build on. 首先,我想告诉你我有什么样的系统,我想要建立。

1- A Solution (has)
   a- Shared Class Library project (which is for lots of different solutions)
   b- Another Class Library project (which is only for this solution)
   c- Web Application project (which main part of this solution)
   d- Shared Web Service project (which also serves for different solutions)

2- B Solution (has)
   a- Shared Class Library project (which is for lots of different solutions)
   c- Windows Form Application project (which is main part of this solution)
   d- Web Service project (which also serves for different solutions)

and other projects like that.... 和其他类似的项目......

I am using xp-dev.com as our svn repository server. 我使用xp-dev.com作为我们的svn存储库服务器。 And I opened different projects for these items ( Shared Class Library, Web Service project, Windows Form Application project, Web Application project, Another Class Library project ) . 我为这些项目打开了不同的项目( 共享类库,Web服务项目,Windows窗体应用程序项目,Web应用程序项目,另一个类库项目 )。

I want to do the versioning of all these projects of course. 我当然希望对所有这些项目进行版本控制。

My first question is, should I put each project(one solution) to one svn repository to get their revision number later on? 我的第一个问题是,我是否应该将每个项目(一个解决方案)放到一个svn存储库中以便稍后获取其修订版号?

Or should I put each of them to different svn repository and keep( write down) their correct version number that is used to publish/deploy every solution? 或者我应该将它们中的每一个放到不同的svn存储库中并保留(写下)用于发布/部署每个解决方案的正确版本号? 替代文字

If I use one svn for each project(Shared Class Lib, Web App, Shared Web Service....) how can I relate the right svn address and version on VS.2010 within the real solution? 如果我为每个项目使用一个svn(共享类库,Web应用程序,共享Web服务......),如何在真实解决方案中将VS.2010上的正确svn地址和版本关联起来? 替代文字

So, how do you manage your repositories and projects? 那么,您如何管理您的存储库和项目?

I believe the correct solution to this is tagging. 我相信对此的正确解决方案是标记。 I don't believe it's a good idea to separate your solution across different repositories. 我不相信将您的解决方案分隔到不同的存储库是个好主意。 It's advisable to keep all projects that are even slightly related in the same repository, and use a standard repository layout, ie: 建议在同一个存储库中保留所有甚至略有相关的项目,并使用标准的存储库布局,即:

/branches /枝
/tags /标签
/trunk /树干

With all your working solution folders described above in /trunk. 使用上面描述的所有工作解决方案文件夹在/ trunk中。 Trunk can contain as many projects/solutions as you feel is manageable, and could even be further organized by project type. Trunk可以包含您认为可管理的项目/解决方案,甚至可以按项目类型进一步组织。 One of my trunk folders is /trunk/websites and I keep all my website solutions in there. 我的一个主干文件夹是/ trunk / website,我将所有的网站解决方案保存在那里。

When you are ready for a release version, you can "tag" your trunk, or part of your trunk, with that release or build version, using "Branch/Tag" over to /tags/ This affords you an opportunity to also record your release notes in the tagged copy. 当您准备好发布版本时,您可以使用“分支/标记”覆盖/标记/“标记”您的主干或部分主干,这样您就有机会记录您的在标记的副本中发布说明。

For more information on branching and tagging in SVN (assuming Tortoise) see Branching / Tagging in the TortiseSVN docs. 有关SVN中的分支和标记的更多信息(假设Tortoise),请参阅TortiseSVN文档中的分支/标记

For more info on these terms, see this question in StackOverflow. 有关这些术语的更多信息, 请参阅 StackOverflow中的此问题

I hope this is helpful. 我希望这是有帮助的。 I do not know what limitations, you may be faced with from your SVN host. 我不知道您的SVN主机可能面临的限制。 These suggestions are based on my experiance in hosting my own VisualSVN Server repository. 这些建议是基于我在托管我自己的VisualSVN Server存储库方面的经验。

I came to SVN from SourceSafe, and it took me some time to see the value in this standard, and to begin using these practices. 我从SourceSafe来到SVN,花了一些时间才看到这个标准的价值,并开始使用这些实践。 They are invaluable to me now. 它们对我来说非常宝贵。

Another approach you can take to this is using the Subversion externals property to be able to manage your code, either in separate repositories or in a single repository. 您可以采用的另一种方法是使用Subversion externals属性来管理您的代码,可以在单独的存储库中,也可以在单个存储库中。 The advantage is that you can simply update the URLs in question when you need a new release of the shared code in your solution. 优点是,当您需要在解决方案中使用新版本的共享代码时,您可以简单地更新相关URL。

Note : I don't remember jack about the Visual Studio solution and project organization; 注意 :我不记得关于Visual Studio解决方案和项目组织的杰克; it's been at least 5 years since I've done any Windows development. 自从我完成任何Windows开发以来至少已有5年了。 That being said, this discussion is applicable no matter what the file/directory layout is. 话虽这么说,无论文件/目录布局是什么,这个讨论都适用。 I'm going to make one up and please just adjust it to your actual situation. 我打算做一个,请根据你的实际情况进行调整。

Lets assume you have one big repository that has all your related projects in it. 让我们假设您有一个大型存储库,其中包含所有相关项目。 If you think that isn't necessarily scalable, I'd suggest taking a look at the Apache projects SVN setup ; 如果你认为这不一定是可扩展的,我建议看看Apache项目的SVN设置 ; they have all the projects in one repository. 他们将所有项目都放在一个存储库中。 Taking a page from the ASF, let's start out the repository structure as follows: 从ASF获取页面,让我们按如下方式开始存储库结构:

/SolutionA/trunk
/SolutionA/tags
/SolutionA/branches

/SolutionB/trunk
/SolutionB/tags
/SolutionB/branches

/SharedClassLib/trunk
/SharedClassLib/tags
/SharedClassLib/branches

/SharedWebService/trunk
/SharedWebService/tags
/SharedWebService/branches

So far this is just a standard SVN layout; 到目前为止,这只是一个标准的SVN布局; each more-or-less independent entity has its own area of the repository to play with. 每个或多或少的独立实体都有自己的存储库区域。 Now, lets assume you've been developing away on the SharedClassLib and you are up to version 2.0.0, and on the SharedWebService you are on version 1.2.5. 现在,让我们假设您已经开始使用SharedClassLib,并且您的版本为2.0.0,而在SharedWebService上您使用的是版本1.2.5。 The directory layout will look something like: 目录布局如下所示:

/SharedClassLib/tags/1.0.0
/SharedClassLib/tags/1.5.0
/SharedClassLib/tags/2.0.0

/SharedWebService/tags/1.0.0
/SharedWebService/tags/1.2.0
/SharedWebService/tags/1.2.5

The other tags are just for illustration of the fact that your development has been marching on over time and you've had multiple releases. 其他标签只是为了说明您的开发一直在不断发展并且您已经有多个版本。

Now, back in SolutionA, you have a LocalClassLibrary project and a LocalWebApp project. 现在,回到SolutionA,您有一个LocalClassLibrary项目和一个LocalWebApp项目。 These projects are strictly part of this solution are are not shared outside of this solution. 这些项目严格地是此解决方案的一部分,不在此解决方案之外共享。 Taking a stab at a directory layout, your trunk might look something like: 在目录布局中进行攻击,您的主干可能看起来像:

/SolutionA/trunk/SolutionA/<some_solution_level_files>
/SolutionA/trunk/SolutionA/LocalClassLibrary/<some_project_level_files>
/SolutionA/trunk/SolutionA/LocalWebApp/<some_project_level_files>

So, our problem is, how do we get the SharedClassLib and SharedWebService into our SolutionA? 所以,我们的问题是,我们如何将SharedClassLib和SharedWebService纳入我们的SolutionA? By using Subversion externals. 通过使用Subversion外部。 Read the externals web page first, then come back here. 首先阅读外部网页,然后回到这里。

To make your life a little easier, I'd suggest creating a svn.externals file in your solution directory to set the svn:externals property if you are doing this from the command line. 为了让您的生活更轻松,我建议您在解决方案目录中创建一个svn.externals文件,以便在从命令行执行此操作时设置svn:externals属性。 If you are using some other tool, just keep in mind that in this case, you are going to need to add multiple lines. 如果您正在使用其他工具,请记住,在这种情况下,您将需要添加多行。 The file will look like: 该文件将如下所示:

SharedClassLib         http://your.svn.server/SharedClassLib/tags/2.0.0
SharedWebService       http://your.svn.server/SharedWebService/tags/1.2.5

Edit 1 : At this point, you can see that the URLs you are referring to are fully qualified. 编辑1 :此时,您可以看到您引用的URL是完全限定的。 Meaning that they can be separate repositories, and you don't have to use the layout I've described here. 这意味着它们可以是单独的存储库,您不必使用我在此描述的布局。 Additionally, if you are at an intermediate stage in your development and you need the latest, bleeding edge, development version of your shared code, use an URL like http://your.svn.server/SharedClassLib/trunk . 此外,如果您处于开发的中间阶段,并且需要最新的,前沿的共享代码开发版本,请使用http://your.svn.server/SharedClassLib/trunk类的URL。 At some point, however, you are going to want to settle on a sable version of the external code before you tag and release your solution. 但是,在某些时候,在标记和发布解决方案之前,您将需要确定外部代码的黑貂版本。

Edit 2 : Note that this is the pre-1.5 svn syntax. 编辑2 :请注意,这是1.5之前的svn语法。 It has changed a bit in 1.5 它在1.5中有所改变

Do an svn propset svn:externals -F svn.externals . 做一个svn propset svn:externals -F svn.externals . in your solution directory, then svn commit && svn update . 在您的解决方案目录中,然后svn commit && svn update At this point svn will populate your working copy with the contents of those URLS. 此时,svn将使用这些URL的内容填充您的工作副本。 Your working copy would look something like: 您的工作副本看起来像:

./SolutionA/svn.externals
./SolutionA/<some_solution_level_files>
./SolutionA/LocalClassLibrary/<some_project_level_files>
./SolutionA/LocalWebApp/<some_project_level_files>
./SolutionA/SharedClassLibrary/<some_project_level_files>
./SolutionA/SharedWebApp/<some_project_level_files>

When you need to bring in new versions of the shared projects, update the svn:externals property appropriately. 当您需要引入共享项目的新版本时,请相应地更新svn:externals属性。 Please note, there are some caveats to this approach, and are detailed in the SVN externals documentation. 请注意,这种方法有一些注意事项,并在SVN外部文档中有详细说明。 Mainly, don't plan on being able to make changes in ./SolutionA/SharedClassLibrary and expect the changes to be magically picked up when you do a commit in SolutionA. 主要是,不打算能够在./SolutionA/SharedClassLibrary中进行更改,并期望在SolutionA中提交时可以神奇地获取更改。

Now you are ready to release SolutionA to the world. 现在您已准备好向全世界发布SolutionA。 Just create the appropriate tag (svn copy) of the trunk to the tags directory: 只需在trunk目录中创建trunk的相应标记(svn copy):

/SolutionA/tags/1.0.0

Now your SolutionA will have it's own code at the correct tag/version, and you are using the right version of the shared projects for that release. 现在,您的SolutionA将在正确的标记/版本上拥有自己的代码,并且您正在为该版本使用正确版本的共享项目。

Obviously, the same discussion applies to SolutionB. 显然,同样的讨论适用于SolutionB。

I haven't worked with SVN in a while, so my apologies if I've gotten any of the above a little bit wrong. 我有一段时间没有和SVN合作过,所以如果我上面的任何一点有点不对,我很抱歉。

My advise will be to put in the same repository projects with the same lifecycle. 我的建议是将相同的生命周期放入相同的存储库项目中

Let's take your A scenario. 我们来看看你的场景吧。 We have: 我们有:

  1. Shared Class Library project (which is for lots of different solutions) 共享类库项目(适用于许多不同的解决方案)
  2. Another Class Library project (which is only for this solution) 另一个类库项目(仅适用于此解决方案)
  3. Web Application project (which main part of this solution) Web应用程序项目(该解决方案的主要部分)
  4. Shared Web Service project (which also serves for different solutions) 共享Web服务项目(也适用于不同的解决方案)

That'll make one repository for 2 & 3 which are different projects of the same solution (hence with the same life cycle): 这将为2和3创建一个存储库,它们是同一解决方案的不同项目(因此具有相同的生命周期):

/solution-A/trunk/ClassLib
/solution-A/trunk/WebApp
/solution-A/tags/1.0.0/ClassLib
/solution-A/tags/1.0.0/WebApp

And one repository for 1 & another for 4 assuming that they have different life cycles. 假设他们有不同的生命周期,一个存储库为1,另一个为4。

/library-A/trunk/ShClassLib
/library-A/tags/1.0.0/ShClassLib
/library-B/trunk/ShWebService
/library-B/tags/1.0.0/ShWebService

Now depending on the subject on which a developer is working he can check out either the trunk, a tag (read only) or a branch. 现在,根据开发人员正在使用的主题,他可以检查主干,标签(只读)或分支。 For instance a developer working on the solution using released libraries will check out the trunk of the solution and the right tags for the libraries. 例如,使用已发布的库处理解决方案的开发人员将检查解决方案的主干和库的正确标签。 The same one requiring the next versions of the libraries will check out the trunk (or a branch) for the libraries, etc. 需要下一版本库的同一个将检查库的主干(或分支)等。

Of course it'll be probably better to have a build/release system able to deliver binary releases for the libraries as well as nightly builds. 当然,拥有一个能够为库和夜间构建提供二进制版本的构建/发布系统可能会更好。

There's really not much to say about Visual Studio support because using Subversion and Tortoise don't work inside of Visual Studio. 关于Visual Studio支持真的没什么可说的,因为使用Subversion和Tortoise在Visual Studio中不起作用。 When you're dealing with projects and solutions you might want to carefully consider whether project and solution settings affect other users. 在处理项目和解决方案时,您可能需要仔细考虑项目和解决方案设置是否会影响其他用户。 If your local paths are not the same as the projects in the repository for example, you may have to check out the project and solution files and leave them checked out permanently. 例如,如果您的本地路径与存储库中的项目不同,则可能必须签出项目和解决方案文件并将其永久签出。

For Web applications often the web.config file might require some careful consideration if there are machine specific settings in the file. 对于Web应用程序,如果文件中存在特定于计算机的设置,则可能需要仔细考虑web.config文件。 For example, if you're running IIS 7 and you download a project that's was created with IIS 6 the project file will be changed potentially to point at system module and handler references in different locations. 例如,如果您正在运行IIS 7并且下载了使用IIS 6创建的项目,则项目文件可能会更改为指向不同位置的系统模块和处理程序引用。 Or you may have a connection string pointing to a different server than the original web.config file. 或者,您可能有一个连接字符串指向与原始web.config文件不同的服务器。 Here too the solution is to download the file originally and then keep the file checked out locally and remember not to update it. 这里的解决方案也是最初下载文件,然后在本地检出文件并记住不要更新它。

My sincere suggestion is to put the projects into same repository; 我真诚的建议是把项目放到同一个库中; it's easy to find and backup. 它很容易找到和备份。 But the key thing to remember when creating new branches and adding new files in the repository is: 但是在创建新分支并在存储库中添加新文件时要记住的关键是:

Create Folder in Repository first 首先在存储库中创建文件夹

Checkout just the Folder to your local folder 只将文件夹签出到本地文件夹

Add Files with Tortoise in Explorer 在资源管理器中添加Tortoise文件

Commit changes 提交更改

Side note: 边注:

If you prefer to have Visual Studio integration for source control you can check out VisualSvn which provides integration with TortoiseSVN directly from within Visual Studio. 如果您希望将Visual Studio集成用于源代码控制,则可以查看VisualSvn ,它直接从Visual Studio中提供与TortoiseSVN的集成。 Visual SVN works with your existing Subversion folders so it doesn't use Visual Studio version control provider (a good thing IMHO). Visual SVN适用于您现有的Subversion文件夹,因此它不使用Visual Studio版本控制提供程序(恕我直言)。 Rather it talks to the TortoiseSVN APIs and gets its data directly from the file store. 而是与TortoiseSVN API对话并直接从文件存储中获取数据。 I haven't used Visual SVN for long but so far it looks nice, although I've gotten so used to using Explorer for source control it doesn't help significantly to have the integration. 我没有使用Visual SVN很长时间,但到目前为止它看起来不错,虽然我已经习惯使用资源管理器进行源代码控制,但它对于集成并没有多大帮助。

One thing that's definitely easier is creation of new projects – you can just use Add to Subversion and VSVN will take care of creating the branch and checking out the files for you. 有一件事情肯定更容易创建新项目 - 您可以使用Add to Subversion,VSVN将负责创建分支并为您检出文件。

It's definitely nice to see the status of files right in the IDE and it's also nice if you frequently add new files to the system as VSVN knows about Visual Studio file associations and automatically adds all related files. 在IDE中查看文件的状态非常好,如果您经常向系统添加新文件,这也很好,因为VSVN知道Visual Studio文件关联并自动添加所有相关文件。

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

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