如何更改访问 SVN 存储库的默认作者?

发布于 2024-08-10 16:59:33 字数 224 浏览 9 评论 0原文

我想将默认的 SVN 用户名更改为新名称。我尝试了此链接中建议的解决方案(如何更改访问默认作者本地 SVN 存储库?),但它不起作用。

我可以使用 Subversive 客户端通过命令行和 Aptana 访问 SVN 存储库。

I want to change the default SVN username to a new name. I tried solution suggested in this link (How do I change the default author for accessing a local SVN repository?), but it is not working.

I have access to SVN repository through command line and Aptana using Subversive client.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

小清晰的声音 2024-08-17 16:59:33

编辑:此答案是关于如何更改日志中的作者,而不是如何设置默认作者。我将把解决方案留在这里,因为如果作者不是正确的,它仍然可以帮助撤消过去的几次提交。

编辑 2:挂钩脚本示例和 .bat 文件的信息。


您没有提供太多细节,因此我们必须猜测,我的第一个想法是调用用于验证更改的钩子脚本。这样的话,不是你的客户端有问题,而是服务器配置问题。

确保 pre-revprop-change 挂钩脚本(位于服务器上的 /hooks 目录中)可由服务器执行并允许更改作者。

以下是 C 语言的示例:

#include <stdio.h>

int main(int argc, char *argv[])
{
int i;
 char *repos = argv[1];
 char *rev = argv[2];
 char *user = argv[3];
 char *propname = argv[4];
 char *action = argv[5];

 if (!strcmp(action, "M") && !strcmp(propname, "svn:log")) return 0;
 if (!strcmp(action, "M") && !strcmp(propname, "svn:author")) return 0;
 fprintf(stderr, "Changing revision properties other than svn:log or svn:author is prohibited");
 return 1;
} 

如果您的 SVN 服务器位于 Linux 上,您也可以简单地将随每个存储库自动创建的 pre-revprop-change.tmpl 文件重命名为 pre-revprop -change,并赋予其服务器可执行权限。它应该看起来像这样,以允许作者和日志更改:

#!/bin/sh

REPOS="$1"
REV="$2"
USER="$3"
PROPNAME="$4"
ACTION="$5"

if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:author" ]; then exit 0; fi
if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi

echo "Changing revision properties other than svn:log or svn:author is prohibited" >&2
exit 1

对于 Windows:

@echo off
REM pre-revprop-change.bat hook script
if "%4" == "svn:log" exit /b 0
if "%4" == "svn:author" exit /b 0
echo "Changing revision properties %4% is prohibited" >&2
exit /b 1

如果它不起作用,可能是由于 COMSPEC 或 PATH 变量没有服务器帐户的正确值,或者也可能是由于钩子脚本。检查此链接了解更多详情

CollabNet 上还有其他挂钩脚本示例 CollabNet

更多详细信息请参见 版本控制与 Subversion 在线书籍,以及此处(检查接下来的部分)。

Edit: This answer is on how to change an author in the logs, not how to set the default author. I'll leave the solution here since it could still help undo the past few commits, were the author not the correct one.

Edit 2: hook script example and information for .bat files.


You don't give much details so we'll have to guess, and my first thought would be about the hook script that is called to validate the change. In that case, your client is not the problem, it is a server configuration issue.

Make sure that the pre-revprop-change hook script (in your <repository>/hooks directory, on the server), is executable by the server and allows a change of author.

Here is an example in C:

#include <stdio.h>

int main(int argc, char *argv[])
{
int i;
 char *repos = argv[1];
 char *rev = argv[2];
 char *user = argv[3];
 char *propname = argv[4];
 char *action = argv[5];

 if (!strcmp(action, "M") && !strcmp(propname, "svn:log")) return 0;
 if (!strcmp(action, "M") && !strcmp(propname, "svn:author")) return 0;
 fprintf(stderr, "Changing revision properties other than svn:log or svn:author is prohibited");
 return 1;
} 

If your SVN server is on Linux, you may also simply rename the pre-revprop-change.tmpl file which is automatically created with each repository to pre-revprop-change, and give it executable permission for the server. It should look like this to allow author and log changes:

#!/bin/sh

REPOS="$1"
REV="$2"
USER="$3"
PROPNAME="$4"
ACTION="$5"

if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:author" ]; then exit 0; fi
if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi

echo "Changing revision properties other than svn:log or svn:author is prohibited" >&2
exit 1

For Windows:

@echo off
REM pre-revprop-change.bat hook script
if "%4" == "svn:log" exit /b 0
if "%4" == "svn:author" exit /b 0
echo "Changing revision properties %4% is prohibited" >&2
exit /b 1

if it does not work, it might be due to the COMSPEC or the PATH variables not having the proper values for the server account, or it could also be the permissions on the hook script. Check this link for more details.

There are other examples of hook scripts at CollabNet.

More details in the Version Control with Subversion online book, and also here (check the next sections).

心凉 2024-08-17 16:59:33

对于 Eclipse(但应该与基于 Eclipse 的 IDE(如 Aptana)配合使用):

在 SVN Perspective 的 SVN Repository 视图中,只需转到
所需存储库的位置属性,并更改身份验证框中的凭据。

从现在开始它应该改变你的作者。

如果你想重写历史,你必须使用类似 RedGlyph 的解决方案。

For Eclipse (but should work with Eclipse-based IDE like Aptana) :

In the SVN Repository views of the SVN Perpective, just go to the
Location Properties of the desired repository and change the credentials in the Authentication box.

It should change your author from now on.

If you want to rewrite history, you have to use something like RedGlyph's solution.

幼儿园老大 2024-08-17 16:59:33

Subversion 1.4.x 在默认 pre-revprop-change 文件中只允许使用 svn:log。当使用带有 Subversive svn 插件的 Eclipse 时,这可能会导致问题。

为了解决神奇的错误,说明

禁止更改 svn:log 以外的版本属性

在 svn 命令之后 。要解决这个特定问题,请添加

if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:author" ]; then exit 0; fi

上面的 RedGlyph 解决方案。

Subversion 1.4.x have got only svn:log allowed in default pre-revprop-change file. This can cause problem when using Eclipse with Subversive svn plugin.

To solve magical error stating that

Changing revision properties other than svn:log is prohibited

after svn commands. To solve this particular problem add

if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:author" ]; then exit 0; fi

from RedGlyph solution above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文