[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Unknown svn_fs_close_txn in example

From: Juanma Barranquero <jmbarranquero_at_laley.wke.es>
Date: 2003-12-03 16:43:09 CET

On 02 Dec 2003 08:39:05 -0600
"C. Michael Pilato" <cmpilato@collab.net> wrote:

> Committed (with nary a mod) as revision 7902. Thanks, Juanma.

My pleasure.

I was, in fact, shamelessly ripping off svnlook.py to resolve the issue
I posted a few days ago about modifying the txn log in a pre-commit hook.

I've finally done it like this:

############################################################################

from sys import argv
from svn import core, fs, repos

# This class allows modifying the svn:log attribute of a transaction in the
# pre-commit hook.
class CheckLog:
    def __init__(self, pool, path, txn, norm):
        self.pool = pool
        self.fs_ptr = repos.svn_repos_fs(repos.svn_repos_open(path, self.pool))
        self.txn_ptr = fs.open_txn(self.fs_ptr, txn, self.pool)

        prop = core.SVN_PROP_REVISION_LOG

        log = norm(fs.txn_prop(self.txn_ptr, prop, self.pool) or '')
        if log != None:
            fs.change_txn_prop(self.txn_ptr, prop, log, self.pool)

# Example function to "normalize" the log (currently, it just deletes the
# ending newline, if any). It should return the new log, or None to leave
# it as is.
def normalize(log):
    if len(log) > 0 and log[-1] == '\n':
        return log[0:-1]
    else:
        return None

# Args are those for the pre-commit hook: REPOS-PATH, TXN.
def main():
    core.run_app(CheckLog, argv[1], argv[2], normalize)

if __name__ == '__main__':
    main()

############################################################################

                                                                Juanma

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Dec 3 16:43:48 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.