Search code examples
svnbulkwhitelistsparse-checkout

SVN - Sparse Checkout Files of Certain Type -or- Matching Certain Pattern


I am working with a massive SVN repository -- which is made up of hundreds of directories (all at varying depths), and thousands of files (all of varying types). I need to make bulk updates to a couple hundred JavaScript files contained in this repo. Instead of downloading the entire repo, I was hoping to selectively checkout only the .js files. I have been playing around with a bunch of different methods, but haven't been able to crack it. Here's what I was able to come up with...

# CHECKOUT INITIAL WORKING COPY
svn co https://myrepo.com/site-content --depth empty

# NAVIGATE TO WORKING COPY
cd site-content

# CHECKOUT FULL DIRECTORY TREE
env REPO=https://myrepo.com/site-content sh -c 'svn ls -R $REPO | grep "/\$" | xargs -n 1 svn co --depth empty $REPO'

# UPDATE WORKING COPY WITH .JS FILES
svn up `svn ls -R https://myrepo.com/site-content | grep .js$`

The responses I'm getting back in Terminal seem to indicate that everything worked, however, that's clearly not the case. I'm left with the full directory tree, but absolutely no .js files. Here’s a sample of my terminal output:

jakes-mac:working-copy jake$ svn co https://myrepo.com/site-content --depth empty

    Checked out revision 21097.

jakes-mac:working-copy jake$ cd site-content

jakes-mac:site-content jake$ env REPO=https://myrepo.com/site-content sh -c 'svn ls -R $REPO | grep "/\$" | xargs -n 1 svn co --depth empty $REPO'

    Checked out revision 21098.
    Checked out revision 21098.
    Checked out revision 21098.
    Checked out revision 21098.
    Checked out revision 21098.
    ...
    Checked out revision 21099.
    Checked out revision 21099.
    Checked out revision 21099.
    Checked out revision 21099.
    Checked out revision 21099.

jakes-mac:site-content jake$ svn up `svn ls -R https://myrepo.com/site-content | grep .js$`

    Updating '2013/js/_old/script.trees.bak.rev-a.js':
    At revision 21100.
    Updating '2013/js/_old/script.video.bak.rev-a.js':
    At revision 21100.
    Updating '2013/js/script.category.js':
    At revision 21100.
    Updating '2013/js/script.trees.js':
    At revision 21100.
    Updating '2013/js/script.video-v2.js':
    At revision 21100.
    Updating '2013/js/script.video.js':
    At revision 21100.
    Updating '2014/TreeGiveaway/js/script.sweeps.js':
    At revision 21100.
    Updating '2014/TreeGiveaway/js/validate-voting.js':
    At revision 21100.
    Updating '2014/js/collectionslider.js':
    At revision 21100.
    Updating '2014/js/difference.js':
    At revision 21100.
    Updating '2014/js/mobile.js':
    At revision 21100.
    Updating '2014/js/script.category.js':
    At revision 21100.
    Updating '2014/js/script.quicklight_inset.js':
    At revision 21100.
    Updating '2014/js/script.trees.js':
    At revision 21100.
    Updating '2014/js/script.trees.v3.js':
    At revision 21100.
    Updating '2014/js/script.trees_inset.js':
    At revision 21100.
    Updating '2014/js/script.trees_inset.new.js':
    At revision 21100.
    Updating '2014/slideshow/js/jquery.easing.min.js':
    At revision 21100.
    Updating '2014/slideshow/js/script.js':
    At revision 21100.
    Updating '2014/slideshow/js/supersized.3.2.7.js':
    At revision 21100.
    Updating '2014/slideshow/js/supersized.shutter.js':
    At revision 21100.
    Updating '2015/js/framework.fetchFeed.js':
    At revision 21100.
    Updating '2015/js/framework.goModal.js':
    At revision 21100.
    Updating '2015/js/frameworkForMobile.js':
    At revision 21100.
    Updating '2015/js/script.category.js':
    At revision 21100.
    Updating '2015/js/script.hs.js':
    At revision 21100.
    Updating '2015/js/script.shop-the-scene.js':
    At revision 21100.
    Updating '2015/js/script.trees.js':
    At revision 21100.
    Updating '2015/tree-finder/results.script-v2.js':
    At revision 21100.
    Updating '2015/tree-finder/results.script.js':
    At revision 21100.
    Updating '2015/tree-finder/wizard.script.js':
    At revision 21100.
    Updating 'current/js/holiday-decor.js':
    At revision 21100.
    Updating 'current/js/how-to.js':
    At revision 21100.
    Updating 'current/js/shop-the-style.js':
    At revision 21100.

EDIT:

All working now! Final command list:

# CHECKOUT INITIAL WORKING COPY
svn co https://myrepo.com/site-content --depth empty

# NAVIGATE TO WORKING COPY
cd site-content

# CHECKOUT FULL DIRECTORY TREE
env REPO=https://myrepo.com/site-content sh -c 'svn ls -R $REPO | grep "/\$" | while read dir; do svn co --depth=empty $REPO/$dir $dir; done'

# UPDATE WORKING COPY WITH .JS FILES
svn up `svn ls -R https://myrepo.com/site-content | grep .js$`

# COMMIT ALL CHANGES TO REPO
svn commit `svn ls -R | grep .js$` -m "Bulk Updating Content"

Solution

  • With your "CHECKOUT FULL DIRECTORY TREE" command you checked out the repository root over an over again in all your directories.

    env REPO=https://myrepo.com/site-content sh -c 'svn ls -R $REPO | \
    grep "/\$" | xargs -n 1 svn co --depth empty $REPO'
                                                 ^^^^^
    

    See the output of e.g. svn info 2014/js/

    "... seem to indicate that everything worked, " - it is not true, as one don't see a line like
    A <filename> e.g.

    Updating '2014/js/script.trees.v3.js':
    A    2014/js/script.trees.v3.js
    

    Try something like this:

    env REPO=https://myrepo.com/site-content sh -c 'svn ls -R $REPO | \
        grep "/\$" | while read dir; do svn co --depth=empty $REPO/$dir $dir; done'