SVN合并一个从一个目录添加的目录(没有目录内容) [英] SVN merge just a directory add from a checkin (without directory contents)

查看:271
本文介绍了SVN合并一个从一个目录添加的目录(没有目录内容)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从一个目录中的一个目录(从一个分支)合并到一个不存在于trunk上的文件。这是一个例子:



中继线(从我们分支)

  / 
/root1.txt
/foo/foo1.txt

分支(2次签入后)

  / 
/root1.txt
/ foo /foo1.txt
/bar/bar1.txt
/bar/bar2.txt

首次签到:

  A / bar 
A /bar/bar1.txt

第二次签入:

  A /bar/bar2.txt 

假设中继没有改变,是否可以得到 /bar/bar2.txt进入中继线?以下是我已经尝试的解决方案:

  svn merge -rX:X + 1 / path / to / branch / bar。 - >没有任何东西合并在这里
svn merge -rX + 1:X + 2 / path / to / branch / bar。 - >将bar2.txt拉入trunk,但不在bar目录下
svn merge -rX:X + 1 / path / to / branch。 - >将两个目录和bar1.txt拉入trunk

svn copy / path / to / branch / bar。 - >递归地将目录栏复制到中继线

mkdir / path / to / trunk / bar
svn add bar
svn merge -rX + 1:X + 2 / path / to / branch / bar bar /

这里的最终解决方案的作品。它允许我只能将bar2.txt拉入中继线并继续,但是当我尝试将我的分支重新集成到trunk后,然后在目录中获得树冲突(目录在两个地方添加 - >'local add,incoming我明白,如果我的团队会做更精细的粒度检查,即将目录添加到单个提交中,并将文件添加到另一个文件中,那么我就可以可以合并,因为我正在尝试以上。这是唯一的解决方案吗?


  1. 似乎SVN允许您将分支中的各个文件合并到中继线中,因此可以使用单个dirctories(非递归) ?

  2. 在上面找到的部分解决方案中,我可以将分支中的目录标记为独立于同时签入的其他文件中继到中继,以便我不会得到树的冲突?

谢谢!

解决方案

尝试这样:

  svn merge http:// url / to / trunk / bar http:// url / to / branch / bar bar / 

如果您将所有合并命令视为简单应用差异,这将更容易。将 svn help merge 的输出与 svn help diff 的输出进行比较 - 它们非常相似。一旦你找出了可以产生你需要的变更集的 svn diff 命令,将其应用于正确的目录,然后设置!



所以在你的情况下,你需要的是分支上的bar / on trunk和bar /之间的区别,应用于本地(trunk)版本的bar。



编辑:如果在主干中还没有条形码/条形码,那么一个简单的svn复制操作就可以做到:

  svn copy http:// url / to / branch / bar http:// url / to / trunk / bar -m'merging new directory bar /'

(请注意,目标是svn存储库本身,而不是工作副本。)


Am trying to merge (from a branch) a file in a directory that does not yet exist on trunk. Here is the example:

Trunk (from which we branch)

/
/root1.txt
/foo/foo1.txt

Branch (after 2 checkins)

/
/root1.txt
/foo/foo1.txt
/bar/bar1.txt
/bar/bar2.txt

First checkin:

A  /bar
A  /bar/bar1.txt

Second checkin:

A  /bar/bar2.txt

Assuming the trunk hasn't changed, is it possible to get only /bar/bar2.txt into the trunk? Here are the solutions I have tried already:

svn merge -rX:X+1 /path/to/branch/bar .  --> nothing gets merged here
svn merge -rX+1:X+2 /path/to/branch/bar .  --> pulls bar2.txt into the trunk but not within bar directory
svn merge -rX:X+1 /path/to/branch .      --> pulls both directory and bar1.txt into trunk

svn copy /path/to/branch/bar .           --> recursively copies directory bar into trunk

mkdir /path/to/trunk/bar
svn add bar
svn merge -rX+1:X+2 /path/to/branch/bar bar/

The final solution here kind of works. It allows me to only pull in bar2.txt into the trunk and continue but when I try to reintegrate my branch back into trunk later, you then get tree conflicts on the directory (directory gets added in both places -> 'local add, incoming add upon merge').

I understand that if my team would do finer grain check ins - i.e. add the directory in a single commit and the files in another - then I could merge as I am trying to above. Is that the only solution?

  1. It seems like SVN allows you to merge individual files from a branch into the trunk so is it possible with individual dirctories (non-recursively)?
  2. In the partial solution I found above, can I mark the directory in the branch as merged to the trunk independently of the other files that were checked in at the same time so that I don't get the tree conflict?

Thanks!

解决方案

Try this:

svn merge http://url/to/trunk/bar http://url/to/branch/bar bar/

It's easier if you think of all merge commands as simply applying a diff. Compare the output of svn help merge to svn help diff -- they're very similar. Once you have figured out the svn diff command that will produce exactly the changeset you need, apply that to the correct directory and you're set!

So in your case, what you need is the difference between bar/ on trunk and bar/ on the branch, applied to the local (trunk) version of bar.

Edit: and in the case where bar/ does not yet exist in trunk, a simple svn copy operation will do the trick:

svn copy http://url/to/branch/bar http://url/to/trunk/bar -m'merging new directory bar/'

(Note that the target is the svn repository itself, rather than the working copy.)

这篇关于SVN合并一个从一个目录添加的目录(没有目录内容)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆