SVN将重命名的项目合并到主干中

发布于 2024-10-26 11:06:30 字数 827 浏览 2 评论 0原文

我目前正在尝试将分支中的一些更改合并回主干,分支中的更改会破坏主干中每个项目的名称。因此,为了简单起见,我们可以说主干的根看起来像这样...

company-name-services
company-name-security
company-name-web

分支看起来像这样...

services
security
web

在分支中运行以下命令,以便使其进入当前状态...

svn mv company-name-services services
svn mv company-name-security security
svn mv company-name-web web

之后的代码更改分枝和主干均发生过。现在我正在执行合并,在主干的工作副本中,我使用 Tortoise SVN 进行合并,选择“重新集成分支”作为合并类型,并选择分支的路径作为运行的结果“来自 URL”我现在在我的工作副本中拥有这个...

company-name-services
company-name-security
company-name-web    
services
security
web

文件夹company-name-*被标记为删除,其他去品牌文件夹被标记为添加。问题是去品牌项目文件夹中的所有文件都没有与其关联的历史信息,甚至在主干中发生的更糟糕的更改也不存在于去品牌文件夹中。我认为 SVN 足够智能,可以从主干引入更改,并在合并后保留历史记录,因为文件夹是使用 svn 命令行工具重命名的。我收到的结果是否符合预期,或者我应该通过其他方式执行合并?

I'm currently trying to merge some changes from a branch back into the trunk, the changes in the branch debrand the name of each project in the trunk. So for simplicities sake lets say the root of the trunk looks like this...

company-name-services
company-name-security
company-name-web

and the branch looks like so...

services
security
web

The following commands were run in the branch in order to get it into its current state...

svn mv company-name-services services
svn mv company-name-security security
svn mv company-name-web web

Following that code changes have occured in both the branch and the trunk. Now that I'm performing the merge, within my working copy for the trunk I have used Tortoise SVN to merge selecting 'Reintegrate a branch' as merge type and selecting the path to the branch as the 'From URL' as a result of running this I now have in my working copy...

company-name-services
company-name-security
company-name-web    
services
security
web

Folders company-name-* are marked for deletion and the other debranded folders are marked to be added. The problem being all files in the debranded project folders have no history infomation associated with them, and even worse changes that have occured in the trunk are not present in the debranded folders. I thought SVN would be intelligent enough to bring in changes from trunk and preserve history after a merge given that the folders were renamed using the svn command line tool. Are the results I'm reciving to be expected or is there some other way I should be performing the merge?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笙痞 2024-11-02 11:06:30

要理解为什么会发生这种情况,你必须了解 svn 是如何进行合并的。

当您将分支合并回主干时,您实际上将分支中所做的每个更改合并到主干中。合并时,svn 将从分支中获取每个提交,并逐一对主干执行相同的更改。

由于您对分支所做的第一个更改(也可能是第一个提交)是重命名根目录,因此 svn 将在主干上执行相同的操作。

我相信您可以通过手动将分支中的每个子文件夹合并到主干中相应的子文件夹来克服这个问题。我不知道 Tortois 的命令,但命令行会像这样(假设您从 trunk 中的根文件夹开始):

> cd company-name-services
> svn merge -r <insert first revision after rename>:HEAD <insert url to sub-folder in branch> .

对于每个子文件夹依此类推

To understand why this happened you have to understand how svn does merging.

When you merge your branch back into trunk you actually merge every change that was done in the branch into trunk. When merging, svn will take every commit from your branch and, one by one, perform the same changes to your trunk.

Since the first change and probably the first commit you did to your branch was to rename the root directories, svn will do the same on trunk.

I believe you can overcome this by manually merge each sub-folder from your branch to the corresponding sub-folder in your trunk. I don't know the Tortois commands for this, but the command line would be like this (assuming you start on the root folder in trunk):

> cd company-name-services
> svn merge -r <insert first revision after rename>:HEAD <insert url to sub-folder in branch> .

and so on for each sub-folder

天气好吗我好吗 2024-11-02 11:06:30

svn mv 是创建分支的错误方法;那做了一个动作。您应该使用svn cp,它将主干的副本复制到分支中。或者,您还应该首先使用 TortoiseSVN 创建分支,然后再次使用它来进行合并。

您所做的是将主干移动到分支,在分支上工作,然后将分支移回主干。没有单独的历史记录需要维护。

请参阅 SVN 书籍,特别是第 4 章,分支和合并,小标题创建分支

svn mv was the incorrect way to create the branches; that does a move. You should have used svn cp, which makes a copy of the trunk into the branch. Alternatively, you should have also used TortoiseSVN to create the branches first, and then used it again to do the merge.

What you did was move the trunk to the branch, work on the branch, and then moved the branch back to the trunk. There is no separate history to maintain.

See the SVN book, specifically Chapter 4, Branching and Merging, sub-heading Creating a Branch.

琉璃繁缕 2024-11-02 11:06:30

很抱歉在答案中回复,我还没有所需的代表来发表评论。

@Ken我可能在我的帖子中没有说清楚,我没有使用 svn mv 来创建分支,我使用 Tortoise 来分支发出一个命令,我相信该命令相当于这样的命令。 在命令行上,

svn cp http://my.server/repos/myRepo/trunk \
    http://my.server/repos/myRepo/branches/my-branch 

然后从分支内发出 svn mv 命令来重命名存储库根目录中的文件夹。

@sstendal 早上上班时我会尝试你的建议并回复结果。

Apologies for replying in an answer I don't have the required rep to comment yet.

@Ken I may have not been clear in my post, I did not use svn mv to create the branch I used Tortoise to branch issueing a command which I believe would be the equivalent to something like this...

svn cp http://my.server/repos/myRepo/trunk \
    http://my.server/repos/myRepo/branches/my-branch 

on the command line, then from within the branch I issued the svn mv commands to rename the folders in the root of the repository.

@sstendal I'll try your suggestion when I get to work in the morning and reply with the outcome.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文