@@ -0,0 +1,995 @@
+from mercurial import context%0Afrom mercurial.i18n import _%0A%0A'''%0A%5Bextensions%5D%0Ahgfilesize=~/m5/incoming/util/hgfilesize.py%0A%0A%5Bhooks%5D%0Apretxncommit = python:hgfilesize.limit_file_size%0Apretxnchangegroup = python:hgfilesize.limit_file_size%0A%0A%5Blimit_file_size%5D%0Amaximum_file_size = 200000%0A'''%0A%0Adef limit_file_size(ui, repo, node=None, **kwargs):%0A    '''forbid files over a given size'''%0A%0A    # default limit is 1 MB%0A    limit = int(ui.config('limit_file_size', 'maximum_file_size', 1024*1024))%0A    existing_tip = context.changectx(repo, node).rev()%0A    new_tip = context.changectx(repo, 'tip').rev()%0A    for rev in xrange(existing_tip, new_tip + 1):%0A        ctx = context.changectx(repo, rev)%0A        for f in ctx.files():%0A            fctx = ctx.filectx(f)%0A            if fctx.size() %3E limit:%0A                ui.write(_('file %25s of %25s is too large: %25d %3E %25d%5Cn') %25 %5C%0A                             (f, ctx, fctx.size(), limit))%0A                return True # This is invalid%0A%0A    return False # Things are OK.%0A

Add a hook to limit the size of any individual file