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

Re: Limit The size of Commit in SVN

From: Johan Corveleyn <jcorvel_at_gmail.com>
Date: Mon, 3 Feb 2014 15:14:16 +0100

On Mon, Feb 3, 2014 at 1:09 PM, Mehboob Ahmed <m.mehboobahmed_at_gmail.com> wrote:
> hi Nico Kadel-Garcia-2
>
> i want to restrict user to commit any kind of data not individual file a
> complete commit. and i want it because in my office developers commit data
> more than a GB i want them to restrict and commit less than a GB can you
> provide me a complte pre-commit hook.
> so far i have done this, kindly guide me.
> =================================
> @echo off
> :: Stops commits that have size of greated than 1GB.
> @echo off
>
> set Repository=%1
>
> set Revision=%2
>
> set MAX_BYTES= 1073741824
>
>
>
> if "%Revision%" GEQ "%MAX_BYTES%" (goto :err) else exit 0
>
> :err
> echo Your commit has been blocked because your commit size is exceed. 1>&2
> echo Kindly Commit less than 1GB. 1>&2
> echo Thanks Regards 1>&2
> exit 1
> ==========================

I don't think it makes sense to limit the size of the commit (i.e. the
diff or the delta that's being sent). There might be a file that's
0.999999 GB already in your repository, and the commit only adds the
last byte that puts it over the edge. The revision (delta) will be
very small, but the file becomes larger than 1 GB.

It's more interesting to just limit the size of individual files, so
people simply cannot add a file of 1 GB (or modify a file so that it
becomes larger than 1 GB). For that you can use the command 'svnlook
filesize' (available since svn 1.7):

[[[
C:\>svnlook help filesize
filesize: usage: svnlook filesize REPOS_PATH PATH_IN_REPOS

Print the size (in bytes) of the file located at PATH_IN_REPOS as
it is represented in the repository.

Valid options:
  -r [--revision] ARG : specify revision number ARG
  -t [--transaction] ARG : specify transaction name ARG
]]]

In a pre-commit hook you would use 'svnlook changed -t $TXN
$REPOS_PATH' to first get the list of changed files, and then loop
over the changed files and check if 'svnlook filesize -t $TXN
$REPOS_PATH $CHANGED_PATH' isn't larger than your imposed limit.

I don't have such a hook that I can show as an example, so I'll leave
the rest as an exercise for the reader.

-- 
Johan
Received on 2014-02-03 15:15:13 CET

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.