Subversion:如何查找所有未合并到主干的修订?
发布周期的分支源是常见的源管理场景之一。尽快合并是一个很好的做法。因此,我们有一个人为因素:分支已关闭,但有人忘记将某些内容合并回主干。
问:是否有“一键”方式获取所有未从分支 X 合并到主干的修订号?
(注意:我不需要这些修订号来查找要合并的内容,我需要它们来创建自动验证,这会提醒人们确保他们没有忘记将某些内容合并到主干。合并本身不是问题。
)似乎 svn mergeinfo 命令在这里无法提供帮助。如果不在根级别执行合并(这是常见情况),则传递分支和主干根将会失败。
欢迎使用任何类型的 svn hooks 脚本、工具作为解决方案。
PS
SVN 的最新版本。无需争论这种情况有多常见或多好;)
Branching sources for release cycle is one of common source management scenarios. Merging as soon as possible is a good practice. Thus we have a human factor: branch is closed, but someone forgot to merge something back to trunk.
Q: Is there a "one click" way to get all revision numbers that were not merged from branch X to trunk?
(Note: I do not need these revision numbers to find what to merge, I need them to create automated validation, that would remind people to make sure they did not forget to merge something to trunk. Merging itself is not an issue.)
It seems like svn mergeinfo command fails to help here. Passing branch and trunk roots will fail if merge was performed not on root level (and it is a common scenario).
Scripts, tools any kind of svn hooks as a solution are welcome.
P.S.
Latest version of SVN. No need to argue how common or good this scenario is ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
svn merge --dry-run
会为您提供所需的详细信息吗?Will
svn merge --dry-run
give you the details you need?由于缺乏灵丹妙药,严格的方法是记录合并的内容和来源。
Due to the lack of a silver bullet, the disciplined way is to keep a note of what has been merged and from where.
基于 Ether 的回复上面,从您要检查未合并修订的分支
Based on Ether's reply above, from the branch you want to check for unmerged revisions
在你的帖子创建三年后,我很喜欢它。而且我相信您所提出的形式仍然没有解决您的任务的方法:)
我在 $ svn help merge 中发现的是不要进行子树合并的建议:
所以我想解决方案是打破进行子树合并的“常见场景”。
必须对合并操作建立某种控制,否则任何对一个分支具有读访问权限并对另一个分支具有写访问权限的人都可以从第一个分支到第二个分支进行合并。所以实际的问题是 - 如何控制子树合并))
I'm enjoying your thread after 3 years of it being created. And I believe there is still no solution for your task in the form you put it :)
What I found though in the
$ svn help merge
is the advice not to do sub tree merges:So I guess the solution is to break your "common scenario" of doing subtree merges.
It would be mandatory to establish some control for merge operation, as otherwise anybody having Read access to one branch and Write access to another can do the merge from first to second. So the actual question is - how to control subtree merges ))
我已经使用 Wicket 和 SVNKit 编写了 Java Web 应用程序,用于查找分支之间未合并的修订,它可以自定义以执行您想要的任何操作... 链接
o
I have written Java Web Application using Wicket and SVNKit for finding not merged revisions between branches, it could be customized to do whatever you want... link
o
如果您使用相对较新版本的 Subversion(我认为是 1.5 或更高版本)以及
mergeinfo
子命令,那么您可以非常轻松地完成此操作。这将显示所有有资格从分支“your-branch-name”合并到主干的修订。
资料来源: http://svnbook.red-bean .com/en/1.5/svn.ref.svn.c.mergeinfo.html
You can do this super easily if you're using a relatively newish version of Subversion (1.5 or higher, I think) with the
mergeinfo
sub-command.This will show you all the revisions that are eligible to be merged to the trunk from the branch "your-branch-name".
Source: http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.mergeinfo.html
简短回答:我不这么认为。
长答案:我最终编写了一个 python 脚本来回答这个问题。
每当开发人员合并变更集时,他们都需要在日志消息中添加“merged rXXX”。 (这是在 svn:mergeinfo 存在之前)该脚本解析所有实时 svn 分支 + 主干,并递归扫描所有“合并”链接,输出每个开发人员尚未合并的更改列表。
[更新] @tmont 的答案更好了,因为每个人都有一个支持 svn mergeinfo --show-revs Eligible 和 svn merge --record-only 的 svn 版本当您只想记录逻辑修复时。
Short answer: I don't think so.
Long answer: I ended up writing a python script to answer this question.
Whenever developers merge a changeset they're required to put "merged rXXX" in the log message. (This from before svn:mergeinfo existed) The script parses all live svn branches + trunk and recursively scans all "merged" links, outputting a per-developer list of changes they haven't merged.
[update] The answer from @tmont is better now that everyone has a svn version that supports
svn mergeinfo --show-revs eligible
andsvn merge --record-only
for those times when you want to record the logical fix only.我意识到你的情况可能已经太晚了,但我对这类事情所做的是为合并提交建立一个约定,以便以后可以识别它们。例如“合并 [1234]:...(1234 的完整提交日志)...”。然后我可以稍后用脚本从 svn 日志中解析它。
为了确保您的整个团队都能做到这一点,请将合并约定放入脚本中并将其放入您的项目中。 (例如,./scripts/merge 1234)。人们通常甚至会欣赏这一点,如果脚本通过自动计算源 url 等操作使合并比原始 svn 命令更容易,那就加倍
祝你好运。
I realize your case is probably too late for this, but what I do for this sort of thing is to establish a convention for the merge commits so they're identifiable later. For example "Merging [1234]: ...(full commit log of 1234)...". Then I can parse it out of svn log with a script later.
To make sure your whole team does it, make the merge convention into a script and put it in your project. (e.g., ./scripts/merge 1234). People will generally even appreciate this, doubly so if the script makes merges easier than the raw svn command would be by doing things like figuring out the source url automatically
Good luck.
我不会担心需要合并的具体更改编号,而只需查看差异:
首先,使侧分支与主干保持同步(或查看将合并的内容):
记住,svn merge 命令看起来就像 svn diff 命令一样 - 您创建一个 diff/patch,然后将其应用到特定位置。上面的合并命令只是说“获取主干和分支之间的所有差异,并将它们应用到主干的工作副本”。因此,您可以轻松地将第二个合并命令更改为邮件通知的差异。
不要忘记在提交每种情况之前检查差异,以确保没有发生任何不好的事情。您可能还必须解决一些冲突。
I wouldn't worry about the specific change numbers that need to get merged, but rather just look at the diffs:
First, bring the side branch up to date with trunk (or see what would be merged):
Remember, svn merge commands look just like svn diff commands - you create a diff/patch, then apply that to a particular location. That merge command above is simply saying "take all the differences between trunk and the branch, and apply them to a working copy of trunk". So you could just as easily change that second merge command into a diff for your mail notification.
Don't forget to check the diffs before committing in each case, to be sure that nothing bad has happened. You may also have to resolve some conflicts.
抱歉,我家里没有 SVN 服务器来测试这个,但是命令可以吗:
你可以解析哪个?我不确定合并回 main 后的输出,但您也许能够解析(使用脚本,我没有脚本,因为我是唯一使用 SVN 服务器的人)日志并读取所有内容已经签入的文件,然后寻找一个表明该文件已经合并到main的关键字?
如果我有时间的话,我今晚回家后会尝试检查一下。
I'm sorry I don't have my SVN server up at home to test this right now, but could the command:
Which you could parse? I'm not sure the output after you merge back to main, but you might be able to parse through (using a script, which I don't have as I'm the only one using my SVN server) the log and read all the files that have been checked in, and then look for a keyword indicating that the file has been merged to main?
I'll try to check it out sometime tonight when I get home if I have some time.
因此,CVS 创建了一个标记来标记分支的根:) 对于 SVN,应该如下所示:
注意:
For that reason CVS created a tag to mark a root of branch :) For SVN that should look like:
Notes: