3 Simulates svnrdump by replaying an existing dump from a file, taking care
4 of the specified revision range.
5 To simulate incremental imports the environment variable SVNRMAX can be set
6 to the highest revision that should be available.
11 if sys.hexversion < 0x02040000:
12 # The limiter is the ValueError() calls. This may be too conservative
13 sys.stderr.write("svnrdump-sim.py: requires Python 2.4 or later.\n")
20 return os.environ[var]
24 def writedump(url, lower, upper):
25 if url.startswith('sim://'):
27 if filename[-1] == '/':
28 filename = filename[:-1] # remove terminating slash
30 raise ValueError('sim:// url required')
31 f = open(filename, 'r')
38 if state == 'header' and l.startswith('Revision-number: '):
40 if state == 'prefix' and l == 'Revision-number: %s\n' % lower:
42 if not upper == 'HEAD' and state == 'selection' and \
43 l == 'Revision-number: %s\n' % upper:
46 if state == 'header' or state == 'selection':
47 if state == 'selection':
52 if __name__ == "__main__":
53 if not (len(sys.argv) in (3, 4, 5)):
54 print("usage: %s dump URL -rLOWER:UPPER")
56 if not sys.argv[1] == 'dump':
57 raise NotImplementedError('only "dump" is supported.')
60 if len(sys.argv) == 4 and sys.argv[3][0:2] == '-r':
61 r = sys.argv[3][2:].lstrip().split(':')
62 if not getrevlimit() is None:
64 if writedump(url, r[0], r[1]):