#!python
#
# 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
mytemp.close()
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):
return
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())
f.write(out)
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])
os.remove(mytempfile)
Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/DlPDMS-UIU4/10285