Created
August 31, 2011 13:32
-
-
Save nivertius/1183543 to your computer and use it in GitHub Desktop.
Mercurial hook preventing debugger initializator slipping into repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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