"C. Michael Pilato" <cmpilato@collab.net> writes:
> "Entner, Jonathan T." <Jonathan.Entner@jhuapl.edu> writes:
>
> > Is there a way to force a commit of a particular file for every
> > commit transaction?
>
> DISCLAIMER: THE FOLLOWING HAS NOT BEEN ATTEMPTED. I'M NOT RESPONSIBLE
> FOR ANY NEGATIVE RESULTS THAT OCCUR FROM IT BEING ATTEMPTED.
> UNDERSTAND THAT SUBVERSION BEHAVIOR MAY CHANGE SUCH THAT THIS NO
> LONGER WORKS, IN WHICH CASE -- TOUGH LUCK, BUCK-O.
>
> So, the problem with modifying files in the pre-commit phase is the
> danger of the working copy claiming to have something that it does
> not. I wonder, though, if you could write a pre-commit hook that
> "touches" a particular file in such a way that a new revision of that
> file would be generated, but that the working copy wouldn't really
> care. For example, your script could set some property on the file
> that it doesn't already have, and then immediately remove that
> property, and then allow the commit to proceed. I think that would
> sufficiently fool the Subversion filesystem into generating a new
> revision of that file without completely horking your working copy.
So, putting my monkeying where my mouth is, attached is the little
pre-commit hook script I wrote for doing just this.
Note, however, that until issue #2107 is fixed, this won't behave in
the expected manner.
--------------------------------------------------------------------------
#!/usr/bin/env python
# touchit.py REPOS-PATH TXN-NAME PATH
#
# Call this script from your pre-commit hook, specifying the path in
# the repository of a version file that you'd like "touched" after
# every commit.
#
# E.g.:
#
# /path/to/touchit.py $1 $2 trunk/version.txt
#
import sys
from svn import core, repos, fs
if len(sys.argv) < 4:
sys.stderr.write("Usage: touchit.py REPOS-PATH TXN-NAME PATH\n")
sys.exit(1)
repos_path = sys.argv[1]
txn = sys.argv[2]
path = sys.argv[3]
core.apr_initialize()
pool = None
try:
pool = core.svn_pool_create(None)
reposobj = repos.svn_repos_open(repos_path, pool)
fsobj = repos.svn_repos_fs(reposobj)
txnobj = fs.open_txn(fsobj, txn, pool)
root = fs.txn_root(txnobj, pool)
pname = None
for i in range(100000):
pname = "touchit-%d" % i
pval = fs.node_prop(root, path, pname, pool)
if pval is None:
break
fs.change_node_prop(root, path, pname, "FOO", pool)
fs.change_node_prop(root, path, pname, None, pool)
finally:
if pool is not None:
core.svn_pool_destroy(pool)
core.apr_terminate()
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Mon Oct 25 18:23:54 2004