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

inconsistent behavior when changing property from pre-commit script

From: Dmitry Konyshev <dmitry.konyshev_at_gmail.com>
Date: 2007-10-17 10:33:16 CEST

Hello,

I've posted this issue description in the users list and Karl Fogel
advised me to post it here as well.

The problem I encountered is as follows: during every commit, I change a
property of all files in a repos in the pre-commit script within the
current transaction. This works quite well, except for the case when a
top-most directory is copied to root of the repos. In this case the
property is only updated for the files in the new directory and stays
the same for all other files.

I can only reproduce this issue with the FSFS back-end.

The sequence of reproducing this issue:

1. Create a FSFS-based repos, set up the attached script as a pre-commit
script:

$ svnadmin create --fs-type=fsfs tmprepos
$ cp test.py tmprepos/hooks/pre-commit
$ chmod +x tmprepos/hooks/pre-commit

2. Checkout the repos, create a directory and put a file there:

$ svn co file:///tmp/tmprepos/ wc
$ svn mkdir wc/dir1
$ echo test > wc/dir1/file1
$ svn add wc/dir1/file1
$ svn ci -m "" wc

3. Find out the file's 'count' property:

$ svn propget count file:///tmp/tmprepos/dir1/file1
1

4. Copy the directory and check the 'count' property of old and new
files (check out that ):

$ svn cp file:///tmp/tmprepos/dir1 file:///tmp/tmprepos/dir2 -m ""
$ svn propget count file:///tmp/tmprepos/dir1/file1
1
$ svn propget count file:///tmp/tmprepos/dir2/file1
2

I tried different scenarios (changing files, file's properties, copying
directories inside other directories, and so on) and it looks like that
only copying the top-most directory to root reveals this effect. Also,
the property of files in other directories don't get updated too.

I'm also attaching a shell script with all the commands to reproduce the
issue.

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)

#!/bin/sh

svnadmin create --fs-type=fsfs tmprepos
cp test.py tmprepos/hooks/pre-commit
chmod +x tmprepos/hooks/pre-commit
svn co file:///tmp/tmprepos/ wc
svn mkdir wc/dir1
echo test > wc/dir1/file1
svn add wc/dir1/file1
svn ci -m "" wc
svn propget count file:///tmp/tmprepos/dir1/file1
svn cp file:///tmp/tmprepos/dir1 file:///tmp/tmprepos/dir2 -m ""
svn propget count file:///tmp/tmprepos/dir1/file1
svn propget count file:///tmp/tmprepos/dir2/file1

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Oct 17 10:33:44 2007

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.