Over a million developers have joined DZone.

Copy All Subversion Properties On Directories And Files From One Source Tree To Another Identical Source Tree

Copy all subversion properties on directories and files from one source tree to another identical source tree. 

Works well for copying between two revisions of a vendor library where a new directory is used for each revision. For example, svncopyprop openssl/0.9.8l openssl/0.9.8m

Works on Windows. Expect that it should work on Linux as well.

# This script will copy all subversion properties from one source tree
# to another identical source tree. It is best for copying between
# revisions of a vendor library. e.g. /openssl/0.9.8l -> /openssl/0.9.8m
# Usage: svncopyprop SRC DST

import sys, os, subprocess, tempfile

mytemp = tempfile.NamedTemporaryFile(delete=False)
mytempfile = mytemp.name

def myexec(kargs, show):
    if show: print ' '.join(kargs)
    return subprocess.Popen(kargs, stdout=subprocess.PIPE).communicate()[0]
def svncopyprop(src, dst):
    if not os.path.exists(dst): 
    out = myexec(['svn', 'pl', '-q', src], False)
    pnames = out.split()
    for pname in pnames:
        out = myexec(['svn', 'pg', '--strict', pname, src], False)
        with file(mytempfile, 'wt') as f:
            out = '\n'.join(out.split())
        myexec(['svn', 'ps', pname, dst, '--file', mytempfile], True)

    if os.path.isdir(src): 
        for subdir in os.listdir(src):
            if subdir == '.svn': continue
            nsrc = os.path.join(src, subdir)
            ndst = os.path.join(dst, subdir)
            svncopyprop(nsrc, ndst)
svncopyprop(sys.argv[1], sys.argv[2])

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}