You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Mehboob Ahmed <m....@gmail.com> on 2014/01/22 08:34:25 UTC

Limit The size of Commit in SVN

Dear All,

Is ther any hook who wont allow user to commit in SVN whose size is greater 
than 1GB.it means i want to restrict user to commit less than 1GB of data 
in SVN. i need this hook in windows format .bat file extention please help.

Regards
Mehboob Ahmed

Re: Limit The size of Commit in SVN

Posted by Branko Čibej <br...@wandisco.com>.
On 03.02.2014 13:09, Mehboob Ahmed 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

Heh. Your error message is incorrect; it should say, "Your commit has
been blocked because the committed revision number would be too high."
You just limited the total number of commits that can be made to the
repository. Unfortunately, that is in no way related to the size of
those commits. :)

-- Brane


-- 
Branko Čibej | Director of Subversion
WANdisco // Non-Stop Data
e. brane@wandisco.com

Re: Limit The size of Commit in SVN

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Stephen Connolly,
am Dienstag, 4. Februar 2014 um 13:25 schrieben Sie:

> [...]and then solve that problem instead.

...and don't expect others to do for you, they surely aren't that
bored . ;-)

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail:Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: Limit The size of Commit in SVN

Posted by Johan Corveleyn <jc...@gmail.com>.
On Wed, Feb 5, 2014 at 4:45 AM, Nico Kadel-Garcia <nk...@gmail.com> wrote:
> On Tue, Feb 4, 2014 at 7:25 AM, Stephen Connolly
> <st...@gmail.com> wrote:
>> Nope I cannot. I don't use windows, and I only use SVN for those projects I
>> work on that are still on SVN.
>>
>> I think you are missing the point that *everyone* has been trying to get you
>> to see...
>>
>> What is the benefit in stopping 1GB+ commits?
>
> In my experience, they're almost inevitably mistakes. They're often
> accidental including bulky binary files, which then are incredibly
> painful to "obliterate" from the repository because there is still no
> "obliterate" option for inappropriately stored files in the repository
> itself, and from the current code lines, there *never will be* such an
> option. The dump/filter/reload echanism is extremely painful for
> clearing such accidentally stored binaries.

That one is a nice use case for enforcing a maximum size on *files*,
not necessarily on the entire commit (i.e. use 'svnlook filesize' to
check in the pre-commit hook). If accidentally committing large
binaries is the problem that the OP wants to prevent, it's clear that
'svnlook filesize' is a good fit for his problem.

> The other common error is accidentally relocating large source trees,
> where an "mv" command is accidentally relocating entire sets of
> projects rather than merely branches.

That one is more difficult, and actually not a good fit for limiting
either file size or commit size (the commit in this case will be tiny,
since no files are transferred at all). That's more something for
other types of hooks (perhaps access control related) or something
like mod_dontdothat.

> I'm not saying this is easy to build into Subversion, the pre-commit
> filter would have to summarize and asses the size of the entire
> commit. I'm just saying there are reasonable reasons to want such a
> filter.

-- 
Johan

Re: Limit The size of Commit in SVN

Posted by Nico Kadel-Garcia <nk...@gmail.com>.
On Tue, Feb 4, 2014 at 7:25 AM, Stephen Connolly
<st...@gmail.com> wrote:
> Nope I cannot. I don't use windows, and I only use SVN for those projects I
> work on that are still on SVN.
>
> I think you are missing the point that *everyone* has been trying to get you
> to see...
>
> What is the benefit in stopping 1GB+ commits?

In my experience, they're almost inevitably mistakes. They're often
accidental including bulky binary files, which then are incredibly
painful to "obliterate" from the repository because there is still no
"obliterate" option for inappropriately stored files in the repository
itself, and from the current code lines, there *never will be* such an
option. The dump/filter/reload echanism is extremely painful for
clearing such accidentally stored binaries.

The other common error is accidentally relocating large source trees,
where an "mv" command is accidentally relocating entire sets of
projects rather than merely branches.

I'm not saying this is easy to build into Subversion, the pre-commit
filter would have to summarize and asses the size of the entire
commit. I'm just saying there are reasonable reasons to want such a
filter.

Re: Limit The size of Commit in SVN

Posted by Stephen Connolly <st...@gmail.com>.
Nope I cannot. I don't use windows, and I only use SVN for those projects I
work on that are still on SVN.

I think you are missing the point that *everyone* has been trying to get
you to see...

What is the benefit in stopping 1GB+ commits?

Either the developer is going to split the commit into two 0.9GB revisions
and commit the 1.8GB anyway... so not stopping the repository from becoming
bloated... or the developer will keep those files out of source control...
so defeating the whole point of source control.

I contend that the real issue here is that you don't want developers
committing large binary files. In which case the commit hook should look
for large binary files and reject commits including them.

If you are concerned with server load, a commit hook is too late... the
file has already landed on the server when the server side hooks are
running.

If you are concerned with large binary files in SVN, a different commit
hook is what you want, i.e. one that stops the large binary files... not
one that prevents what may be a legitimate commit.

Consider the case where there are video prompts associated with text
messages in a repository.  When committing a change to the text messages,
you should also commit the updated prompts (because it is a change that
should be part of the commit... having an incorrect video prompt for the
text message is a bug).

If I have to rework 20 of the messages as a result of a single refactoring
(introducing another screen, so all the messages now have to have "or via
the foo screen" appended... which requires a re-recording of all affected
messages by the talent), that could well mean committing the code for the
addition of the "foo" screen, with the message text changes and the updated
video files.

Putting a 1GB limit per revision will prevent me committing the change as a
single commit (which one can argue is the correct thing to do for this
single change).

TL;DR it sounds very much like you are solving the "wrong" problem... ask
yourself what is the real problem you want to solve and then solve that
problem instead.


On 4 February 2014 12:03, Mehboob Ahmed <m....@gmail.com> wrote:

> hi Stephen
>
> i've shared the incmplete hook. if the commit size is larger than one gb
> than commit should cancel and prop up the echo msg... and let user commit
> less than 1GB data. can u provide me hook for windows for Tortoise SVN
>
>
>
> --
> View this message in context:
> http://subversion.1072662.n5.nabble.com/Limit-The-size-of-Commit-in-SVN-tp186696p186905.html
> Sent from the Subversion Users mailing list archive at Nabble.com.
>

Re: Limit The size of Commit in SVN

Posted by Mehboob Ahmed <m....@gmail.com>.
hi Stephen

i've shared the incmplete hook. if the commit size is larger than one gb
than commit should cancel and prop up the echo msg... and let user commit
less than 1GB data. can u provide me hook for windows for Tortoise SVN



--
View this message in context: http://subversion.1072662.n5.nabble.com/Limit-The-size-of-Commit-in-SVN-tp186696p186905.html
Sent from the Subversion Users mailing list archive at Nabble.com.

Re: Limit The size of Commit in SVN

Posted by Stephen Connolly <st...@gmail.com>.
On 4 February 2014 10:45, Mehboob Ahmed <m....@gmail.com> wrote:

> hey Johan,
>
> all i want is when my developer hit the commit button my script trigger the
> error if the commit size only commit size no repository size only that
> perticular commit size is greater than a GB.
>
> @echo off
> :: Stops commits that have size of greated than 1GB.
> @echo off
>
>
>
>
> set REPOS=%1
>
> set TXN=%2
>
> set MAX_BYTES= 1073741824
>
> svnlook changed -t %TXN% %REPOS%
>
> svnlook filesize -t %TXN% %REPOS% %changed%
>
> for /D /r %%G IN (%TXN%) DO (
>
> if "%G%" 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
>
>
You're still going to have the 1GB transferred to the server before the
script runs... unless I misunderstand... so what is the utility in such a
restriction? You won't be saving the server load or the client commit
time... the only thing you may catch is somebody committing very large
binary files to SVN... which probably suggests a different check anyway



> Please Guide will be very great full to you.
> Regards
> Mehboob Ahmed
>
>
>
> --
> View this message in context:
> http://subversion.1072662.n5.nabble.com/Limit-The-size-of-Commit-in-SVN-tp186696p186895.html
> Sent from the Subversion Users mailing list archive at Nabble.com.
>

Re: Limit The size of Commit in SVN

Posted by Mehboob Ahmed <m....@gmail.com>.
hey Johan,

all i want is when my developer hit the commit button my script trigger the
error if the commit size only commit size no repository size only that
perticular commit size is greater than a GB.

@echo off  
:: Stops commits that have size of greated than 1GB.        
@echo off


  

set REPOS=%1

set TXN=%2
      
set MAX_BYTES= 1073741824

svnlook changed -t %TXN% %REPOS%

svnlook filesize -t %TXN% %REPOS% %changed%

for /D /r %%G IN (%TXN%) DO (

if "%G%" 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

Please Guide will be very great full to you.
Regards
Mehboob Ahmed



--
View this message in context: http://subversion.1072662.n5.nabble.com/Limit-The-size-of-Commit-in-SVN-tp186696p186895.html
Sent from the Subversion Users mailing list archive at Nabble.com.

Re: Limit The size of Commit in SVN

Posted by Johan Corveleyn <jc...@gmail.com>.
On Mon, Feb 3, 2014 at 1:09 PM, Mehboob Ahmed <m....@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

Re: Limit The size of Commit in SVN

Posted by Nico Kadel-Garcia <nk...@gmail.com>.
I don't have such a tool. I see some pre-commit scripts in the
subversion source tree that might be a starting place, but nothing
aimed at measuring and restricting file size. If you're restricting
the complete diff size, not just individual files, you're going to
need to have a look that adds up all those diffs. And it's going to
need to be in Perl or Python, not shell, because shell gets a bit
strange when adding numbers larger than 255.

I don't have the time or the need for that tool myself, I'm on a
contract that is keeping me busy. I'd look into the existing python
based pre-commit scripts for some hint on how to accomplish this.

On Mon, Feb 3, 2014 at 7:09 AM, Mehboob Ahmed <m....@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
> ==========================
> Waiting for your reply
> Regards Mehboob Ahmed
>
>
>
> --
> View this message in context: http://subversion.1072662.n5.nabble.com/Limit-The-size-of-Commit-in-SVN-tp186696p186865.html
> Sent from the Subversion Users mailing list archive at Nabble.com.

Re: Limit The size of Commit in SVN

Posted by Mehboob Ahmed <m....@gmail.com>.
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
==========================
Waiting for your reply
Regards Mehboob Ahmed



--
View this message in context: http://subversion.1072662.n5.nabble.com/Limit-The-size-of-Commit-in-SVN-tp186696p186865.html
Sent from the Subversion Users mailing list archive at Nabble.com.

Re: Limit The size of Commit in SVN

Posted by Nico Kadel-Garcia <nk...@gmail.com>.
On Wed, Jan 22, 2014 at 8:40 PM, Ryan Schmidt
<su...@ryandesign.com> wrote:
> On Jan 22, 2014, at 01:34, Mehboob Ahmed wrote:
>
>> Is ther any hook who wont allow user to commit in SVN whose size is greater than 1GB.it means i want to restrict user to commit less than 1GB of data in SVN. i need this hook in windows format .bat file extention please help.
>
> Yes, you could write a hook to do that.

Limit the size of individual files? Or of the changes accumulated
together of all the relevant files?  Or of the difference in files?

Now, if I were thinking aobut a pre-commit script from scratch, I
might want to restrict binary files, such as *.iso, *.war, *.jar, *.o,
*.gz, *.tar, *.zip, *.a, etc., especially for what should be a source
repository. That can help prevent a lot of the accidental commits you
might see, such as compiled files in a source code repository.

Why, exactly, are you trying to limit the maximum commit size?

Re: Limit The size of Commit in SVN

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jan 22, 2014, at 01:34, Mehboob Ahmed wrote:

> Is ther any hook who wont allow user to commit in SVN whose size is greater than 1GB.it means i want to restrict user to commit less than 1GB of data in SVN. i need this hook in windows format .bat file extention please help.

Yes, you could write a hook to do that.