Topic: Subversion Help

I'm a sourcesafe user so I'm struggling with subversion a little.  I am running windows xp and I set up a free repository at unfuddle.  I have installed tortoisesvn client on my pc.  I navigated to my rails development directory which is at C:\InstantRails\rails_apps\ then I right clicked on my project which is called cedar and imported it to subversion.  Worked great and I could see my project through unfuddle's site.

The editor that I use is Komodo Edit so I open up my editor and edit some code and save it.  I was expecting some kind of message that the file was readonly or something but didn't get that.  It let me save the changes without any warnings. 

It appears to me that this is a lot more manual than sourcesafe and most of the tutorials seem to be for the mac or linux/unix.  I watched the railscast but I'm still struggling here for some reason. 

Can someone who uses Windows/rails/subversion tell me the steps that you took to get your repository setup and how you use it on a daily basis.


Re: Subversion Help

I think your setup is working as expected, I was initially confused myself when I started using subversion. I have been using SourceJammer, where all files are marked as read-only unless you check the file out. Once you have a file checked out other users are unable to modify the file until you've checked it back in, this is referred to as the Lock-Modify-Unlock approach.

Subversion uses the Copy-Modify-Merge Solution, from the help:

Subversion, CVS, and other version control systems use a copy-modify-merge model as an alternative to locking. In this model, each user's client reads the repository and creates a personal working copy of the file or project. Users then work in parallel, modifying their private copies. Finally, the private copies are merged together into a new, final version. The version control system often assists with the merging, but ultimately a human being is responsible for making it happen correctly.

So in subversion you can modify any file you wish in your working copy, when you commit your changes subversion will merge them with changes from other users. All this is very well explained in the help available with TortoiseSVN, see section 2.2. Versioning Models

Re: Subversion Help

So take a look at my Work Flow and see where I'm missing something or just wrong.  I have no idea why I'm having such a hard time figuring this out.  I know you can use the subversion command line tool, but I'll use tortoise for this example.

1. Open Ruby Console Window through Instant Rails and type "rails cedar" to create a project called cedar.  This creates the project at c:/InstantRails/rails_apps/cedar.
2. Open Windows Explorer, navigate to project, right click on it, go to TortoiseSVN -> import.  I know that I can exclude files, but for not let's assume I want to track all files.
3. I follow the steps for Tortoise and get my project into the repository.
4. Now I want to begin working on the source code, so I navigate to my project in windows explorer and right click then click SVN Checkout.

Question: Do I check out the entire project or just a folder or file I want to work on?  Does it matter?  When I click on the project and say Checkout, I get a message saying the Target folder is not empty are you sure you want to check out into that file?

Question: Should I have another area on my disk that I work on the project then when I commit changes, copy it to c:/InstantRails/rails_apps/cedar or should I just work on it there?

Question: Is it possible to check out individual items or do I have to check out a folder? With tortoise it looks like I can only check out folders.

5. Make some changes, then right click folder and click commit. 

Is this all I need to know to get started?  What I am missing or misstating?

Last edited by mroosa (2007-12-07 08:59:09)

Re: Subversion Help

You don't check out files that you work on each time you want to work on a file. I think you didn't get the concept behind it fully yet.

1) You Import the full project structure into the repository when yozu start your project.

2) you checkout the entire project again, simply overwriting the files you just imported. This makes subversion mark this directory as a checked-out working copy of the repository.

3) you work on files in this directory directly,you don't need to (and shouldn't) copy the files anywhere else. This is your working copy, so work on it wink

4) you commit changed files to svn. When another user already changed that file, subversion first gets the new version and tries to mergs your changes and the ones made by the other programmer automatically. If that doesn't work, because you changed the same part of the code, you will be asked to do the merge manually.

4a) After the merge, you commit the new file.

5) Programmer 2 does an svn update before he gets to work the next day, and gets the new version of the file with your merge.

So in short:
- you only check out our entire project once. (or later again to your production server)
- you always wortk on this checked out copy.
- you commit changes
- subversion will merge changes, when conflicts arise, you have to do it on your own.
- before you work on, do an svn update to reveice updated versions of files changed by other users.

Re: Subversion Help

Duplex, thanks a lot.  That really cleared some things up and answered my questions. 

I think I got the basics now.  When I do the commit, I right click on the project folder and click commit.  It pulls up a windows form where I can enter the log message.  It also lists all the files in the project.  Do I need to manually check off each one that I changed or do I just click select all and then commit?

Re: Subversion Help

you won't want to commit the whole project all the time, you can commit only one file (right-click it and commit it) or a couple ... you will want to only commit the files you actually changed/created.

- Change one/many file(s)
- want to save the changes (e.g. you are pretty sure the code is solid and worth a new revision)
- commit the file.
- continue coding.

Some IDEs like Apatana have built-in svn support and show you what files were changed since the last commit, do the commiting from inside the IDE, auto-commit changes on exit of the IDE and other features ...

Last edited by Duplex (2007-12-07 13:56:27)

Re: Subversion Help

Thanks, I think I got it now.  For some reason subversion wasn't tracking my changes locally before but not it seems to be.  Thanks.