2 # ====================================================================
3 # Copyright (c) 2005 CollabNet. All rights reserved.
5 # This software is licensed as described in the file COPYING, which
6 # you should have received as part of this distribution. The terms
7 # are also available at http://subversion.tigris.org/license.html.
8 # If newer versions of this license are posted there, you may use a
9 # newer version instead, at your option.
11 # This software consists of voluntary contributions made by many
12 # individuals. For exact contribution history, see the revision
13 # history and logs, available at http://subversion.tigris.org/.
14 # ====================================================================
19 from svn
import repos
, fs
, core
21 def main(pool
, repos_dir
, path
):
22 # Construct a ChangeCollector to fetch our changes.
23 fs_ptr
= repos
.svn_repos_fs(repos
.svn_repos_open(repos_dir
, pool
))
24 youngest_rev
= fs
.svn_fs_youngest_rev(fs_ptr
, pool
)
25 root
= fs
.svn_fs_revision_root(fs_ptr
, youngest_rev
, pool
)
26 if not fs
.svn_fs_node_prop(root
, path
, core
.SVN_PROP_NEEDS_LOCK
, pool
):
28 """Locking of path '%s' prohibited by repository policy (must have
30 """ % (path
, core
.SVN_PROP_NEEDS_LOCK
))
35 def _usage_and_exit():
37 Usage: %s REPOS-DIR PATH
39 This script, intended for use as a Subversion pre-lock hook, verifies that
40 the PATH that USER is attempting to lock has the %s property
41 set on it, returning success iff it does.
42 """ % (os
.path
.basename(sys
.argv
[0]), core
.SVN_PROP_NEEDS_LOCK
))
46 if __name__
== '__main__':
49 sys
.exit(core
.run_app(main
, sys
.argv
[1], sys
.argv
[2]))