Skip to content

Instantly share code, notes, and snippets.

@nivertius
Created August 31, 2011 13:32
Show Gist options
  • Save nivertius/1183543 to your computer and use it in GitHub Desktop.
Save nivertius/1183543 to your computer and use it in GitHub Desktop.
Mercurial hook preventing debugger initializator slipping into repository
from mercurial import hg, ui, util
searched_string = 'pdb.set_trace'
def hook(ui, repo, **kwargs):
current_context = repo[None]
for file_name in current_context.files():
if not file_name.endswith('.py'):
continue
file_context = current_context.filectx(file_name)
file_data = file_context.data()
if searched_string in file_data:
raise util.Abort("File %s contains forbidden string %s" % (file_name, searched_string))
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment