3 # USAGE: getfile.py [-r REV] repos-path file
5 # gets a file from an SVN repository, puts it to sys.stdout
12 my_getopt
= getopt
.gnu_getopt
13 except AttributeError:
14 my_getopt
= getopt
.getopt
16 from svn
import fs
, core
, repos
20 def getfile(path
, filename
, rev
=None):
21 path
= core
.svn_path_canonicalize(path
)
22 repos_ptr
= repos
.open(path
)
23 fsob
= repos
.fs(repos_ptr
)
26 rev
= fs
.youngest_rev(fsob
)
27 print "Using youngest revision ", rev
29 root
= fs
.revision_root(fsob
, rev
)
30 file = fs
.file_contents(root
, filename
)
32 data
= core
.svn_stream_read(file, CHUNK_SIZE
)
35 sys
.stdout
.write(data
)
38 print "USAGE: getfile.py [-r REV] repos-path file"
42 opts
, args
= my_getopt(sys
.argv
[1:], 'r:')
46 for name
, value
in opts
:
49 getfile(args
[0], args
[1], rev
)
51 if __name__
== '__main__':