title: Conditionally Allow Checkin Only if Code Coverage Numbers increase
body: <p>I am Currently working on a big java project, which needs to be managed in bigger &amp; better ways. It is using SVN , Hudson , Sonar. After multiple checkins in a day , a nightly Hudson build is run , which also runs sonar , hence giving the new stats ( of code coverage , complexities etc ). But these numbers are not very useful as of now as they tell situation / figures after checkin.</p>
  
  <p>The practical situation is that , with every checkin the code covergae is decreasing. Now we want to bench mark the figures at present level. Lets say Code Coverage presently is at 45% What we want is the next checkin should be allowed if and only if it increases code code coverage % else not.</p>
  
  <p>My question is how this can be done ??</p>
  
  <p>I did some research around , came to know of two possible ways</p>
  
  <ol>
  <li>Use SVN Hooks</li>
  <li>Use Continuous Build servers like Hudson</li>
  </ol>
  
  <p>For 1st Option found link / tutorial : <a href="https://stackoverflow.com/questions/139315/can-i-run-a-script-when-i-commit-to-subversion">Can i run a script when i commit to subversion?</a></p>
  
  <p>The following two links seems to suggest 2nd option is better ( as it has much less checkin time) </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/6942801/sonar-integration-with-svn">Sonar integration with SVN</a></li>
  <li><a href="https://stackoverflow.com/questions/7109387/how-can-i-guarantee-all-unit-tests-pass-before-commiting">How can I guarantee all unit tests pass before committing?</a></li>
  <li>Also suggests using "Continuous Integration Game" </li>
  </ul>
  
  <p><strong>Questions</strong></p>
  
  <ol>
  <li>As i haven't worked on configuring hudson ( just used it as a normal user to initiate build ) what i dont understand from above two links is that... Sonar will run AFTER checkin is done, so how will it stop user to checkin if some test case failed ? or is my understanding incorrect ?? or it will send an email to all developers indicating stats before and after checkin ? or it will send email only if test case fails ??</li>
  <li>My use case is little different... before deciding to commit or not i want to check the new coverage % (including the present checkin changes ) and old coverage % ( before checkin changes ) and allow only if the new > old ... how can i do this using hudson+sonar ?? any code/config examples ??</li>
  <li>Or my use case is not possible by using Hudson ... and SVN hook is the only option for me ?? if yes any code example on how to do this</li>
  </ol>
  
  <p>Let me know if i need to clarify my question further</p>