Simple Subversion: status, add, delete, and commit

Submitted by Ed_B on Thu, 10/07/2010 - 14:39

Printer-friendly versionPrinter-friendly version

I'm using Subversion on google code for writing "timer-scheduler", an Arduino library.  (http://code.google.com/p/timer-scheduler/)  It turns out that the everyday commands are add, delete, status, and commit. I use them on the command line. Here's how they work for me.

Warning: It is important to understand that Subversion manages the local svn folders as well as the ones on the svn server. In particular, all file/folder deleting operations on the local folder must be done with the "svn delete" command. You can add folders locally, and then use "svn add" to add them to the Subversion project. But you cannot delete local folders and then "commit" (See "Deleting" Below.)

click READ MORE to see the whole post

 

This is where my SVN project is located on my computer
/home/varmint/svn/timer-scheduler/

This where my Arduino application folder lives
/home/varmint/bin/arduino-0017/

Incedentally, my Arduino application and libraries folders are not in my subversion project folder. In order to test my edits, I copy my svn/timer-scheduler/ folder to the Arduino libraries folder after every edit. Just for fun, here's the command line:

cp -rf /home/varmint/svn/timer-scheduler/* /home/varmint/bin/arduino-0017/hardware/libraries/TimerScheduler

Onward to SVN stuff:

Status

Use "svn status -v" a lot to check the health of your project!

Do some editing on (for instance) /home/varmint/svn/timer-scheduler/utility/clock.c

Decide that your edits compile and run and are worth saving. Check that svn sees all the right files that have been changed and that it knows about everything that's supposed to be there, and to ignore things not to be included.

svn status -v

If SVN sees unknown files in the local version of the project, it will tell you so, and they will simply be left out of the update process. If you want those files included, you have add them to the project with "svn add".

Add

You can add folders to your local copy of the project using your file manager and editor, then use "svn add" to put them in the SVN server. For example, from the file manager, make a new folder called timerInterrupt_Overflow/ in the SVN project folder and add some code. Add the new folder to the project:

svn add examples/timerInterrupt_Overflow

Delete

Read the whole delete section before deleting anything in your project.

a simple delete:

svn delete examples/TimerPinDirect_1test1

More detail on deleting-
Every run of the Arduino compile process on examples/timerInterrupt_Overflow.pde makes a subfolder called timerInterrupt_Overflow/applet/. The files in applet/ don't contain sourcecode and they make the version really big. We don't want the applet/ folder in the project. Therefore, you should delete examples/timerInterrupt_Overflow/applet from examples/timerInterrupt_Overflow/ before using "svn add examples/timerInterrupt_Overflow/".

If you forget to delete the applet/ folder from the project before adding timerInterrupt_Overflow/ to the project you can use "svn delete --force" to remove the applet/ folder from the project:

svn delete --force examples/timerInterrupt_Overflow/applet

After removing the applet/ folder using the "svn delete" command, then recompiling (which recreates applet/), "svn status -v" will tell you that it doesn't know what the applet/ folder is. Good. Ignore it.

An unhappy scenerio. If instead of doing the delete using "svn delete", you deleted a folder by using your local file manager, the local and remote will refuse to sync. It will break the svn database. (This is bad.) Try to fix it by force deleting the non-existant folder from the database:

svn delete --force examples/TimerPinDirect_1test1/applet

Commit

Happy again. Upload to the SVN server in the sky. Commit your changes -- dont forget to cd to the top project folder in your local svn folder! Otherwise you'll only get a partial sync.  The comment in 'single quotes' is required:

cd /home/varmint/svn/timer-scheduler/
svn status -v
svn commit -m 'documenting the IRQ, added as serial print test in the .pde. works okay at 9600'