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

RE: Re: Best practice for partial repository checkout

From: Jan Hardenbergh <hardenbergh_at_terarecon.com>
Date: Thu, 22 May 2008 10:59:59 -0400

Faced with exactly the same situation, we chose to only checkout what needed to be checked out for each project.

So, for the sw library product, we only need (for example...)

 common/PNGFile
 common/include
 hw/falcon/include
 sw/xyz
 sw/utils

We have one script which does the initial checkout and another script that updates the tree - both use pysvn. Here is the update script:

# svnwalk.py - walk the subdirectories of '.' and find .svn caches and see if there are any modified or added files.
# We need to do this because we checkout a long list of directories at differing levels of the source tree.
# for a directory that has .svn, the only dirs that should survive are the ones that are not versioned,
# because they will have a .svn further down the tree. November 2007 AFV (jch prototype).

import sys
import os
import pysvn
import time

verbose = False
veryVerbose = False
update = False
dots = False
showExtras = False
slow = False

def login(*args):
    return True, 'vgsw', '@source', False

def main():
    global verbose
    global veryVerbose
    global update
    global dots
    global showExtras
    global slow
    
    revdate = revision=pysvn.Revision( pysvn.opt_revision_kind.head ) # default for update is HEAD
    
    print '%s, aka %s'%(time.strftime('%m/%d/%Y %H:%M:%S'),time.strftime('%Y%m%d'))
    needNewline = False

    argCount = 0 # for -date
    for a in sys.argv[1:]:
        a = a.lower()
        argCount += 1
        if a == "-verbose": verbose = True
        if a == "-veryverbose": veryVerbose = True
        if a == "-update":
            update = True
            slow = True
        if a == "-dots": dots = True
        if a == "-extras": showExtras = True
        if a == "-slow": slow = True
        if a == "-date":
            date = sys.argv[argCount+1]
            if len(date) == 8:
                oldTime = time.strptime(date,'%Y%m%d')
            elif len(date) == 12:
                oldTime = time.strptime(date,'%Y%m%d%H%M')
            else:
                print 'svnwalk.py BAD -date. No sense of humor? 20080407 + YYYYMMDDHHmm'
                return
            print '-update will use date/time %s, current date/time is %s'%(time.strftime('%Y%m%d%H%M',oldTime),time.strftime('%Y%m%d%H%M'))
            revdate = pysvn.Revision( pysvn.opt_revision_kind.date, time.mktime(oldTime) )
            
        if a == "-help":
            print 'svnwalk.py [-update] [-dots] [-date n][-verbose][-extras][-veryverbose][-slow]'
            print 'status codes: M modified, u needs update, C conflicted, A added, L lost,'
            print ' D deleted, ?/?? unversioned. Default shows status of versioned files only'
            print ' u, a, d and c (repository status) only show up with -slow'
            return

    client = pysvn.Client()
    client.exception_style = 1
    if update: client.callback_get_login = login
    
    for root, dirs, files in os.walk('.'):
        if len(dirs) > 0 and verbose:
            print ' ', root
        elif dots:
            sys.stdout.write('.')
            needNewline = True

        if '.svn' in dirs:
            newdirs = [] # for a directory that has .svn, the only dirs that should survive are the ones that are not versioned.
            changes = client.status(root, update=slow)
            changes.sort()
            
            if update:
                r = root
                try:
                    client.update(r, revision=revdate)
                except pysvn.ClientError, detail:
                    for message, code in detail.args[1]:
                        # We want to ignore the message:
                        # Failed to add directory '<name>': object of the same name already exists
                        if code != 155000: print 'SVN error code:', code, 'message: ', message
            
            for f in changes:
                code = ''
                fpath = f.path.decode("iso-8859-1")
                if f.text_status == pysvn.wc_status_kind.added: code = 'A'
                elif f.text_status == pysvn.wc_status_kind.deleted: code = 'D'
                elif f.text_status == pysvn.wc_status_kind.modified: code = 'M'
                elif f.text_status == pysvn.wc_status_kind.conflicted: code = 'C'
                elif f.text_status == pysvn.wc_status_kind.missing: code = 'L'
                elif f.text_status == pysvn.wc_status_kind.unversioned:
                    if showExtras: code = '?'
                    if os.path.isdir(fpath):
                        path = os.path.split(fpath)
                        #print "path", path
                        if len(path) > 1:
                            newdirs.append(path[1])
                
                if slow and not os.path.isdir(fpath):
                    if f.repos_text_status == pysvn.wc_status_kind.added: code = code # + 'a'
                    elif f.repos_text_status == pysvn.wc_status_kind.deleted: code = code + 'd'
                    elif f.repos_text_status == pysvn.wc_status_kind.modified: code = code + 'u'
                    elif f.repos_text_status == pysvn.wc_status_kind.conflicted: code = code + 'c'
                    elif f.repos_text_status == pysvn.wc_status_kind.missing: code = code + 'l'
                    elif f.repos_text_status == pysvn.wc_status_kind.unversioned and showExtras: code = code + '??'

                if code != '' or veryVerbose:
                    if needNewline:
                        sys.stdout.write('\n')
                        needNewline = False
                    print code, fpath

            # back to if .svn in dirs scope. Cannot replace dirs =, must keep original container.
            del dirs[:]
            for nd in newdirs:
                dirs.append(nd)

    if needNewline:
        sys.stdout.write('\n')
    print time.strftime('%m/%d/%Y %H:%M:%S')

if __name__ == '__main__':
    main()

> -----Original Message-----
> From:
> users-return-77944-hardenbergh=terarecon.com_at_subversion.tigris.org
> [mailto:users-return-77944-hardenbergh=terarecon.com_at_subversio
> n.tigris.o
> rg]On Behalf Of Blair Zajac
> Sent: Wednesday, May 21, 2008 2:20 PM
> To: Andy Levy
> Cc: Steve Kelem; svn users
> Subject: Re: Best practice for partial repository checkout
>
>
> Andy Levy wrote:
> > On Wed, May 21, 2008 at 12:55 PM, Steve Kelem
> <skelem_at_elementcxi.com> wrote:
> >> I have a question about the best practice for checking out
> part of a
> >> repository.
> >>
> >> We have a repository that has a structure like:
> >>
> >> trunk/
> >> hw/
> >> sw/
> >> apps/
> >> training/
> >>
> >> Each of the sub-directories is quite large and taking up
> lots of space when
> >> each of our engineers checks out the entire trunk.
> >>
> >> The right way to check out (AFIK) would be to check out
> only the top-level
> >> directory that's needed. (Check-out is quite slow, on the
> order of a few
> >> hours!) That's fine for checking out a new sandbox,
> starting from scratch.
> >> What about someone who has the whole trunk checked out,
> but realizes (for
> >> example, due to a company mandate) that one or more
> directories are not
> >> needed in his sandbox?
> >>
> >> One possibility is to delete the entire local sandbox and
> then check out
> >> only the directories that are needed. That's safe, but
> costly in check-out
> >> time and can lose any local work-in-progress.
> >
> > Unless you save the work in progress.
> >
> >> But what if a lot of work is in progress in, e.g., the hw
> directory, but a
> >> local copy of the sw directory is not needed? Is there an
> easy way to tell
> >> subversion that I don't need a copy of sw, or apps, or
> training, but that I
> >> want to keep all my local work in the hw directory?
> >
> > Copy or move sw using your file manager of choice (shell prompt,
> > Windows Explorer, Nautalis, Finder, what have you) to another
> > location, then delete what you don't want. The great thing about
> > Suvbersion WCs is that (barring symlinks) each directory can be its
> > own independent working copy just by copying it to a new place.
>
> That is true for 1.5 and older, but may not be true in the
> future svn releases.
>
> Blair
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
> For additional commands, e-mail: users-help_at_subversion.tigris.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-05-22 17:02:59 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.