Change depth in existing SVN working copy without redownloading
Asked Answered
S

5

40

I have a working copy of an entire SVN repository, but I want to change it into a sparse working copy because of disk space issues.

One way to do this would be:

svn up --set-depth immediates projects
svn up --set-depth infinity projects/project1
svn up --set-depth infinity projects/project2

However, that would first delete project1 and project2, then redownload them. This is really inconvenient, because they're very large and the server's upload speed is very low. I tried this (with another, smaller, part of the repo, as an experiment):

svn up --set-depth infinity projects/project1
svn up --set-depth infinity projects/project2
svn up --set-depth immediates projects

But then the last command just undoes the first 2.

How can I set the depth of a working copy without it immediately updating/changing it, so I can have the chance to correctly configure subdirectories first?

Or is there another way to accomplish what I want, e.g. by copying project1 and project2 to a safe location first?

Spearmint answered 28/8, 2011 at 19:26 Comment(0)
E
32

Woo hoo, I had this problem, and TortoiseSVN has supported solutions for both add and delete an item from the sparse checkout. http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-checkout.html

1.To add: In windows explorer, Right click on the checked out folder, then use TortoiseSVN ? Repo-Browser to bring up the repository browser. Find the sub-folder you would like to add to your working copy, then use Context Menu ? Update item to revision....

2.To delete; From your root, right-click / Repo-Browser / Update item to revision; then select 'Exclude'.

Everetteeverglade answered 29/3, 2013 at 18:46 Comment(1)
You don't have to go through the repo browser. TortoiseSVN's contextual menu has the "Update to revision..." option. Just right-click on the excluded folders themselves rather than the working directory root. Of course, this assumes a stub folder (empty excluded folder) exists in your path.Almedaalmeeta
S
3

I ended up hacking it:

  • Manually edit the depth setting to "immediates" for projects *.
  • Hard delete (not SVN delete) all children of projects except project1 and project2
  • svn up projects

[*] To do this, open up projects/.svn/entries in a text editor and change

b125e325-6f7c-4931-9942-d1ea1ea1441a
X

into

b125e325-6f7c-4931-9942-d1ea1ea1441a







immediates
X

Note: That UUID-looking line is probably different per repo, and X is actually hex value 0x0C which I can't get displayed here on SO.

Spearmint answered 28/8, 2011 at 20:5 Comment(0)
S
1

I had the same problem, but what you wrote doesn't seem be possible in SVN 1.7, since the metadata format looks different.

Here's what I ended up doing (using the directories in your situation). First, I copied project1 and project2 somewhere safe.

svn co --depth immediates svn_url/projects 

This checks out projects with empty directories project1 and project2. I then delete the empty folders and put the actual directories in their place. SVN gives me some weird messages but it seems to work and allows me to commit. (It does not work with --depth empty and then copying the folders in, but immediates seems to work.)

I agree this situation is not ideal, but that's why I'm switching to Git for future projects! I've used SVN for a long time, but it is getting beyond hope.

Spoliate answered 29/9, 2012 at 1:39 Comment(0)
S
1

Nothing like reviving an old SO Question.

I have been working with a very similar problem where I branch from trunk to create a release package but due to limitations I have to clone files which are only intended for dev.

asset
└── js
    └── some
        └── directories
            ├── assets
            │   ├── files ...
            ├── dev       **<------------ This folder needs to be empty**
            │   ├── apis
            │   ├── campaign
            │   ├── features
            │   ├── modules
            │   ├── main.js
            │   └── tags
            └── release
                ├── apis
                ├── data
                ├── features
                ├── modules
                ├── main.js
                └── tags

I decided that I would exclude the dev files to remove the temptation to patch a fix in the release branch in the wrong directory.

I do a lot of sparse checkouts to avoid large folders in trunk but have never done it retrospectively on a working copy. It seems this is pretty straight forward.

To modify the working copy so that asset/js/some/directories/devis empty you can simply run the svn co command again on the working copy.

In my case the following works

svn co --depth empty ^/branches/releases/latest/asset/js/some/directories/dev \
asset/js/some/directories/dev

You are basically running a partial checkout on your pre-existing working copy and this will work at any level. In the original case you would simply run the following.

svn co --depth immediates ^/branches/mybranch/projects projects
svn co --depth immediates ^/branches/mybranch/project1 project1
svn co --depth immediates ^/branches/mybranch/project2 project2

For those that don't know the caret ^ is shorthand for the repository root so it works like a relative path on your repository a little like ../some/location.

The key here is that you are not creating a new working copy to fix your problem. You are running these commands on your existing working copy and resetting the depth of your chosen directories.

Showplace answered 18/10, 2017 at 8:36 Comment(0)
F
0

I don't know why people are doing things the hard way in the other answers.

Since Subversion 1.6 it's possible to simply do svn update --set-depth exclude <directory_you_want_to_prune_from_local_working_copy>

Farflung answered 11/3, 2019 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.