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.
10 if sys
.hexversion
< 0x02040000:
11 # The limiter is the ValueError() calls. This may be too conservative
12 sys
.stderr
.write("svnrdump-sim.py: requires Python 2.4 or later.\n")
18 return os
.environ
[var
]
21 def writedump(url
, lower
, upper
):
22 if url
.startswith('sim://'):
24 if filename
[-1] == '/': filename
= filename
[:-1] #remove terminating slash
26 raise ValueError('sim:// url required')
27 f
= open(filename
, 'r');
33 if state
== 'header' and l
.startswith('Revision-number: '):
35 if state
== 'prefix' and l
== 'Revision-number: %s\n' % lower
:
37 if not upper
== 'HEAD' and state
== 'selection' and l
== 'Revision-number: %s\n' % upper
:
40 if state
== 'header' or state
== 'selection':
41 if state
== 'selection': wroterev
= True
45 if __name__
== "__main__":
46 if not (len(sys
.argv
) in (3, 4, 5)):
47 print("usage: %s dump URL -rLOWER:UPPER")
49 if not sys
.argv
[1] == 'dump': raise NotImplementedError('only "dump" is suppported.')
52 if len(sys
.argv
) == 4 and sys
.argv
[3][0:2] == '-r':
53 r
= sys
.argv
[3][2:].lstrip().split(':')
54 if not getrevlimit() is None: r
[1] = getrevlimit()
55 if writedump(url
, r
[0], r
[1]): ret
= 0