本文介绍了在 Subversion 中更改旧提交的作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到今天,我有一个用户名为 foo.bar.现在,从这里开始,该用户将被称为 fb.但我想更新所有旧提交以反映这个用户名而不是出于统计原因等旧用户名.如何做到这一点?

I have a user that has, up until today, been called foo.bar. Now that user will be known as fb instead from here on. But I would like to update all the old commits to reflect this username instead of the old one for statistical reasons etc. How can this be done?

我知道语法

svn propset --revprop -r revision_number svn:author your_username

但这需要大量的体力劳动.是否有现有的函数或脚本只需要替换名称和替换名称?

But that would require a lot of manual labor. Is there an existing function or script that just takes the name to replace and the name to replace it with?

更新:

这是我制作的一个小脚本来处理这个问题,因为我将在很多用户的很多 repos 上这样做:)只需在您选择的检出存储库文件夹中运行它.请注意,脚本中的错误处理最少.

Here is a small script I made to handle this since I will be doing this on a lot of repos for a lot of users :)Just run it in the checked out repository folder of your choice. Note that error handling is at a minimum in the script.

https://github.com/inquam/svn-rename-author

推荐答案

您可以构建一个命令来获取 old_username 提交的日志中的修订:

You can build a command to get the revisions in the log which old_username has committed with:

svn log | grep "^r[0-9]* | old_username |" | cut -c 2- | awk '{print $1}'

此命令获取日志,搜索出现在每个修订版开头的行,从这些行中删除第一个字符(即 r),然后获取该行的第一个剩余部分,这是修订版.

This command gets the logs, searches for lines that appear at the start of each revision, drops the first character (i.e. the r) from those lines and then takes the first remaining part of the line, which is the revision.

您可以通过多种方式使用此信息.在 bash 中,您可以使用以下命令生成 svn propset 命令序列:

You can use this information in a variety of ways. In bash you could make it produce the sequence of svn propset commands with:

for f in `svn log | grep "^r[0-9]* | old_username |" | cut -c 2- | awk '{print $1}'`
do
svn propset --revprop -r $f svn:author your_username
done

迭代第一个表达式(现在在反引号中)创建的值并将这些值用于您的 svn propset 命令,用适当的修订替换 $f价值.

which iterates over the values created by the first expression (now in backquotes) and uses those values for your svn propset command, replacing the $f with the appropriate revision value.

这篇关于在 Subversion 中更改旧提交的作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-10 23:18