Is there a way to make it so that if I call $ svn ci -m "some message" it yells at me for not specifying the files I want to check in?
I would be fine with it either just asking me to confirm that I want to check in the whole directory, or just canceling the operation.
Normally I try to be verbose and tell SVN the files I want to check in, but occasionally I forgot and end up checking in more than I wanted to.
Before I get to your answer, I want to make sure you understand how Subversion works.
Subversion looks at changes as a changelist and not as individual file changes. That’s why the entire repository revision is incremented whenever there’s a commit and not just individual files.
Many people who are use to version control systems that don’t handle changelists do things like this:
This is bad because it breaks the concept of the change list. If
file1,file2, andfile3are all related to a single change, they should be committed together.The standard way of using Subversion it to work on a single change list at a time. You work fixing a bug or adding a feature, commit your changes, then work on the next bug or feature. If you are working on two separate bugs or features at the same time, you should really have two separate checkouts.
Doing it that way would allow you to use
svn committo commit your change list as a single unit.That said, there is a way to change that behavior of a Subversion commit if you don’t list any files and that is by defining your own
svnfunction and an alias to thesvncommand.For example, in Kornshell, there is no easy way of changing the prompt when you do a
cdto reflect the directory you’re in. To get around this, you create a_cdfunction that changes the directory and the prompt. Then, you alias thecdcommand to your_cdfunction.In your case, you’ll define a
_svnfunction that looks at the first parameter and sees whether it iscommit. If it’s not, you can safely execute the actualsvncommand. If the first parameter iscommit, you can then look to see if there is a second parameter. If there isnt’, you can assume you forgot to list files, and exit out. The function would look something like this:Then, you create an alias:
Now, executing
svnwon’t run thesvncommand (at least directly). Instead, your alias will run the_svnfunction.By the way, I’m not assuming any parameter handling in my function. (What if you add
-m "this is a test") or–username bob –password swordfish` to the command?). You’ll have to extend the function to handle parameters to the commit command. However, this gives you the general idea how you can change a command’s functionality to do things like this.