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

Selectively checking out and working on subprojects?

From: Junio C Hamano <junkio_at_cox.net>
Date: 2004-02-05 12:21:12 CET

I have two related questions (running 0.37.0 r8509 from Debian).

1. What is the right way to check out part of a project from a
   repository, keeping track of what is and what is not
   currently checked out, leaving the possibility of later
   checking them out and/or pruning some unneeded subtree from
   the working directory?

2. When does "svn co -N" make any sense?

Suppose I have gcc, libc, kernel, xfree86, and tex under /pub in
a repository. Each of these projects is big, so I want to work
on a couple of them at a time.

I know I can first check out everything and then remove things I
do not plan to work on right now (in this example, each project
just has one file called "1").

    $ R=file://`pwd`/repo
    $ svn co $R/pub
    A pub/kernel
    A pub/kernel/1
    A pub/tex
    A pub/tex/1
    A pub/xfree86
    A pub/xfree86/1
    A pub/libc
    A pub/libc/1
    A pub/gcc
    A pub/gcc/1
    Checked out revision 1.
    $ rm -fr pub/[txlg]*
    $ ls -A pub
    .svn kernel

Subversion knows that I removed these subdirectories.

    $ svn st
    ! tex
    ! xfree86
    ! libc
    ! gcc

More importantly, if I later want to start working on one of
them, it lets me update it.

    $ svn up tex
    A tex
    A tex/1
    Updated to revision 1.
    $ vi tex/1 ;: hack away
    $ svn commit -m 'hacked tex' tex

This, however, is an embarrassingly inefficient way of doing
things. I expected that the -N (nonrecursive) flag to "svn co"
would give me the behaviour I wanted without requiring a full
initial checkout, so I tried the following, which did not work:

    $ rm -fr pub ; : give me a clean slate
    $ svn co -N $R/pub
    Checked out revision 1.
    $ cd pub
    $ find . -print -name .svn -prune
    .
    ./.svn

So far, looks good; the working directory has nothing
there--nonrecursive works as advertised.

    $ svn ls
    gcc/
    kernel/
    libc/
    tex/
    xfree86/

Also looks good; subversion knows that the repository that
corresponds to my working directory has these projects hanging
below it....

    $ svn st

... not really; "svn st" does not show anything.

    $ svn up gcc
    svn: 'gcc' is not under version control
    $ ls -A
    .svn

... and update does not work either.

Worse yet, an attempt to check out gcc into this working
directory does not work. It creats gcc directory but checkout
fails, like this:

    $ svn co $R/pub/gcc
    svn: Working copy 'gcc' not locked
    $ find . -print -name .svn -prune
    .
    ./.svn
    ./gcc
    ./gcc/.svn

In short, working directory created with "svn co -N" does not
seem to be of any use.

What am I missing?

Here is the full transcript to reproduce the experiment:

  1. Preparing a test repository.

    $ rm -fr repo workdir pub
    $ R=file://`pwd`/repo
    $ svnadmin create repo
    $ svn co $R workdir
    Checked out revision 0.
    $ cd workdir
    $ mkdir pub
    $ for project in gcc libc kernel xfree86 tex
> do
> mkdir pub/$project
> date >pub/$project/1
> done
    $ svn add [a-z]*
    A pub
    A pub/gcc
    A pub/gcc/1
    A pub/libc
    A pub/libc/1
    A pub/kernel
    A pub/kernel/1
    A pub/xfree86
    A pub/xfree86/1
    A pub/tex
    A pub/tex/1
    $ svn commit -m 'Import a bunch.'
    Adding pub
    Adding pub/gcc
    Adding pub/gcc/1
    Adding pub/kernel
    Adding pub/kernel/1
    Adding pub/libc
    Adding pub/libc/1
    Adding pub/tex
    Adding pub/tex/1
    Adding pub/xfree86
    Adding pub/xfree86/1
    Transmitting file data .....
    Committed revision 1.
    $ cd ..
    $ rm -fr workdir

  2. Full checkout followed by selective removal works as expected.

    $ svn co $R/pub
    A pub/kernel
    A pub/kernel/1
    A pub/tex
    A pub/tex/1
    A pub/xfree86
    A pub/xfree86/1
    A pub/libc
    A pub/libc/1
    A pub/gcc
    A pub/gcc/1
    Checked out revision 1.
    $ find pub -print -name .svn -prune
    pub
    pub/.svn
    pub/kernel
    pub/kernel/.svn
    pub/kernel/1
    pub/tex
    pub/tex/.svn
    pub/tex/1
    pub/xfree86
    pub/xfree86/.svn
    pub/xfree86/1
    pub/libc
    pub/libc/.svn
    pub/libc/1
    pub/gcc
    pub/gcc/.svn
    pub/gcc/1
    $ rm -fr pub/[txlg]*
    $ ls -A pub
    .svn kernel
    $ svn st
    ! tex
    ! xfree86
    ! libc
    ! gcc
    $ svn up tex
    A tex
    A tex/1
    Updated to revision 1.

  3. Partial checkout attempt with -N (nonrecursive) does not
     seem to be useful at all.

    $ rm -fr pub
    $ svn co -N $R/pub
    Checked out revision 1.
    $ cd pub
    $ find . -print -name .svn -prune
    .
    ./.svn
    $ svn ls
    gcc/
    kernel/
    libc/
    tex/
    xfree86/
    $ svn up gcc
    svn: 'gcc' is not under version control
    $ svn co $R/pub/gcc gcc
    svn: Working copy 'gcc' not locked
    $ find . -name .svn -prune -o -print
    .
    ./gcc
    $ find . -print -name .svn -prune
    .
    ./.svn
    ./gcc
    ./gcc/.svn
    $ rm -fr gcc
    $ svn co $R/pub/gcc gcc
    svn: Working copy 'gcc' not locked
    $ find . -print -name .svn -prune
    .
    ./.svn
    ./gcc
    ./gcc/.svn
    $ rm -fr gcc
    $ cd ..

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Feb 5 12:21:31 2004

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.