On Friday, August 20, 2010 09:42:44 am Ryan Schmidt wrote: > > Also imagine the logs: Bob did a fix, hook script did a fix. Robert > > did a fix, hook script did a fix. Alice did a fix, hook script did a > > fix. Every other log entry is your hook script modifying code. > > Only commits immediately after adding a new file will be a commit by the > hook script, to add the property. For commits that just modify existing > files, there will be no need for the hook script to commit anything.
It could be done within the same commit, actually, without a separate commit. Here is a simple pre-commit in Python that will set 'foo:bar' property to 'baz' on all committed files but not directories. [[[ #! /usr/bin/python # vi: set sw=2 : import sys from svn import core, fs, delta, repos def v(pool, repos_path, txn): fs_ptr = repos.fs(repos.open(repos_path, pool)) txn_ptr = fs.open_txn(fs_ptr, txn, pool) txn_root = fs.txn_root(txn_ptr, pool) chg = fs.paths_changed2(txn_root, pool) for f in chg: if chg[f].node_kind == core.svn_node_file: fs.change_node_prop(txn_root, f, "foo:bar", "baz") if __name__ == '__main__': core.run_app(v, sys.argv[1], sys.argv[2]) ]]] Here is how it works. Note the foo:bar property change. [[[ /tmp$ svnadmin create aa /tmp$ cp pre-commit aa/hooks/ /tmp$ svn co file:///tmp/aa awc Checked out revision 0. /tmp$ cd awc /tmp/awc$ echo qwerty > qwerty /tmp/awc$ svn add qwerty A qwerty /tmp/awc$ svn ci -m 1 qwerty Adding qwerty Transmitting file data . Committed revision 1. /tmp/awc$ svn di -c 1 Index: qwerty =================================================================== --- qwerty (revision 0) +++ qwerty (revision 1) @@ -0,0 +1 @@ +qwerty Property changes on: qwerty ___________________________________________________________________ Added: foo:bar ## -0,0 +1 ## +baz ]]] The problem with this approach is that the working copy is not aware that the commit was somehow altered on the server, so the client does not see this property on the file: [[[ /tmp/awc$ svn pl qwerty /tmp$ ]]] Therefore, I would only use this approach for properties that client does not care about, and svn:needs-lock is not one of such properties. Regards, Alexey.