Downloading all revisions from a remote subversion repo

I wrote a script to create a backup of a complete remote svn repo, containing all revisions. It looks like there's a project rsvndump that does something similar, but I knew that what I wanted could be done in a few lines of Python.

Change the first few lines, and then run the script.
url='https://url.of.repo/svn/'
output=r'C:\full\path\to\desired\output'
username='user.name'

import os, subprocess, shutil
from os.path import join, exists

def runwithshell(listArgs):
  print('  '.join(listArgs))
  popen = subprocess.Popen(listArgs, shell=True, stdout=subprocess.PIPE)
  stdout = popen.communicate()[0]
  return stdout.rstrip(), popen.returncode

def run_assertsuccess(cmd):
  assert '|' in cmd
  cmd = cmd.split('|')
  stdout, ret = runwithshell(cmd)
  assert ret == 0

def go():
  assert exists(output)
  os.chdir(output)
  run_assertsuccess('svnadmin|create|lrepo')
  if os.name=='nt':
    assert ':' in output, 'want full path'
    fout=open('lrepo/hooks/pre-revprop-change.bat','w')
    fout.write('')
    fout.close()
  else:
    assert output.startswith('/'), 'want full path'
    fout=open('lrepo/hooks/pre-revprop-change','w')
    fout.write('#!/bin/sh\nexit 0;')
    fout.close()
    run_assertsuccess('chmod|+x|localrepos/hooks/pre-revprop-change')
    
  run_assertsuccess('svnsync|init|--username|'+username+'|file:///'+output+'\lrepo|'+url)
  run_assertsuccess('svnsync|sync|--username|'+username+'|file:///'+output+'\lrepo')

def createExportDump():
  assert exists(output)
  os.chdir(output)
  run_assertsuccess('svnadmin|dump|.\lrepo|--incremental|>|out.dump')



if __name__=='__main__':
  go()
  createExportDump()
  print('saved to out.dump')



Later, to restore from the dump, use:
# svnadmin create newrepo
# svnadmin load ./newrepo < out.dump
References: How do I download my Subversion history