4

I am working in a big project using SVN and many times I have to go see things in other people's branches and play with them. But I want to keep those changes local, never commit them. By mistake, though, its very easy to type svn ci -m"blabla" and commit my changes in someone else's branch. The branches have some identifier to know who they belong to, so for instance we have:

project-aa
project-bb
etc...

And mine would be project-bb. Is there a way of making sure that I commit on the right branch? For instance, whenever I commit, if the text on the path does not contain "-bb", then ask me if I am sure.

Is this possible?

2

I would use a shell function:

svn () {
    if [[ $1 == "ci" || $1 == "commit" ]] && [[ $PWD != *"-bb"* ]]; then
        echo "don't commit to someone else's branch" >&2
        return 1
    fi    
    # now, do the actual svn command
    command svn "$@"  # quotes are crucial here
}
|improve this answer|||||
1

You could make a bash script wrapper that you'd place earlier in your PATH or by renaming the existing svn program file.

That script would simply check if the parameters include that string and react depending if it's found or not.

|improve this answer|||||
  • Thanks. I know nothing of bash, is there a ready-made thing for this, or could you get em started please? – ddeunagomez Jun 9 '16 at 7:27
  • 1
    Now would probably be a good time to learn. Based on your question, you already know one or more programming language and your request is actually very simple, so with a bit of effort you could at least give it a try. It could use grep to find the string and check the return value with a condition (if) to determine if an additional validation is required (done with a read), and if it fails exit. – Julie Pelletier Jun 9 '16 at 7:36
  • 1
    You apparently know more than you were saying. You could set it up as an alias but should still put it in a shell script and use the original arguments (/path/svn $*) when you go forward with the operation. – Julie Pelletier Jun 9 '16 at 8:11
  • 1
    The only problem I'm still wondering about is your quoted comment. – Julie Pelletier Jun 9 '16 at 8:16
  • 1
    After a few tests, it appears that you should use /path/svn "$@" – Julie Pelletier Jun 9 '16 at 8:58
0

Make those checkouts via git-svn. You get the benefits of git (e.g. very fast switch between branches, nicer diff, full local copy for working offline, …), and any commit that you make would go to your local git repository, you would need to do an extra push step to send code back to svn.

git-svn isn't always very robust, it sometimes fails to synchronize changes from svn and pushing changes back to svn is sometimes painful. But for your use case that wouldn't matter.

|improve this answer|||||
  • I preffer avoiding git as much as possible, honestly. I understand people like it, but I just think its a burden to get work done, I always spend 10 hours figuring out what command I want, realising I commited but did not push.. I don't think there is any point in using git unless the repositories are somewhat "ranked" – ddeunagomez Jun 10 '16 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.