Register to post in forums, or Log in to your existing account
Zugg Software :: View Entry - Must be a better way - putting project into SVN
Post new entry     Home » Forums » Zugg's Blog

Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Mon Aug 25, 2008 8:04 pm   

Must be a better way - putting project into SVN
As you know, I use SubVersion (svn) for my version control system.

But I've been lazy. Since I upgraded to Vista and Delphi 2007, I hadn't put my new Delphi 2007 source code into svn yet.

Today I decided it was time. And I discovered again why this is such a pain and why I had postponed it. I've probably whined about this in the past, but I'll bring it up again to see if there is a better way to do this.

The task is simple: Load source code from an existing project directory into Subversion and start managing it.

Seems simple at first. But the details are driving me crazy.

Here is the tricky part: This "Project" directory contains more than just *.pas source code files. It contains compiled dcu files and all sorts of other crap (including the final EXE files). Yes, I probably could have designed a better directory structure in the beginning and put the *.pas files into their own directory...but I didn't.

So the task is to take the existing "Project" directory and only put the *.pas source code into the Subversion repository. (In reality I have several other file types like *.dfm that also get added, but let's keep this example simple).

First I set up the file extensions that I want svn to ignore. This is pretty easy with TortoiseSVN since it has a "global ignore pattern" setting.

Next, it seems that I just do an "svn import" of the "Projects" directory to put the source code into the svn repository. In this example, I use a URL of "svn://localhost/Project/trunk". The *.pas files are added just fine.

So now the source code is in the repository, but now I need to check it out back into my "Projects" directory so that I have a working copy that is tracked by svn. I try to do a "Checkout" but it complains that the *.pas files already exist.

Well, of *course* they already exist...these are the same files that I just *imported* into svn. Can't svn realize that these are exactly the same files??? Apparently not.

So here is the annoying procedure I have come up with to perform this task:

1) Use svn import on the Project directory to get the files into svn
2) Rename the "Project" directory to "Project-orig"
3) Use svn checkout to bring the files back from the repository into a directory called "Project"
4) Manually copy the .svn hidden subfolder from the new "Project" directory into the "Project-orig" directory.
5) Delete the "Project" directory
6) Rename the "Project-orig" directory back to just "Project"

This works, but it seems like such a mess! Isn't there some option for placing an existing directory into SVN and causing it to create the .svn hidden subdirectories all at once without all of this extra mess?

It's this kind of complexity that turns people off to version control. I know that this is exactly why I've postponed getting this set up again since I upgraded everything to Delphi 2007. I'm wasting a whole day getting this all set up (since I have multiple "Project" directories to do this with, and some include subdirectories which just add to the mess).
Reply with quote

Joined: 10 Oct 2000
Posts: 1551
Location: Australia

PostPosted: Tue Aug 26, 2008 8:15 am   
The way I tend to use tortoise/svn is I will have a global directory eg "projects" which is a repository, then under that projects repository, I have sub directories for each of my clients/programs... that way it's just a matter of doing a tortoise add folder to the "global" repository, instead of having to create a new repository for every single client/program I have.

Technically that's not as "good" because it means I can't shuffle a project off to its own repository later and retain the history, but since I usually have a new project every 2-3 weeks, I would be creating a lot of repositories.
Reply with quote

Joined: 09 Oct 2003
Posts: 459
Location: USA

PostPosted: Tue Aug 26, 2008 6:31 pm   
I use TracSVN with multiple repositories. I have a little batch script on the SVN server that I run with two parameters: svncreate "Long Name of Application Being Written" shortname

Then it goes through and creates my repository, my Trac site, creates the permissions for both and all that jazz. It's nice for the new project every 2-3 weeks type thing and there is a main page that lists all of the projects that Trac is taking care of. (And yes, this is running on Windows server and not *nix).

However, trying to import old projects is always a pain especially half-importing them like you ran into with the delphi 2007 stuff.

Ichthus on SWmud:
Reply with quote

Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Tue Aug 26, 2008 7:41 pm   
Of course in my case I don't have new projects every 2-3 weeks. It's one of the reasons I postponed dealing with this when I decided to make a fresh start with the Delphi 2007 conversion. If I had just stuck with the existing Delphi 7 repository then it would already be set up. But since I wanted to leave the Delphi 7 version of CMUD untouched when I upgraded to Delphi 2007, I create a new project directory and copied over the source code. So this is only something I do every few years.

It just still surprised me that this was still so hard to do. For example, on my Laptop I now have the same problem. I need to attach my Delphi Projects directory on my laptop to the new Delphi 2007 SVN repository. But it's just going to complain that the files already exist in the directory.

It's like SVN needs some sort of "force" option to say "yes, I *know* the files already exist...just overwrite them anyway!!!". That's really all I want to do. I *know* the files on my laptop are older versions and I just want them to get overwritten by the latest version from the SVN repository and to get all of the hidden .svn directories created so that I can make changes on the laptop and commit them to the repository.

Like I said, this is why some people don't use version control. It can be *such* a PAIN sometimes, and for no good reason. They just set up a rule that version control should *never* overwrite any files and have stuck to that with no exceptions, even when it doesn't make any sense.

SVN is supposed to be "better" and "smarter" than the older CVS system. But it still has plenty of problems like this that make it a pain.
Reply with quote

Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Sun Sep 14, 2008 8:42 pm   
The assumption is (generally) that your files are either a) checked-in to the repository or b) possible to create from the checked-in files. Therefore all you need to do is: import all the files that you use to create stuff, then throw away the original source dir (or rename just in case), then checkout the project again, and continue using that.

I realise some projects may not quite conform to this pattern.. tho to be honest I can't see why not.

(I have a project where crazily the files are in cvs and some of them are in svn, it was a test, honest.. To update a cvs checkout with the svn one and the .svn files, I just used rsync to copy one over top of the other.. works fine)

Reply with quote

Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Mon Sep 15, 2008 7:06 pm   
Heya Castaway! Great to hear from you. Yeah, in my case I have a bunch of other files in the source dir (compiled files, etc), so I can't just throw it away. But I used to use a similar procedure where I'd a) import the files, b) rename the original directory, c) checkout the project, then d) copy the original directory back over the new directory. That achieved the same effect, but still seemed like a kludge.

Since SVN (and any other version control system) can compare checksums of files to tell if they are the same, it still seems like it should be smart enough when doing a checkout to an existing directory to be able to tell that the existing files are the exact same as the ones in the repository and not issue any warning unless it tries to overwrite a file that is actually different.
Reply with quote
Display posts from previous:   
Post new entry   Reply to entry     Home » Forums » Zugg's Blog All times are GMT
Page 1 of 1

Jump to:  
You cannot post new entries in this Blog
You cannot reply to entries in this Blog
You cannot edit your posts in this Blog
You cannot delete your posts in this Blog
© 2009 Zugg Software. Hosted on