简体   繁体   English

git-svn可以正确填充svn:mergeinfo属性吗?

[英]Can git-svn correctly populate svn:mergeinfo properties?

I am evaluating git-svn and trying to determine how well it will play with a particular svn repository. 我正在评估git-svn并尝试确定它与特定svn存储库的效果。 I am mostly concerned with getting git-svn to perform merges in such a way that the svn:mergeinfo property is correctly set in the subversion repo. 我主要关心的是让git-svn执行合并,以便在subversion repo中正确设置svn:mergeinfo属性。 Is this possible? 这可能吗?

Here is what I have done so far: 这是我到目前为止所做的:

# Checkout the SVN repo.
$ git svn clone svn://server/project1 -T trunk -b branches -t tags

# Make sure we are working on trunk.
$ git reset --hard remotes/trunk

# Modify the working copy.
$ vim file.txt

# Commit locally to the git repo.
$ git commit -a

# Push the commits back to the SVN server.
$ git svn dcommit
Committing to svn://server/project1/trunk ...
    M   file.txt
Committed r178
    M   file.txt
r178 = b6e4a3a0c28e7b9aa71d8058d96dcfe7c8a2b349 (trunk)

Now how would I go about merging that particular commit into one of the subversion branches? 现在,我将如何将该特定提交合并到一个subversion分支中? Again, it is very important to me that git properly set the svn:mergeinfo property when committing the change. 同样,对我来说非常重要的是git在提交更改时正确设置了svn:mergeinfo属性。

Even though this is an old question, the current state of affairs with git-svn has changed since it was asked. 尽管这是一个老问题,但自从被问到以来,git-svn的当前状况已经发生了变化。 Specifically, in git 1.7.5, there is some limited support for setting the svn:mergeinfo when dcommitting back to svn. 具体来说,在git 1.7.5中,当提交回svn时,对设置svn:mergeinfo的支持有限。

git svn dcommit now accepts the -mergeinfo=<mergeinfo> flag. git svn dcommit现在接受-mergeinfo=<mergeinfo>标志。 To quote from the 1.7.5+ man page : 引用1.7.5+手册页

-mergeinfo=<mergeinfo> -mergeinfo = <合并信息>

Add the given merge information during the dcommit (eg --mergeinfo="/branches/foo:1-10"). 在dcommit期间添加给定的合并信息(例如--mergeinfo =“/ branches / foo:1-10”)。 All svn server versions can store this information (as a property), and svn clients starting from version 1.5 can make use of it. 所有svn服务器版本都可以存储此信息(作为属性),从1.5版开始的svn客户端可以使用它。 git svn currently does not use it and does not set it automatically. git svn目前不使用它,也不会自动设置它。

One should be very careful when using this though. 但是在使用它时应该非常小心。 Even though the man page says "add" what it really means is "replace". 即使手册页上写着“添加”,它的真正含义是“替换”。 That is, the svn:mergeinfo attribute is set based on what is passed, it does not add the specified revisions to the already existing svn:mergeinfo . 也就是说, svn:mergeinfo属性是根据传递的内容设置的,它不会将指定的修订添加到现有的svn:mergeinfo Learn from my mistake… 从我的错误中学习......

Edit: 编辑:

It appears that they are still working on improving this even further. 看起来他们仍在努力进一步改善这一点。 As of git-svn 1.7.7 , the following text was added to the git-svn man page: git-svn 1.7.7开始 ,git-svn手册页中添加了以下文本:

config key: svn.pushmergeinfo config key:svn.pushmergeinfo

This option will cause git-svn to attempt to automatically populate the svn:mergeinfo property in the SVN repository when possible. 此选项将导致git-svn尝试在可能的情况下自动填充SVN存储库中的svn:mergeinfo属性。 Currently, this can only be done when dcommitting non-fast-forward merges where all parents but the first have already been pushed into SVN. 目前,这只能在提交非快进合并时才能完成,其中除第一个之外的所有父级已经被推入SVN。

Short answer: No, git-svn does not care about svn:mergeinfo properties since git-svn is not doing merges back to svn (it is doing commits). 简短回答:不,git-svn并不关心svn:mergeinfo属性,因为git-svn没有合并回svn(它正在进行提交)。

Long answer: Most people use git-svn to get out of the brain-damaged merging of svn. 答案很长:大多数人使用git-svn来摆脱大脑损坏的svn合并。 The problem with svn is that it does not differentiate between copying files or folders (often caused by refactoring) and creating a branch since creating a branch or tag is done by using the "svn copy" command. svn的问题在于它不区分复制文件或文件夹(通常由重构引起)和创建分支,因为创建分支或标记是通过使用“svn copy”命令完成的。 The svn:mergeinfo property is a band-aid on this problem but there are still cases where modifications are ambiguous. svn:mergeinfo属性是这个问题的创可贴,但仍然存在修改含糊不清的情况。 Git has much more robust support for branching and merging. Git对分支和合并有更强大的支持。

Seems like they are working on it. 好像他们正在努力。 It might be possible in next version: 在下一个版本中可能有可能:

http://git.kernel.org/?p=git/git.git;a=commit;h=6abd9332f97441a568421ba233ad8929b50a7efc http://git.kernel.org/?p=git​​/git.git;a=commit;h=6abd9332f97441a568421ba233ad8929b50a7efc

Theoretical part 理论部分

The problem is that Subversion and Git have significantly different merge tracking mechanics. 问题是Subversion和Git有明显不同的合并跟踪机制。

As result certain merge information can not be properly translated from Subversion to Git. 因此,某些合并信息无法从Subversion正确转换为Git。 For instance, Git does not track cherry-picks at all, when SVN tracks them even on subdirectories level. 例如,当SVN甚至在子目录级别跟踪它们时,Git根本不跟踪樱桃选择。

On the other hand there are no problems representing Git merge history in Subversion. 另一方面,在Subversion中表示Git合并历史没有问题。 But be careful here, as some SVN file/directory properties are not present in Git repository (eg svn:keywords), modifications of these properties are lost in SVN repository once you dcommit a merge commit. 但是请注意,由于某些SVN文件/目录属性不存在于Git存储库中(例如svn:keywords),一旦您提交合并提交,这些属性的修改将在SVN存储库中丢失。

Practical part 实用部分

git-svn does not automatically set svn:mergeinfo property according to all the parents of Git commit. git-svn不会根据Git commit的所有父节点自动设置svn:mergeinfo属性。 But you can specify the value of the property manually before dcommitting corresponding commit. 但是,您可以在提交相应的提交之前手动指定属性的值。

Have a look at SubGit , a server-side replacement for git-svn. 看看SubGit ,它是git-svn的服务器端替代品。 It translates merge information in both directions when it's possible. 它在可能的情况下在两个方向上转换合并信息。 It also supports such SVN properties as svn:ignore, svn:eol-style and svn:mime-type. 它还支持svn:ignore,svn:eol-style和svn:mime-type等SVN属性。

For more details please refer to SubGit documentation and SubGit vs. git-svn comparison. 有关更多详细信息,请参阅SubGit文档SubGit与git-svn比较。

SubGit is a commercial product with free options for open-source, academic and small projects. SubGit是一个商业产品,提供开源,学术和小型项目的免费选项。 And I'm one of SubGit developers. 我是SubGit开发人员之一。

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

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