Skip to content

Instantly share code, notes, and snippets.

@rifttech
Created December 6, 2019 16:25
Show Gist options
  • Select an option

  • Save rifttech/0c55fe7bbee72adba6a2faf2cd692810 to your computer and use it in GitHub Desktop.

Select an option

Save rifttech/0c55fe7bbee72adba6a2faf2cd692810 to your computer and use it in GitHub Desktop.
Mercurial - Hooks
import os
import re
def no_cyrillic_hook(ui, repo, **kwargs):
_changedFiles = [os.path.basename(file) for file in repo[kwargs['node']].changeset()[3]]
for t in _changedFiles:
try:
t.decode('ascii')
except UnicodeDecodeError:
ui.warn("\nCyrillic Detected!")
ui.warn("\nIllegal filename: " + t + "\n")
return 1
else:
pass
return 0
[hooks]
pretxncommit = python:.hg/../custom_hooks.py:no_cyrillic_hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment