Subversion:如何查找所有未合并到主干的修订?

发布于 2024-08-20 05:27:13 字数 360 浏览 6 评论 0原文

发布周期的分支源是常见的源管理场景之一。尽快合并是一个很好的做法。因此,我们有一个人为因素:分支已关闭,但有人忘记将某些内容合并回主干。

问:是否有“一键”方式获取所有未从分支 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 技术交流群。

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

发布评论

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

评论(11

北斗星光 2024-08-27 05:27:14

svn merge --dry-run 会为您提供所需的详细信息吗?

Will svn merge --dry-run give you the details you need?

寻找我们的幸福 2024-08-27 05:27:14

由于缺乏灵丹妙药,严格的方法是记录合并的内容和来源。

Due to the lack of a silver bullet, the disciplined way is to keep a note of what has been merged and from where.

深海夜未眠 2024-08-27 05:27:14

基于 Ether 的回复上面,从您要检查未合并修订的分支

svn merge --dry-run http://svnrepo/path-to-merge-source .  \
| grep Merging                                             \
| sed 's/--- Merging//'                                    \
| sed 's/into.*//'                                         \
| sort -u                                                  \
| sed 's/ through r/:/'                                    \
| sed -e :a -e N -e 's/\n//' -e ta                         \
| sed 's/ r/ -r/g'                                         \
| sed 's|^|svn log http://svnrepo/path-to-merge-source |'

Based on Ether's reply above, from the branch you want to check for unmerged revisions

svn merge --dry-run http://svnrepo/path-to-merge-source .  \
| grep Merging                                             \
| sed 's/--- Merging//'                                    \
| sed 's/into.*//'                                         \
| sort -u                                                  \
| sed 's/ through r/:/'                                    \
| sed -e :a -e N -e 's/\n//' -e ta                         \
| sed 's/ r/ -r/g'                                         \
| sed 's|^|svn log http://svnrepo/path-to-merge-source |'
南城追梦 2024-08-27 05:27:14

在你的帖子创建三年后,我很喜欢它。而且我相信您所提出的形式仍然没有解决您的任务的方法:)

我在 $ svn help merge 中发现的是不要进行子树合并的建议:

如果只想合并子树,则子树路径必须是
包含在 SOURCE 和 TARGET_WCPATH 中;这是不鼓励
避免子树合并信息

所以我想解决方案是打破进行子树合并的“常见场景”。

必须对合并操作建立某种控制,否则任何对一个分支具有读访问权限并对另一个分支具有写访问权限的人都可以从第一个分支到第二个分支进行合并。所以实际的问题是 - 如何控制子树合并))

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:

If you want to merge only a subtree, then the subtree path must be
included in both SOURCE and TARGET_WCPATH; this is discouraged, to
avoid subtree mergeinfo

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 ))

寂寞美少年 2024-08-27 05:27:14

我已经使用 Wicket 和 SVNKit 编写了 Java Web 应用程序,用于查找分支之间未合并的修订,它可以自定义以执行您想要的任何操作... 链接

screeno

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

screeno

開玄 2024-08-27 05:27:13

如果您使用相对较新版本的 Subversion(我认为是 1.5 或更高版本)以及 mergeinfo 子命令,那么您可以非常轻松地完成此操作。

svn mergeinfo --show-revs eligible svn://repo/branches/your-branch-name svn://repo/trunk

这将显示所有有资格从分支“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.

svn mergeinfo --show-revs eligible svn://repo/branches/your-branch-name svn://repo/trunk

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

卸妝后依然美 2024-08-27 05:27:13

简短回答:我不这么认为。

长答案:我最终编写了一个 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 and svn merge --record-only for those times when you want to record the logical fix only.

Saygoodbye 2024-08-27 05:27:13

我意识到你的情况可能已经太晚了,但我对这类事情所做的是为合并提交建立一个约定,以便以后可以识别它们。例如“合并 [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.

一江春梦 2024-08-27 05:27:13

我不会担心需要合并的具体更改编号,而只需查看差异:

首先,使侧分支与主干保持同步(或查看将合并的内容):

cd branch-dir
svn merge --reintegrate http://svnrepo/path-to-trunk .
svn ci -m'making this branch current'

cd ../trunk-dir
svn merge --dry-run http://svnrepo/path-to-trunk http://svnrepo/path-to-branch .
svn ci -m'merging in all unmerged changes from <branch>'

记住,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):

cd branch-dir
svn merge --reintegrate http://svnrepo/path-to-trunk .
svn ci -m'making this branch current'

cd ../trunk-dir
svn merge --dry-run http://svnrepo/path-to-trunk http://svnrepo/path-to-branch .
svn ci -m'merging in all unmerged changes from <branch>'

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.

水中月 2024-08-27 05:27:13

抱歉,我家里没有 SVN 服务器来测试这个,但是命令可以吗:

svn log --verbose

你可以解析哪个?我不确定合并回 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:

svn log --verbose

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.

樱花坊 2024-08-27 05:27:13

因此,CVS 创建了一个标记来标记分支的根:) 对于 SVN,应该如下所示:

+ trunk / project1
+ tags / project1-b1-root
+ branches / project1-b1

注意:

  1. 标记 project1-b1-root 和分支 project1-b1 是从主干同时创建。
  2. 没有人应该提交给 project1-b1-root (您可以限制 tags/ 路径的此操作)。
  3. 当每个人都声称他已将所有内容放入主干时,您可以在 project1-b1-rootproject1-b1 之间进行比较,并尝试将其应用到主干:已经应用的更改将被默默地跳过,其余的您将看到差异或冲突。

For that reason CVS created a tag to mark a root of branch :) For SVN that should look like:

+ trunk / project1
+ tags / project1-b1-root
+ branches / project1-b1

Notes:

  1. Tag project1-b1-root and branch project1-b1 are created at the same time from trunk.
  2. Nobody should commit to project1-b1-root (you can restrict this operation for tags/ path).
  3. When everybody claimed, that he has put everything to the trunk, you make a diff between project1-b1-root and project1-b1 and try to apply it to trunk: the changes, which are already applied, will be silently skipped, for the rest you will see the difference or collisions.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文