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.
13 if os
.environ
.has_key(var
):
14 return os
.environ
[var
]
17 def writedump(url
, lower
, upper
):
18 if url
.startswith('sim://'):
20 if filename
[-1] == '/': filename
= filename
[:-1] #remove terminating slash
22 raise ValueError('sim:// url required')
23 f
= open(filename
, 'r');
29 if state
== 'header' and l
.startswith('Revision-number: '):
31 if state
== 'prefix' and l
== 'Revision-number: %s\n' % lower
:
33 if not upper
== 'HEAD' and state
== 'selection' and l
== 'Revision-number: %s\n' % upper
:
36 if state
== 'header' or state
== 'selection':
37 if state
== 'selection': wroterev
= True
41 if __name__
== "__main__":
42 if not (len(sys
.argv
) in (3, 4, 5)):
43 print "usage: %s dump URL -rLOWER:UPPER"
45 if not sys
.argv
[1] == 'dump': raise NotImplementedError('only "dump" is suppported.')
48 if len(sys
.argv
) == 4 and sys
.argv
[3][0:2] == '-r':
49 r
= sys
.argv
[3][2:].lstrip().split(':')
50 if not getrevlimit() is None: r
[1] = getrevlimit()
51 if writedump(url
, r
[0], r
[1]): ret
= 0