Want to use Subversion with CodeWarrior?

 

Seven+ years (!) ago, I learned about the Subversion project and was very excited about the evolutionary improvements over CVS.  I've switched to it for all of my personal projects.


However, the Subversion guys weren't going to write a CodeWarrior Version Control System (VCS) plugin so I figured I'd have to do it myself.  I used to use CodeWarrior for all my personal projects and I still use it at work from time to time.  Plus, I figure that the odds of my team even considering a switch to Subversion would have been negligible if there were no CW plugin.  So here we are.


Features

  1. Integration with the IDE, just like you'd expect.

  2. Support for the Add, Blame, Cat, Commit, Difference, Info, Lock, Log, Resolved, Revert, Status, Unlock, and Update commands.

  3. Uses the internal CodeWarrior diff engine for visual differences.  Unified diff is lame.

  4. Open Source.


Requirements

  1. Metrowerks CodeWarrior 8.3 or higher.  Sadly, using the plugin in CW10 doesn't work due to a crashing bug in the IDE which will never be fixed.  CW 9.x is what I mostly use and test with.

  2. Mac OS X 10.4.x or higher

  3. Windows XP SP2 (only version tried)


Download

  1. Mac

  2. Windows


Release Notes - Version 1.2.1 (2007-08-20)

  1. Per request, renamed the plugin from "Subversion" to "CWSVN".  Note that you will need to remove the old "SubversionXXX" plugin files from your CW plugins directory before installing the new ones.

  2. Updated to core svn 1.4.4 libraries.

  3. Separate versions for CW 8.x and CW 9.x on Windows to try and fix the stupid MSL DLL issues.  If someone wants to figure out how to build this plugin with Visual Studio and avoid the Standard C library collisions which cause this issue, be my guest!

  4. I have very little time to work on this anymore. Hopefully, I will be able to continue tracking new subversion releases but don't expect any new features.


    Old Release Notes


Installation

Install the Subversion command line binaries from http://subversion.tigris.org/.  You'll need the command line tools to be installed to use the plugin successfully on Windows.


On the Mac, just drag the "CWSVN" file into your "CodeWarrior Plugins/Version Control/" folder, drag the "CWSVN Panel" file into your "CodeWarrior Plugins/Preference Panels/" folder, and restart the IDE.  On Windows, the plugin is named "CWSVN.dll" and the preference panel is "PCWSVN.dll" to follow existing CW plugin naming conventions.  The base plugins folder is "Bin/Plugins/".


Open up a project within your Subversion working copy, go to Edit -> Version Control Settings..., and set the version control method to "Subversion" in the popup.  Enter a username and password and set the "Local Path" field to the top of your working copy and you're good to go.


If you are using an authentication system other than user/password, you can leave the username/password fields in the VCS setup blank and the plugin will use the underlying auth caching behavior of the Subversion client library.  As long as you have logged into your server once with the command line client, you won't have to enter the info in the IDE.  You may or may not see the IDE pop up the user/pass dialog but you can just dismiss it without entering anything.  If you you are using username/password, you can enter the username and leave the password blank but check the "remember password" checkbox.  You won't ever see the IDE dialog if you do that.


Design Considerations

I should start by pointing out that CodeWarrior has a design quirk whereby the VCS state can never be considered unmodified if a file is not read-only (CodeWarrior's VCS support was designed for reserved checkout version control systems).  Even though the plugin might tell the IDE that the VCS state is "not checked out," the IDE will display the status in the project window as "modified read-only" via a dashed line through a pencil icon if the file is not read-only.  To avoid confusion for those people used to the behavior of other version control systems within CodeWarrior, the plugin has a preference to make the files read-only after every operation unless the file is already locally modified [this is not the default].


However, by reinterpreting the IDE's icon display, you can actually use this quirk to your advantage.  Because files which have the "svn:needs-lock" property will be made read-only by the Subversion client library, they will appear in the IDE with a "solid line through a pencil" icon which normally means "not checked out."  For this plugin, it means that you should choose the "Lock" command to start editing the file instead of choosing the "Checkout" command.  This unlocks the file and notifies the repository that you have reserved the file for editing.  Interpreting the IDE's display in this manner gives you three distinct visual cues to quickly determine the state of your code.




Note also that the plugin is entirely self-contained in that it contains all of the necessary Subversion client code instead of just linking against libraries installed on your system.  This avoids versioning issues and install location issues for custom Subversion installs.  As of version 1.2, the plugin can be built to just use the installed svn libraries in /usr/local (or /usr on Leopard).  That makes it a LOT smaller (and you no longer have to wait for me to do a new release to sync up with new subversion releases).  The installation disk image contains plugins built with and without the embedded svn libraries.


Limitations

  1. No support for initial checkout.  You must have an existing working copy already.

  2. No support for properties.  The most obvious omission in properties support is the fact that the plugin does not automatically set the svn:keywords properties for text files when adding them.  The best workaround is to use the Subversion config setting for "enable-auto-props" and set up your config file to do what you want.

  3. No support for creating tags or branches.

  4. No local BDB support on the Mac.  This should only be an issue if you're accessing a file:// based repository. Windows should have BDB support but is untested.

  5. Missing commands: cleanup, copy, delete, export, list, merge, mkdir, move (rename), propdel, propedit, propget, proplist, propset, and switch.

  6. The difference selection dialog cannot pick a version with a different base URL (e.g. the same file on a branch or tag).


Mac Notes

For the curious programmer, I'll describe a neat hack I did (well, I think it's neat).  CodeWarrior plugins must use the CFM/PEF format but the Subversion libraries are dyld/Mach-O.  Since CFM code can't link directly against dyld code, it was necessary to make a dyld/Mach-O dynamic shared library that I could load and use.  However, I didn't want to ship two files in case somebody accidentally deleted the shared library or tried to mix and match different versions.  I was able to merge the shared library's Mach-O data and the PEF fragment into the same file, use the 'cfrg' resource to tell CFM how to do the right thing, and then use the dlopen/dlsym/dlclose routines from the System framework to load the Mach-O function pointers.  One file, two runtime formats.  Coolness.


As of 1.2, you can build the plugin without this hack and it will dynamically load the libraries installed in /usr/local instead.  If you're building on OS X Leopard, the svn binaries are installed in /usr/xxx so you'll need to tweak the code to look there instead (see code comments).


Contact Info

Got questions?  Send email to "subversion at soundgeek dot org".

Found a bug?  Send email to "bugs at soundgeek dot org".


License

         Copyright © 2004-2007, Stephen A. Davis, All rights reserved.


Redistribution and use in source and binary forms, with or without

modification, are permitted provided that the following conditions

are met:


*Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.


*Redistributions in binary form must reproduce the above

copyright notice, this list of conditions and the following

disclaimer in the documentation and/or other materials provided

with the distribution.


*Neither the name of Stephen A. Davis nor the names of

contributors may be used to endorse or promote products derived

from this software without specific prior written permission.


THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.