Posts Tagged ‘svn’

SVN commit that ignores unversioned files

SVN Commit Fun

I know, I know, I should be using Git. Well, I do. I use it for everything I have under my control. Unfortunately, like many, I still have obligations that require me to use SVN on a regular basis. And when I roll with SVN, I roll command line. No, its not an elitist, terminal God point of view. I happen to like TortoiseSVN, but 90% of my SVN versioned work is on Linux servers.

If you’re like me, you’ll find yourself frequently using this lazy command line syntax inside your project directory to catch all your changes in one commit:

svn commit * -m "you should always leave a message!"

And there’s a very good chance you’ve run into this error, or something similar:

svn: Commit failed (details follow):
svn: '/path/to/unversioned_file' is not under version control

As it turns out, there doesn’t appear to be a way to ignore unversioned files in the svn commit options. Now before you sart leaving comments about the svn:ignore property of the SVN configuration, realize that it only applies to the svn add, svn import, and svn status commands. It has no impact on svn commit calls so we need another solution.

To that end, I put together a simple one-liner shell script to perform an SVN commit on all versioned files within the current directory, ignoring all unversioned files. Here it is:

svn status | grep ^[^?] | awk '{print $2}' | xargs svn commit -m "my commit message"

In case that makes no sense, it performs the following operations:

  1. Call svn status to get a full list of relevant project files.
  2. The question mark (?) in svn status signifies an unversioned file. The grep regular expression only matches files that do not start with that question mark.
  3. Use awk to print the second column from the svn status call, which is the filename.
  4. Use xargs to feed the filename list from awk to our svn commit call.

You can take this all one step further (as I have) and turn it into a bash script accepting your commit message as its only argument (signified by the ${1}).

svn status | grep ^[^?] | awk '{print $2}' | xargs svn commit -m "${1}";

There you go, happy SVN’ing.

In my prior 2 part guide entitled “Google Project, Subversion, and Eclipse” ( and ) I discussed how to setup a Google Project Hosting Subversion repository and how to integrate it into an Eclipse based IDE. It came with lots of text and screenshots. While lots of people prefer this method of step by step instruction (I’m usually one of them), its layout left me disappointed.

To remedy this dissatisfaction I put together this video. It walks you through everything from that 2 part guide in a concise 6 minute video. You’ll get to see exactly how to create a Google Project Hosting Subversion repository, install the Subclipse SVN plugin for Flash Builder 4, and integrate the repository into your development environment.

You’ll have to forgive the very amateur nature of the video, this was my first time using Adobe Captivate .  Its a pretty intuitive software, but I’m totally ignorant to the finer points of video guide creation.  I’m sure that will start to change in the near future, though, especially if people actually take the time to watch this one.

In we learned how to setup a Google Project Hosting Subversion repository for version control and remote storage of our code.  In Part 2 we will learn how to integrate this remote repository into the Eclipse based IDE of your choice.  Before starting, though, let me first mention that:

  • I’m on a Windows system with TortoiseSVN, so some of this will vary on other OSes.
  • I will be using Flash Builder 4 for this guide, but Flex Builder 3 and other Eclipse based IDEs are very similar.
  • You’ll need to know the workspace directory of your IDE, which will be referred to as WORKSPACE from now on.

So let’s say I want to check out my Away3D Flash Builder 4 template project.

  1. The first thing I do is go to my Google Project Hosting page and find the Subversion URL for that project.  You can find my project hosting at
    Google Project Hosting Home
  2. Goto “Source -> Browse” and we’ll find the project I’m looking for under the trunk, “away3d_template_fb4“.  The path to that project is “trunk/away3d_templates/away3d_template_fb4“.  You’ll need this for the checkout later.
    Path to our project
  3. Now its time to install Subclipse, an SVN plugin for Eclipse based IDEs.  Open up Flash Builder 4 (or whatever Eclipse based IDE you are using).  Goto “Help -> Install New Software…
  4. In the resulting dialog, enter the following URL in the “Work with” field:
    Then click  ”Add”.  You will be prompted for a name for the site.  Just call it “Subclipse”.  After you click OK you should get a dialog that looks like this:
    Installing New software
  5. Check “Subclipse” then expand its choices.  Deselect “Subclipse Integration for Mylyn 3.x (Optional)” and “Subversion Revision Graph”.  Your list should look like this:
    Software List
  6. From here just follow the steps for the Subclipse install.  If you need specific instructions to get Subclipse loaded in your Eclipse based IDE, use the Download and Install instructions from the Subclipse website.  The IDE will restart (or you should do it manually) when the install finishes.
  7. After Flash Builder 4 reopens, right click in the Package Explorer and select “Import…”.  From the resulting dialog expand “SVN” and select “Checkout Projects From SVN“.  click Next.
    svn dialog
  8. Select the radio button next to “Create a new repository location” and click Next.
  9. In the “URL” field, I will be entering the following URL:
    Notice that the root of the path is my Google Project Hosting root “” and that it ends with the path to my specific project “trunk/away3d_templates/away3d_template_fb4” as mentioned in Step 2. click Next.
  10. Your IDE will return a list of files under this project, but we are checking out the whole thing so just select the top level choice (the full URL) and click Finish.  It will likely take a few moments to finish, depending on the size of your project.
    checkout in eclipse
  11. In your Package Explorer you should now have your Google Project Hosted code integrated into your Eclipse based IDE.  You can do a quick confirmation of this by seeing if there are little yellow icons indicating version control on your filenames.  Also, you can mouse-over any version controlled filename to see when it was last committed and by whom.
    SVN loaded project
  12. Now let’s try a quick change and commit.  I’m going to add a sphere to my Away3D template, then commit the change back to the Google Project Hosting Subversion repository.  After I make the code changes, save, and run the application, the local repository will mark the files as changed.  Notice the little yellow bars have changed to black and white asterisks on changed files.
    Code change
  13. To commit all my changes I am going to right click on the project root in the Package Explorer and goto “Team -> Commit…
    commit changes
  14. In the resulting dialog I am going to write a simple commit message to give a little info about the changes and then click OK.  Eclipse will execute the commit and when it is finished you will see all those little black and white asterisks turn back into yellow bars.  This signifies that your local changes have been successfully sent to the Google Project Hosting Subversion repository.  Feel free to go back to the Google project web interface to confirm it.
    Commit through eclipse

Congrats, you made it!  If you managed to follow along with these 2 long blog posts of mine, you now have your code hosted by Google Project Hosting in a Subversion repository and have it fully integrated into the Eclipse based IDE of your choice.  Give yourself a pat on the back!

It may seem like a lot of work up front, but the ability to revert, merge, backup, branch, and tag code becomes priceless once you get into some serious projects.  The simple assurance that you can fall back to a any revision of your code when you inevitably F something up is great.  Learn to love version control and I assure you it will love you back.  Creepy…

I am about to start moving all the code from the demos on my blog into a Google Project Subversion repository and I thought it might be helpful for others if I made a guide for the process.  Its not too complicated, as Google does a good job of guiding you through, but sometimes a step by step is just what the doctor ordered.  This will be Part 1 of 2.  In Part 2 I plan to show you how to integrate the Google Project Subversion repository you’ll create here into the Eclipse based IDE of your choice.

For Part 1 of this guide there’s a few things to consider:

  • I’m on a Windows system, so some of this will vary on other OSes.
  • You need an SVN client.  For Windows I highly suggest TortoiseSVN.
  • This is not an SVN and Subversion tutorial.  Check out this link for more info on them.

OK, let’s get you on your way to free version control via Subversion via Google Project Hosting.  It doesn’t get more exciting than this!

  1. In case you’ve been living in the stone age and have not yet done it, or to your existing account.
  2. Create a project at the site.  You should see a page like this:Create Google Code Project
  3. Fill in the fields as described on the right hand side.  The only field you need to make sure you set correctly for this guide is “Version Control System.”  This must be set to “Subversion.”  You can use “Mercurial” if you want, but the rest of this guide isn’t going to do you much good!  Click “Create Project” to finish.
  4. This should bring us to our new project home page.
    Project Home Page
  5. Click the “Source” tab to find the URL from which we can checkout the trunk of our new code repository.  Using your SVN client of choice, checkout the repository into a new directory (I’ll call it SVNDIR from now on).  For those on Windows using TortoiseSVN, you’ll right click on SVNDIR and select “SVN checkout…“.  You will then enter the SVN URL from the “Source” page like this:
    Checkout from Subversion

    click OK and you’ve got your less than exciting first checkout.  If all worked well you should now have a single .svn directory in your SVNDIR.
  6. Now we’ll test adding and committing to our new repository.  To keep the initial test simple, I’m going to simply add “demos” directory to SVNDIR which will later house the source code for the demos from this blog.  To do that, create the directory as you normally would in SVNDIR.  Right click the new “demos” directory and under the “SVN” heading click “Add“.
    Add to Subversion
    Click OK in the resulting dialogs to add “demos” to your local repository.
  7. To add “demos” to the Google Code repository we need to commit the add from the last step.  To do that we right click “demos” again and click “SVN Commit…” which will give you a dialog that looks like this:
    Commit to Subversion
    Add a simple message and click OK to start the commit.  You’ll will be prompted for a username and password, which if you are logged into your Google account you can retrieve from this URL: .  Enter those, click OK, and congrats!  You made your first Google Code repository commit!
  8. Now that that works, let’s do something a little more substantial.  Grab one of your source or project directories and copy it to SVNDIR.  In my case, I’ll be copying my away3d_template project that I use as the base for, you guessed it, my Away3D projects.  Do exactly as you did with “demos” to add and commit this new code.
  9. Go back to your Google Project home page and click the “Source” tab.  From here, click “Browse” and take a look at the layout of your new repository.  Under “trunk” you should be able to see ‘demos” and the project you just added.
    Google Project SVN Repository

And that’s all there is to it.  You are now using Google’s Project Hosting and are applying version control to your projects.  Stay tuned for Part 2 where I’ll give step by step instructions on how you can setup your favorite Eclipse based IDE to integrate with Google’s Subversion repository.  It will make the process of sharing and keeping your code updated a breeze.