[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Make a working copy from an export

From: Kyle McKay <mackyle_at_gmail.com>
Date: Sun, 19 Apr 2009 14:04:33 -0700

On Apr 16, 2009, at 06:17:59 PDT, David Shere
<dshere_at_steelerubber.com> wrote:
> I have an export of my repository which I wish to make into a working
> copy.
>
> Here's my situation:
> I use Subversion to manage my music library. I have a working copy at
> home and at work, and sometimes check out portions in other places. I
> recently deleted my working copy at work and need to restore it. The
> server is hosted at home, so when I check out at work, I'm depending
> on
> my upload bandwidth at home, which is minimal. An export of the
> library
> is 10GB, but a working copy is 21GB. I can bring an export to work on
> my 16GB USB Flash drive, but the flash drive is too small for a
> working
> copy. That's why I want to put an export on my flash drive (at home),
> take it to work, and then convert the export to a working copy.
>
> This hasn't been an issue in the past because each update at work was
> only a handful of files, since I was adding music to the repository
> one
> album at a time. Now that I have to check out the entire library, it
> becomes a much more bandwidth-hungry operation. I have seen some
> tutorials on how to make an export from a working copy, but not the
> other way around. I would make no changes to the export.
>
> I realize there are other ways to do this:
> 1. Use the flash drive to copy half of the working copy one day and
> the
> other half the next day
> 2. Run a series of checkout/interrupt iterations at work.
> I'm wondering if there's a tool in Subversion to do the work for me.

Instead you could check out a working copy at home. Remove the
non .svn related files, copy it to your flash drive, take it to work,
copy it to your work machine, restore the regular files, and switch
the URL.

If you have a unix-like (i.e. Linux/MacOSX) machine at home, here's
how you could do this:

1. For the following assume that when at home the URL to checkout your
working copy is:

   file:///svn/project/trunk

and that when you are at work the URL to checkout the same working
copy is:

   svn+ssh://home.machine/svn/project/trunk

2. Assume that the temporary working copy on your home machine is to
be created in:

   /tmp/svn/project_towork

3. Assume that your flash drive can be found at:

   /Volumes/Flash

   (That's the same path both at home and at work)

4. Assume that at work your final working copy is going to live in:

   /Users/me/project

5. First checkout a fresh working copy at home (you could skip this
step and use an existing working copy provided it has NO modifications
-- svn stat shows nothing -- not recommended though as any
svn:ignore'd files will be removed and you'll have to run a recursive -
R revert on it later)

   mkdir -p /tmp/svn/project_towork
   svn co file:///svn/project/trunk /tmp/svn/project_towork

6. Now remove all non-.svn files from the new working copy (BE VERY
CARFUL WITH THIS STEP!)

   find /tmp/svn/project_towork -name .svn -prune -o -type f -print0 |
     xargs -0 rm -f

   NOTE: That's actually one line that's been wrapped. If you break
it after the | as shown above the shell will prompt you for the rest
or you can just unwrap it onto one line when you enter it.

   BE VERY CAREFUL WITH THIS STEP -- variations of the above command
could remove more than just the non-.svn files in your new working copy.

7. Verify that the newly pared down working copy will fit on your
flash drive:

   du -hs /tmp/svn/project_towork # Size of working copy as-is
   tar czf - . | wc -c # Size tar archive would be in BYTES

   NOTE: you can skip this step or use any other method to verify the
size. The above tar command will take almost as long to run as
actually creating the archive in the first place.

8. Create a tar archive of the newly pared down checkout on your flash
drive.

   cd /tmp/svn/project_towork
   tar czf /Volumes/Flash/svn_towork.tgz .

   NOTE: You can just copy the /tmp/svn/project_towork directory
directly to the flash drive, but using a tar archive makes sure you
don't miss any of the "." files and helps reduce the space needed by
consolidating everything into one file.

-- svn_towork.tgz TRAVELS VIA FLASH DRIVE SNEAKER NET TO WORK --

8. Unpack your tar archive at work.

   IMPORTANT: Make sure the destination directory doesn't already
exist or it's empty!

   mkdir -p /Users/me/project
   tar xvf /Volumes/Flash/svn_towork.tgz -C /Users/me/project

   NOTE: If you didn't use a tar archive in the first place, just copy
the working copy directory off the flash drive into the /Users/me
directory and then rename it to project.

9. Have svn restore the removed files from the copies in the .svn
subdirectories

   svn -R revert /Users/me/project

   NOTE: Be sure you get the path in the above command correct or you
could end up reverting files you don't intend to. Also this step
could take a while to run on a large checkout.

10. Switch the working copy URL so that it can be used from work.

   cd /Users/me/project
   svn switch --relocate file:///svn/ svn+ssh://home.machine/svn/

   NOTE: You can also use the two full URLs here instead but they
wouldn't fit on the above line.

OTHER NOTES:

* This leaves an unused, pared-down working copy in /tmp/svn/
project_towork on your home machine. You can manually delete that or
use something like:

   rm -rf /tmp/svn/project_towork # BE VERY CAREFUL ABOUT TYPOS!

* If you used an existing working copy at home (and skipped step 5)
then you'll need to cd to its directory and run this command before
you start using it again:

   svn -R revert .

* The pared-down working copy created in step 6 will be just a little
bit larger than an export, but not much -- using a tar archive as
shown above will minimize the difference.

Kyle

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1812455

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-04-19 23:05:29 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.