4 from svn
import client
, ra
, core
6 def printer(segment
, pool
):
7 path
= segment
.path
is not None and segment
.path
or "(null)"
8 print "r%d-r%d: %s" % (segment
.range_start
, segment
.range_end
, path
)
14 # parse the target URL and optional peg revision
15 path_pieces
= args
[0].split('@')
16 if len(path_pieces
) > 1:
17 peg_revision
= int(path_pieces
[-1])
18 assert peg_revision
>= 0
19 url
= '@'.join(path_pieces
[:-1])
21 peg_revision
= core
.SVN_INVALID_REVNUM
23 url
= core
.svn_path_canonicalize(url
)
25 # parse the revision range, if any
27 rev_pieces
= args
[1].split(':')
28 num_revs
= len(rev_pieces
)
31 start_revision
= int(rev_pieces
[0])
32 end_revision
= int(rev_pieces
[1])
34 start_revision
= end_revision
= int(rev_pieces
[0])
35 assert(start_revision
>= 0)
36 assert(end_revision
>= 0)
38 start_revision
= peg_revision
42 if start_revision
>= 0 \
43 and end_revision
>= 0 \
44 and end_revision
> start_revision
:
45 raise Exception, "End revision must not be younger than start revision"
46 if peg_revision
>= 0 \
47 and start_revision
>= 0 \
48 and start_revision
> peg_revision
:
49 raise Exception, "Start revision must not be younger than peg revision"
51 return url
, peg_revision
, start_revision
, end_revision
56 url
, peg_revision
, start_revision
, end_revision
= parse_args(sys
.argv
[1:])
58 sys
.stderr
.write("""Usage: %s URL[@PEG-REV] [START-REV[:END-REV]]
60 Trace the history of URL@PEG-REV, printing the location(s) of its
61 existence between START-REV and END-REV. If START-REV is not
62 provided, the entire history of URL@PEG-REV back to its origin will be
63 displayed. If provided, START-REV must not be younger than PEG-REV.
64 If END-REV is provided, it must not be younger than START-REV.
66 (This is a wrapper around Subversion's svn_ra_get_location_segments() API.)
69 """ % (os
.path
.basename(sys
.argv
[0]), str(e
)))
72 core
.svn_config_ensure(None)
75 client
.get_simple_provider(),
76 client
.get_username_provider(),
77 client
.get_ssl_server_trust_file_provider(),
78 client
.get_ssl_client_cert_file_provider(),
79 client
.get_ssl_client_cert_pw_file_provider(),
81 ctx
.auth_baton
= core
.svn_auth_open(providers
)
82 ctx
.config
= core
.svn_config_get_config(None)
84 ra_callbacks
= ra
.callbacks_t()
85 ra_callbacks
.auth_baton
= ctx
.auth_baton
86 ra_session
= ra
.open(url
, ra_callbacks
, None, ctx
.config
)
87 ra
.get_location_segments(ra_session
, "", peg_revision
,
88 start_revision
, end_revision
, printer
)
90 if __name__
== "__main__":