4 # Licensed to the Apache Software Foundation (ASF) under one
5 # or more contributor license agreements. See the NOTICE file
6 # distributed with this work for additional information
7 # regarding copyright ownership. The ASF licenses this file
8 # to you under the Apache License, Version 2.0 (the
9 # "License"); you may not use this file except in compliance
10 # with the License. You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing,
15 # software distributed under the License is distributed on an
16 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 # KIND, either express or implied. See the License for the
18 # specific language governing permissions and limitations
23 # USAGE: dumprops.py [-r REV] repos-path [file]
25 # dump out the properties on a given path (recursively if given a dir)
32 my_getopt
= getopt
.gnu_getopt
33 except AttributeError:
34 my_getopt
= getopt
.getopt
37 from svn
import fs
, core
, repos
40 def dumpprops(path
, filename
='', rev
=None):
41 path
= core
.svn_path_canonicalize(path
)
42 repos_ptr
= repos
.open(path
)
43 fsob
= repos
.fs(repos_ptr
)
46 rev
= fs
.youngest_rev(fsob
)
48 root
= fs
.revision_root(fsob
, rev
)
49 print_props(root
, filename
)
50 if fs
.is_dir(root
, filename
):
51 walk_tree(root
, filename
)
53 def print_props(root
, path
):
54 raw_props
= fs
.node_proplist(root
, path
)
55 # need to massage some buffers into strings for printing
57 for key
, value
in raw_props
.items():
58 props
[key
] = str(value
)
60 print('--- %s' % path
)
63 def walk_tree(root
, path
):
64 for name
in fs
.dir_entries(root
, path
).keys():
65 full
= path
+ '/' + name
66 print_props(root
, full
)
67 if fs
.is_dir(root
, full
):
71 print("USAGE: dumpprops.py [-r REV] repos-path [file]")
75 opts
, args
= my_getopt(sys
.argv
[1:], 'r:')
77 for name
, value
in opts
:
81 dumpprops(args
[0], args
[1], rev
)
83 dumpprops(args
[0], "", rev
)
87 if __name__
== '__main__':