swestrup: (Default)
[personal profile] swestrup
I've just spent the last 3 hours fighting with subversion, and I still haven't managed to do what I was trying. You see, by far the most common use-case I've ever had for Subversion is one that they don't cover at all in their documentation, and seem to think is non-existent, and that is the migration from some ad-hoc version control system.

For example, just now I came across some old archives of snapshots of a project. They were all named things like 'foo-project-<DATESTAMP>.zip' and had been made just by copying and zipping the project filetree in its current state. What I need is some way to present successive snapshots to subversion in such a way that:
  • newly appearing files are automatically added to the archive.
  • vanishing files are automatically deleted
Ideally, it should be as easy as doing a series of commands like
#!/bin/bash

for zip in foo-project-*.zip; 
do
  unzip -d foo $zip
  svn import --update -m "automated import" foo file:///path/foo/trunk
  rm -rf foo-project
done
Or something along those lines. Instead, you have to:
  1. import the first snapshot to make the repository.
  2. checkout a copy of the repository
  3. unzip the next snapshot
  4. diff the working copy against the snapshot
  5. manually mark and delete any files that have vanished.
  6. copy the snapshot over the current copy.
  7. commit this new version
  8. delete the snapshot, and goto step 2.
ARGH!!!  There has GOT to be an easier way, I keep telling myself, but I haven't found one.

Date: 2007-09-16 12:49 pm (UTC)
From: [identity profile] skjalm.livejournal.com
How about unzipping the first and importing it then unpacking the next archive on top of the first and committing that version (adding any files that wasn't in the previouse set) and so on?

You should be able to find added/removed files by using either svn diff or svn status (or whatever it's called - I haven't used svn that much yet)

Date: 2007-09-16 09:02 pm (UTC)
From: [identity profile] peaceful-dragon.livejournal.com
Ah yes, the "svn status" command is essential. Run it every time you unzip a new one, and it'll tell you exactly which files have been changed or added.

Problem is deletion though... Can't know which ones have been deleted.

Date: 2007-09-16 11:40 pm (UTC)
From: [identity profile] cpirate.livejournal.com
Sure, you just have to delete the working copy files (but not the .svn directories) before unzipping the new tarball. Then "svn status" will tell you that there are files missing from the working copy.

It is definitely still a pain. I'm a bit surprised nobody's hacked that up yet. One strategy might be to hack together the worst possible implementation of something barely resembling this, and guilt other people into fixing it instead of outright rejecting it :)

Date: 2007-09-16 03:39 pm (UTC)
From: [identity profile] joenotcharles.livejournal.com
If CVS can do this (dunno if it can or not), you could import the ad-hoc files into CVS and then import the CVS repository into Subversion. (Substitute any other version control system that Subversion can import from for CVS.)

The bit about searching for new or deleted files can't be too hard to script, though, can it?

Date: 2007-09-17 04:45 pm (UTC)
From: [identity profile] hendrikboom.livejournal.com
It seems to me I did this with monotone a while ago. The only hard part was me figuring out which of the files in the snapshot were source, and which were generated from source (I didn't want to archive generated files).

January 2017

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 13th, 2026 05:46 pm
Powered by Dreamwidth Studios