Limit Size of Subversion Commits With this Hook

We have experienced some abuse of our subversion repository at work recently. Someone committed 400 MB of data all at once including many object files, libraries, and executables. I did not get very harsh with the person who did this. Because a) I have no objection to binaries in subversion in the first place, b) I don't really know what he's working on, c) disk space is cheap and we are no where near capacity, and d) his commit was still smaller than a few commits we had a long time ago (which were legit). Still, if you just allow people to commit whatever they want to your subversion repository, in the worst case, you could run out of disk space, necessitating an svn dump-and-load onto a new larger drive (pain). It would suck to have to do that just because some people were committing large binaries (without any legitimate reason to). There are other annoying consequences. Our tarball backups of svn currently fit on a DVD, which is cheap and easy, if we allowed this abuse to continue it would complicate our backup process.

What I wanted was a way to limit the commit size for certain users automatically. There did not seem to be any hooks out there to do this, so I wrote one.

Just paste the following into your pre-commit hook:

/svn/repos/hooks/check_txn_size.py "$REPOS" "$TXN" || exit 1

and paste the following into a check_txn_size.py file in your hooks directory and make it executable.

#!/usr/bin/env python
import sys,os,popen2
 
MAX_BYTES = 1024000
DEBUG = False
SVNLOOK = '/usr/bin/svnlook'
ALLOWED_USERS = ['david', 'ctang', 'vjain', 'mike', 'sbridges', 'tcirip']
ADMIN_EMAIL = '<a href="mailto:admin@company.com">admin@company.com</a>'
 
def printUsage():
  sys.stderr.write('Usage: %s "$REPOS" "$TXN" ' % sys.argv[0])
 
def getTransactionSize(repos, txn):
  txnRevPath = repos+'/db/transactions'+'/'+txn+'.txn'+'/rev'
  return os.stat(txnRevPath)[6]
 
def printDebugInfo(repos, txn):
  for root, dirs, files in os.walk(repos+'/db/transactions', topdown=False):
    sys.stderr.write(root+", filesize="+str(os.stat(root)[6])+"\n\n")
    for name in files:
      sys.stderr.write(name+", filesize="+str(os.stat(root+'/'+name)[6])+"\n")
 
def checkTransactionSize(repos, txn):
  size = getTransactionSize(repos, txn)
  if (size > MAX_BYTES):
    sys.stderr.write("Sorry, you are trying to commit %d bytes, which is larger than the limit of %d.\n" % (size, MAX_BYTES))
    sys.stderr.write("If you think you have a good reason to, email %s and ask for permission." % (ADMIN_EMAIL))
    sys.exit(1)
 
def getUser(repos, txn):
  cmd = SVNLOOK + " author " + repos + " -t " + txn
  out, x, y = popen2.popen3(cmd)
  cmd_out = out.readlines()
  return cmd_out[0][:-1]
 
if __name__ == "__main__":
  #Check that we got a repos and transaction with this script
  if len(sys.argv) != 3:
    printUsage()
    sys.exit(2)
  else:
    repos = sys.argv[1]
    txn = sys.argv[2]
 
  if DEBUG: printDebugInfo(repos, txn)
  user=getUser(repos, txn)
  if DEBUG: sys.stderr.write("User:"+user)
  if DEBUG:
    if (user in ALLOWED_USERS):
      sys.stderr.write(user+" in allowed users")
    else:
      sys.stderr.write(user+" not in allowed users")
  if (user not in ALLOWED_USERS):
    checkTransactionSize(repos, txn)

Comments

Thank you for some other informative blog. Where else could I get that type of information written in such an ideal means? I have a mission that I’m just now working on, and I have been at the look out for such information.
my apron

Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing
Pleural Mesothelioma

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well..
Shade Sail Services

ugg outlet
coach factory outlet
coach outlet
cheap nfl jerseys
nfl jerseys wholesale
ray ban sunglasses
cheap ray ban sunglasses
ray ban sunglasses
ray ban sunglasses discount
kate spade handbag
kate spade bags
canada goose jackets
canada goose outlet
air max 2018
moncler jackets outlet
moncler outlet
adidas yeezy
adidas yeezy boost
harden vol 1
nike air max
louboutin shoes
christian louboutin outlet
kate spade
kate spade handbags
nike shoes
fitflops sale
fitflops
cheap uggs
ugg boots for women
ugg boots outlet
ugg boots
ugg outlet
ugg outlet store
ugg sale
ugg boots on sale
uggs canada
ugg boots canada
canada goose jackets
canada goose
canada goose outlet
canada goose sale
canada goose outlet
canada goose sale
louis vuitton outlet
louis vuitton factory outlet
ugg ustralia
ugg boots
ugg ustralia
ugg australia
canada goose outlet
canada goose
burberry outlet
burberry sale
canada goose jackets
canada goose outlet
canada goose outlet
canada goose sale
cat boots
coach outlet
coach canada
canada goose outlet
canada goose sale
kate spade
kate spade outlet
longchamp outlet
longchamp handbags
louis vuitton outlet
louis vuitton outlet store
mbt shoes
michael kors outlet
michael kors outlet store
north face outlet
north face outlet online
polo ralph lauren
polo ralph lauren outlet online
red bottom shoes
louboutin shoes
timberland outlet
ugg boots
ugg boots on sale
ugg boots
ugg outlet
ugg slippers
ugg sandals
cheap uggs
cheap uggs
ugg sale
canada goose jackets
ugg boots
uggs outlet
moncler outlet
moncler jackets
ralph lauren outlet online
ralph lauren outlet
polo outlet
polo ralph lauren outlet online
air jordans
air jordan shoes
canada goose clothing
canada goose coats
canada goose jackets
canada goose coats
cheap uggs
coach factory outlet
coach outlet
coach outlet store online
coach outlet
coach outlet
coach factory outlet
coach factorty outlet
coach outlet
columbia sportswear
ray ban sunglasses
cheap ray ban sunglasses
hermes outlet
hermens bags
louis vuitton outlet
louis vuitton outlet store
moncler jackets
moncler coats
moncler outlet
moncler jackets
north face jackets
pandora charms sale clearance
pandora charms sale
ralph lauren outlet
polo ralph lauren outlet online
salvatore ferragamo shoes
salvatore ferragamo
timberland boots
toms outlet
tory burch outlet
ugg outlet
ugg boots
ugg boots
uggs on sale
ugg boots
uggs
ugg outlet
ugg boots
ugg shoes
ugg shoes
ugg outlet
uggs clearance
ugg outlet
ugg outlet online
louis vuitton
louis vuitton outlet online
burberry outlet
cheap jerseys
cheap jerseys from china
michael kors outlet
michael kors outlet online
nike air max
air max 2017
adidas superstar
fred perry
fred perry polo
louis vuitton outlet
louis vuitton outlet online
mbt shoes
michael kors outlet
michael kors outlet store
coach factory outlet
coach outlet online
canada goose outlet
canada goose jackets
burberry outlet
uggs clearance
canada goose outlet
canadian goose
ugg boots
cheap uggs
canada goose outlet
canada goose sale
canada goose jackets
canada goose clothing
ugg outlet
moncler outlet
moncler jackets
coach factorty outlet
coach outlet
canada goose jackets
canada goose uk
adidas shoes
cheap ray bans
cheap ray ban sunglasses
polo outlet
polo ralph lauren outlet online
canada goose outlet
canada goose
michael kors outlet
michael kors outlet clearance
air jordan shoes
jordan shoes
burberry outlet
burberry outlet store
north face jackets
ralph lauren outlet
polo ralph lauren outlet online
ugg australia
cheap jordans
cheap jordans for sale
ugg outlet
ugg uk
ugg
moncler jackets
canada goose jackets
canada goose
oakley sunglasses
ugg boots
ugg boots
ferragamo outlet
ferragamo shoes
burberry outlet
burberry
canada goose outlet
supreme clothing
uggs outlet
ugg outlet
the north face
north face outlet
moncler uk
moncler
canada goose jackets
canada goose
canada goose jackets
canada goose coats
michael kors outlet
michael kors outlet store
nike outlet
nike outlet store
moncler uk
moncler jackets
ugg outlet
ugg outlet online
gucci handbags
cheap ugg boots
ugg boots
supreme new york
supreme clothing
ugg canada
uggs canada
longchamp outlet
longchamp outlet online
north face jackets
north face outlet
north face jackets
ralph lauren outlet
polo ralph lauren outlet
ugg outlet
uggs clearance
canada goose jackets
ugg outlet
uggs outlet
ugg outlet
uggs outlet
canada goose outlet
ugg boots
canada goose sale
uggs on sale
uggs sale
ugg boots
ugg boots on sale
uggs outlet
ugg outlet
canada goose outlet
ugg australia
uggs canada
uggs
ralph lauren outlet
ugg outlet
ugg outlet
ugg outlet
ugg outlet
ugg outlet
ugg boots
canada goose jackets
canada goose jackets
canada goose outlet
canada goose outlet
ralph lauren
ralph lauren outlet
ugg outlet
ugg outlet
ugg outlet
canada goose outlet
canada goose outlet
ugg boots
ugg boots
canada goose outlet
canada goose outlet
canada goose outlet
ralph lauren outlet
2017.11.4yangping

This is my first time visit here. From the tons of comments on your articles,I guess I am not only one having all the enjoyment right here! mt4 indicator

e. Alors Toms Factory Outlet il se releva tout à cheap uggs fait et, gagnant Nike Air Sneakers un terrain toms shoes outlet plat, l’arpenta de long en large, Official NHL Jerseys de son Cheap Michael Kors Handbags pas canada goose jackets on sale pesant.
De temps Michael Kors Handbags Discount à christian louboutin outlet autre, il revenait vers Moncler Jackets Discount Marketplace la berge coach factory outlet online et, de ses yeux Ugg boots Sale dilatés, nike air continuait à womens nike air max interroger ジョーダン スニーカー la piste du Discount Ray Ban Sunglasses Yukon, comme Negozi Pandora si, Nike Air Shoes par la tension de sa Billige Nike Sko volonté, il avait pu Nike Factory Outlet y matérialiser Discount Christian Louboutin Shoes enfin la nike schuhe günstig forme attendue d’un homme. Mais Nike Polo Sale rien chaussure basket homme n’apparut.
Il revint se réchauffer un peu à son feu de campement, qu’il ranima. Nike Factory Store Puis il Pandora Style Beads recommen?a son Nike Roshe Run Sale même Ugg Outlet Online Store manège.
La température adidas outlet monta UGGS Outlet légèrement, pendant l’après-midi, et la 23 IS BACK Store neige se mit à tomber, fine et dure Nike Shox Cheap comme du cristal. new jordan releases Il n’y avait pas Coach Bags On Sale de vent. Nike Pas Cher Femme Les blancs flocons nfl store descendaient tout droit, en une Air Max Pas Cher paisible monotonie.
Morganson se tapit zapatos de futbol nike dans Pandora Outlet un günstige nike schuhe creux du Adidas Superstar Sale Online sol, sous l’avalanche Moncler Outlet Online inlassable, les yeux fermés, et Adidas Originals Stan Smith à TOMS For Sale demi courbé, la tête sur ses Nike Tn Requin Pas Cher genoux. Il ne pouvait Adidas Yeezy Boost 350 For Sale voir, mais louboutin heels ses oreilles Cheap Michael Kors montaient la garde.
Mais Cheap Toms Shoes Outlet pas un glapissement de chiens, pas un crissement Cheap Air Max Trainers de Discount TOMS tra?neaux, pas Canada Goose Online Store un cri The official UGG des conducteurs Doudoune Moncler Pas Cher ne rompait prada outlet le silence.
Au air force one pas cher crépuscule, l’homme Air Nike rallia sa tente, se coupa botas de futbol une nouvelle provision de cheap nike air max bois, Yeezy Men mangea Toms Outlet Online deux scarpe nike biscuits et Cheap Nike Free Run se fourra sous vans shoe store ses couvertures.
Mais il Canada Goose Outlet avait Moncler Outlet insuffisamment mangé. Nike Kyrie Aussi Cheap Retro Jordans For Sale ne UGG BOOTS FOR WOMEN dormit-il Official Toms Shoes Outlet que d’un sommeil agité, Nike Shoes Sale Store se Adidas Originals Sale retournant Christian Louboutin Heels sur zapatillas nike baratas lui-même à New Air Max 2017 tout moment, en geignant Uggs Pas Cher Soldes et Pandora Store en grognant. Adidas Originals Superstar à Original Ugg Boots minuit, ADIDAS NMD SALE ON LINE il Moncler Sale dut Nike Outlet se Nike Shoes Online relever et absorber un nike sportschuhe autre biscuit.
*
Au cours des nike air jordan pas cher jours Air max levně qui suivirent, le Boost Yeezy Sale On Line froid se fit plus Yeezy Boost Sale Online intense.
Morganson constata nike shoes que adidas store quatre biscuits Cheap Air Max par Louboutin Wedding Shoes jour étaient insuffisants Adidas NMD For Sale à Coach Outlet Store Online fournir à Nike Free Run 5.0 Womens son Kobe Shoes Nike corps le calorique nécessaire, en dépit des innombrables Soccer Boots Outlet nike tasses de bourgeons de sapin Adidas Superstar dont, Jordan Sneakers For Sale pour soigner son scorbut, il newest lebron shoes assaisonnait sa nourriture. Il Nike Store dut augmenter sa ration.
Son menu fut, dès lors, de trois Air max dam biscuits Jordan Store le モンクレール レディース matin, de thé à midi, de trois nike tn pas cher autres Zapatillas Air Max biscuits le soir. Yeezy Shoes Discount Marketplace Entre-temps, new pandora charms de la converse store tisane de bourgeons de Adidas Neo Discount Sale sapin, à discrétion.
Il y Scarpe Air Max eut Doudoune Moncler Femme Pas Cher un TOMS SHOES OUTLET jour où Ugg Pas Cher En France Morganson Nike Huarache Womens Cheap se surprit à augmenter la dimension des biscuits nike jordan shoes qu’il cheap uggs for women confectionnait. Canada Goose Womens Coats Il soutint une lutte apre contre lui-même et revint Timberland Outlet au Adidas Yeezy Cheap calibre Nike Air Pas Cher primitif.
Le cinquième Doudoune Moncler Site Officiel jour, la piste Pandora Store de Yukon se ranima. longchamp bags on sale Vers le Michael Kors Clearance Sud, apparut Yeezy Black une Hugo Boss Sale silhouette fitflops sale uk sombre, qui grossit Scarpe Nike Scontate peu à Vans Black Sneakers peu. Morganson, Nike Air Huarache For Sale du pandora beads coup, chaussures nike pas cher s’alerta.
Afin de s’assurer si asics sko le chaussure adidas pas cher mécanisme fonctionnait bien, Jordan Shoes Air il Nike Air Jordan 11 fit jouer Air Max Sneakers son fusil, Nike Air Max Goedkoop chassa du Uggs For Cheap magasin une Zapatillas Nike Air Max Baratas cartouche, qu’il huarache sneakers rempla?a TOMS OUTLET par New Nike Shoes une autre, avec Canada goose dam laquelle retro jordans for cheap il Christian Louboutin Shoes Outlet recommen?a Adidas Soccer Cleats Cheap la Chaussure Nike Pas Cher même expérience.
Ensuite il Discount Air Max s’agenouilla Cheap Nike Air Huarache dans son trou, Air Jordan Retro Sale releva Reebok Outlet Store lentement Cheap Nike Huarache la détente de son arme, et la Air Max Femme rabaissa avec Chaussure Nike Air Max Pas Cher des précautions identiques. Puis il Nike Roshe Run la couvrit de sa Michael Kors moufle, afin Chaussure Air Max de tenir UGGS For Women tiède le Nike Air Women métal.
à mesure Moncler Outlet Store que nike mercurial soccer cleats s’avan?ait l’ombre noire, Pandora Store Sale il Air Max Kopen put discerner Nike Air Damen que c’était nike sneakers un Pandora Official Website homme ugg clearance qui voyageait à nike sb stefan janoski pied, seul, sans chiens ni tra?neau, ni aucune sorte d’équipement.
Morganson Nike Shoes Discount Marketplace devint nerveux. Cheap Louboutin Heels Le gibier Nike joggesko était maigre. D’une Cheap True Religion Jeans main Nike Air Max Sale hésitante, Nike Air Max Cheap il arma cependant son fusil. Mais il se trouva, Hogan Outlet en Michael Kors Outlet fin de compte, que le Cheap Real Jordans voyageur était simplement Air Max 90 un Nike Shox discount Sale Indien.
Morganson poussa un Boutique Ugg soupir désappointé et laissa retomber pandora jewelry store son arme. L’Indien, poursuivant paisiblement Nike Soccer Cleats Boots sa Stone Island Outlet route, passa Cheap Michael Kors Tote Bag devant canada goose jacket outlet lui et Cheap Toms Outlet Store disparut, peu après, suivre un envoi dans Descuentos Nike la direction de Minto, derrière le contrefort boisé Cheap True Religion Jeans de Ugg Pas Cher Femme la Mens Nike Air Max vallée.
Cet Nike Outlet Store échec ne découragea point Morganson. Bottes Ugg Femme Pas Cher Il songea, au Boty Nike Air contraire, à parfaire son Abercrombie and fitch store embuscade. Il se reporta, Canada Goose Outlet avec son ugg factory outlet fusil, moncler jacket sale un peu en Nike Air 90 arrière, jusqu’à l’entrée du UGG Boots Cheap marécage, ugg store parmi Pandora Outlet Store les premiers peupliers et Adidas Shoes Discount Marketplace les TOMS STORE buissons Nike Online Store touffus dont ils émJordan Shoes For Cheap

Pages

Add new comment