{"id":648,"date":"2004-12-09T19:41:44","date_gmt":"2004-12-09T23:41:44","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=648"},"modified":"2020-05-27T09:22:01","modified_gmt":"2020-05-27T17:22:01","slug":"source-control-with-subversion-on-windows","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2004\/12\/09\/source-control-with-subversion-on-windows\/","title":{"rendered":"Source Control with Subversion on Windows"},"content":{"rendered":"<p>We&#8217;re getting around to hiring an additional me at work so I needed to get a source control solution in place before he\/she arrives and starts hacking away at the codebases.  At the last place I worked we used <a href=\"http:\/\/msdn.microsoft.com\/vstudio\/previous\/ssafe\/\">Visual SourceSafe<\/a> for a long time (which was pretty worthless) and then started using CVS, although not on the projects I worked on.  A couple weeks ago I asked a bunch of questions about <a href=\"http:\/\/cephas.net\/blog\/2004\/11\/05\/automating_application_deployment_with_tomcat.html#000814\">automating Java web application deployment<\/a> and Erki suggested that I buy and read the <a href=\"http:\/\/www.pragmaticprogrammer.com\/starter_kit\/au\/index.html\">Pragmatic Project Automation book<\/a>, which I did and which I loved.  I read it from start to finish (which isn&#8217;t an easy thing to do with a technical book) and took a ton of notes.  Anyway, I&#8217;m pretty sure the book didn&#8217;t mention <a href=\"http:\/\/subversion.tigris.org\/\">Subversion<\/a> even once, but it did drill home the importance of setting up your code in source control and then doing your manual, scheduled, automated (using <a href=\"http:\/\/cruisecontrol.sourceforge.net\/\">CruiseControl<\/a>) or production builds directly from the source control system using <a href=\"http:\/\/ant.apache.org\/\">Ant<\/a> or <a href=\"http:\/\/groovy.codehaus.org\/\">Groovy<\/a>, which led to alot of ideas about how you could automate builds to production Tomcat systems.  I&#8217;ve heard alot about Subversion; it&#8217;s described as CVS with none of the warts and all of the features, so I tried it out. Following are the notes I kept during the installation process. Hopefully this helps out someone somewhere down the road:<\/p>\n<p>a) <a href=\"http:\/\/subversion.tigris.org\/project_packages.html\">Download Subversion<\/a> (obviously)  I downloaded version 1.1.1 ( svn-1.1.1-setup-2.exe)<\/p>\n<p>b) Run the install. I chose to install to c:\\subversion\\.<\/p>\n<p>c) Test the Subversion install by going to the install directory and then going to the \/bin directory. Run the svnadmin from the command line:<code><br \/>\nCD c:\\subversion\\bin\\<br \/>\nsvnadmin<\/code><br \/>\nIf you get an error that says that says &#8220;svnadmin.exe &#8211; Unable To Locate DLL&#8221;, you&#8217;ll need to either a) install the Visual C++ 6.0 VCREDIST.exe, which is available <a href=\"http:\/\/download.microsoft.com\/download\/vc60pro\/Update\/1\/W9XNT4\/EN-US\/VC6RedistSetup_enu.exe\">here<\/a>  (but only if you&#8217;re using Windows 98 or Windows ME) or b) find someone or some system that has msvcp60.dll and copy that file to c:\\$windows\\system32\\ (where $windows is the directory that contains your Windows installation).<\/p>\n<p>d) Create a repository on the machine that is going to host your source code.  From the command line on the server machine:<code><br \/>\nsvnadmin create d:\\$projects\\$projectname<\/code><br \/>\nwhere $projects is the name of a folder that will contain all your Subversion source code repositories and $projectname is the name of the specific project you&#8217;re going to create a repository for.<\/p>\n<p>e) Start the server either from the command line:<code><br \/>\nsvnserve -d -r d:\\$projects<\/code><br \/>\nor use the SVN Service Wrapper (<a href=\"http:\/\/dark.clansoft.dk\/~mbn\/svnservice\/\">http:\/\/dark.clansoft.dk\/~mbn\/svnservice\/<\/a>), note that the <code>r<\/code> switch limits directory browsing by specifying the root of your repositories.<\/p>\n<p>f) Create a users database (which is nothing more than a text file, I created a file called users.conf) and save it in the <code>d:\\$projects\\$projectname\\conf<\/code> directory and then add your usernames &amp; passwords.  An example user database might look like this:<code>[users]<br \/>\naaron = mypassword<\/code><\/p>\n<p>g) Within the <code>d:\\$projects\\$projectname\\<\/code>directory, open the conf\/svnserve.conf file using your text editor of choice and add the following to allow reading and writing to the users in the database we just created:<code><br \/>\n[general]<br \/>\nanon-access = none<br \/>\nauth-access = write<br \/>\npassword-db = users.conf<br \/>\nrealm = $projectname<br \/>\n<\/code><br \/>\nwhere $projectname is the name of the project you&#8217;re setting up and users.conf is the name of the file you created in step f.<\/p>\n<p>h) Finally, restart the server and you&#8217;re ready to start using the client and import your project.<\/p>\n<p>i) To import an existing project, invoke the svn executable from the command line on the client:<code><br \/>\nsvn import c:\\temp\\myproject svn:\/\/myserver\/myproject -m \"initial import\" aaron mypassword<br \/>\n<\/code><br \/>\nwhere <code>c:\\temp\\myproject<\/code> is the directory that contains the existing project you want to import (and should have 3 folders: trunk, tags and branches, your source code should be in the trunk folder; more on repository layout <a href=\"http:\/\/svnbook.red-bean.com\/en\/1.0\/ch05s04.html\">here<\/a>), <code>myserver<\/code> is the name of the server that contains the Subversion repository you created in step d, <code>myproject<\/code> is the name of the project (ie: $projectname from step d) you&#8217;re importing into, the <code>m<\/code> switch signifies the message you want to tag this import with, followed by the username and password you setup in the users database in step f.<\/p>\n<p>j) Finally, checkout the project from the server (invoking the svn executable from the directory that you want the trunk checked out from&#8230;, ie: <code>c:\\projects\\myproject<\/code>)<code><br \/>\nsvn co svn:\/\/myserver\/myproject\/trunk . aaron mypassword<br \/>\n<\/code><\/p>\n<p>k) To add, move, delete, or edit and then commit any changes back to subversion:<br \/>\nAdd: <code>svn add src\/myfile.java -m \"adding a file\"<\/code><br \/>\nMove: <code>svn move src\/myfile.java src\/mynewfile.java -m \"moved myfile.java to mynewfile.java\"<\/code><br \/>\nDelete: <code>svn delete src\/myfile.java -m \"removing a file\"<\/code><br \/>\nCommit: <code>svn commit src\/myfile.java -m \"the message\"<\/code><\/p>\n<p>That&#8217;s it&#8230; there&#8217;s a alot more to read.  One of the coolest things about Subversion is that the documentation is all packaged up into a free PDF published by Oreilly, which you can download <a href=\"http:\/\/svnbook.red-bean.com\/\">here<\/a>. I printed out the manual and breezed through it in a couple hours.  You should too.<\/p>\n<p>I did try to get the <a href=\"http:\/\/subclipse.tigris.org\/\">Subclipse Eclipse Subversion plugin<\/a> working, but for the life of me&#8230; I couldn&#8217;t. I think it ended up for the better anyhow because while the command line is a bit more tedious, I understand more about what&#8217;s going on in the system, which is helpful. I&#8217;d recommend that you get familiar with the command line client before attempting to use a GUI plugin.<\/p>\n<p>After you&#8217;re all set with Subversion and you&#8217;re ready to get started with CruiseControl, note that while Cruisecontrol contains an <code>&lt;svn&gt;<\/code> tag, you still need to drop down into command line mode in Ant to checkout \/ update your local repository when doing an automated build. For example: <code><br \/>\n&lt;exec executable=\"svn\"&gt;<br \/>\n&nbsp;&nbsp;&lt;arg line=\"update\"\/&gt;<br \/>\n&lt;\/exec&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re getting around to hiring an additional me at work so I needed to get a source control solution in place before he\/she arrives and starts hacking away at the codebases. At the last place I worked we used Visual SourceSafe for a long time (which was pretty worthless) and then started using CVS, although &hellip; <a href=\"https:\/\/cephas.net\/blog\/2004\/12\/09\/source-control-with-subversion-on-windows\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Source Control with Subversion on Windows<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4,2,12],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/648"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=648"}],"version-history":[{"count":3,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/648\/revisions"}],"predecessor-version":[{"id":3059,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/648\/revisions\/3059"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}