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

pre-commit property update issue

From: Dmitry Konyshev <dmitry.konyshev_at_gmail.com>
Date: 2007-10-10 23:53:54 CEST

Hello,

For some reason, I need to update a property of each file in a repos on
every commit. I've create a pre-commit script in python that does all
the work. Unfortunately, in some circumstances properties of some files
don't get updated. Specifically, this happens if a top-most directory in
the repos is copied.

A simplified version of the script is attached to this message. It opens
current transaction, traverse the repository and increments the 'count'
property of every file it encounters.

Everything works fine unless a command similar to the following is executed:

svn cp -m "copying top-most dir" repos_url/dir1 repos_url/dir2

In this case the 'count' properties of files in new dir2 get
incremented, but for other files in the repos they don't.

It misbehaves alike if a top-most directory is copied to a work copy
first and then committed without any changes. If something has been
changed in the new directory in the work copy, all files' 'count'
properties are updated properly.

 From debug output of the script I can see that the properties of all
files are updated and their new values are printed, but in new revision
the properties of files in old directories stay as they were before the
commit.

Although I realize that making modifications in current transaction in
the pre-commit script might be something improper, this works quite well
in most cases. So, the fact that it fails in only a few circumstances
looks like a bug to me.

Any comments on this issue are appreciated.

Regards,
Dmitry

#!/usr/bin/python

import svn.repos, svn.fs, sys

def chk_file(root, path):
    print >> sys.stderr, path
    prop = svn.fs.node_prop(root, path, 'count')
    if prop:
        prop = str(int(prop) + 1)
    else:
        prop = '1'
    svn.fs.change_node_prop(root, path, 'count', prop)
    print >> sys.stderr, prop

def chk_dir(root, path):
    print >> sys.stderr, path
    dirents = svn.fs.dir_entries(root, path)
    for dirent in dirents:
        if svn.fs.is_dir(root, path + '/' + dirent):
            chk_dir(root, path + '/' + dirent)
        else:
            chk_file(root, path + '/' + dirent)

repos = svn.repos.open(sys.argv[1])
fs = svn.repos.fs(repos)
txn = svn.fs.open_txn(fs, sys.argv[2])
root = svn.fs.txn_root(txn)
dirents = svn.fs.dir_entries(root, '')
for dirent in dirents:
    if svn.fs.is_dir(root, dirent):
        chk_dir(root, dirent)
    else:
        chk_file(root, dirent)
#sys.exit(-1)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Oct 10 23:58:07 2007

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

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