views:

686

answers:

3

I want to change the default SVN username to a new name. I tried solution suggested in this link (http://stackoverflow.com/questions/45624/change-default-author-in-local-svn-repo), but it is not working.

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

+2  A: 

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

RedGlyph
@RedGlyph: My repository is on Windows XP and I am using SVN on localhost.
RPK
Then the easiest by far is to compile the C code and check the security permissions to make sure the server account can execute it. If you compile it with Cygwin, make sure to use `-mno-cygwin` not to depend on any Cygwin .dll library. You _could_ use a .bat script but it is not easy to setup (see here: http://stackoverflow.com/questions/1620490/post-commit-hook-run-as-what-user-in-svn).
RedGlyph
@RedGlyph: Isn't there any simple SVN command that I can execute from the command line.
RPK
@Rohit: No, there is a client command (`svn propset`) but it cannot bypass the hook script on the server, and it won't be accepted if that script is missing unfortunately. There is an obscure `svnadmin setrevprop` command but it is barely mentioned in the documentation and I couldn't find any practical example or explanation on how it works. Why is that a problem to simply put a hook script? You'll be able to modify the logs and authors in the future with it and believe me, those things are sometimes necessary.
RedGlyph
@Rohit: I've put an example of .bat script and a link to other examples (in Python and Perl). I hope it solves your problem.
RedGlyph
+3  A: 

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.

Steve Schnepp
Oops, right. I'm afraid I misunderstood the question, I removed my OT solution ;-)
RedGlyph
@Steve: Thanks. Actually, I just found there is an "override" option in Aptana Subversive plugin to override the default name. It works, but I am now getting error:SVN: 'Set revision author' operation finished with error: Disabled repository featuresvn: Repository has not been enabled to accept revision propchanges;ask the administrator to create a pre-revprop-change hookDisabled repository featuresvn: Repository has not been enabled to accept revision propchanges;ask the administrator to create a pre-revprop-change hook
RPK
@Rohit: that's what I call *rewrite history*. The `override` option is something that tries to update the author **after** the commit (ie. rewriting). For this you have to use hooks.
Steve Schnepp
@RedGlyph: You could just have edited your solution to either better match the question or just add a header that it's an answer on a little different, but related, question. Every answer that is correct and notredundant has its right to exist :-)
Steve Schnepp
@Steve: It would have been a hell of an edit to do. I finally opted to undelete it, in case part of the log history has to be changed due to the wrong author being used.
RedGlyph
@Steve: I've found a way and it worked. I am using Windows XP. From control panel, select -> Administration Tools -> Computer Management.Find the old user listed there. Right-click and select "Rename".Previously, when I checked the "override" box (in Aptana) and entered new name of author, it used to give error while checking-in files. But now it is not giving.
RPK
A: 

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.

andrej