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])

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

{{ parent.tldr }}

{{ parent.urlSource.name }}