Johan Corveleyn wrote on Wed, Jun 13, 2012 at 15:32:56 +0200: > On Wed, Jun 13, 2012 at 3:16 PM, Vladimir Shun'kov <shuny...@gmail.com> wrote: > > Would be enough have the number bytes of changes. I did disk usage in > > pre-commit hook and disk usage in post-commit hook and then calculated > > the difference. But I commited the new file with size 20Kb and size of > > commit I recieved only 5Kb due some svn compression I guess. > > In 1.7, there's a new svnlook subcommand: 'svnlook filesize'. This can > give you the filesize of any file (from a revision or a transaction), > without having to 'svnlook cat' it (i.e. more efficiently). > > Maybe you can use that directly, or use it to calculate the difference? > > Like, in the pre-commit hook: > > 1) 'svnlook changed -t $TXN $REPOS' to get the list of changes in this > transaction > > 2) For every changed (or added) file, do 'svnlook filesize -t $TXN $REPOS' > > 3) For changed files, compare them to 'svnlook filesize -r $YOUNGEST > $REPOS' where $YOUNGEST is the result of 'svnlook youngest $REPOS'. > > 4) Do some arithmetic on the result >
$TXN may be based on a revision earlier than $YOUNGEST, and the file may have changed between that base revision and youngest. If that happens, the commit attempt will fail due to a conflict, but before that happens the logic above would make calculations based on the wrong information. I don't know if there is an svnlook API to print the base revision of a given txn... but I guess there should be. > HTH > -- > Johan