Created
January 5, 2013 09:27
-
-
Save komiya-atsushi/4460731 to your computer and use it in GitHub Desktop.
Mercurial のリポジトリにおける、case folding collision を回避するための Python スクリプトです。
セントラルリポジトリの pretxnchangegroup フックでこのスクリプトを実行するように設定します。
This file contains 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
#!/usr/bin/env python | |
import commands | |
import sys | |
latest_node = commands.getoutput("hg head --template '{node}'") | |
file_statuses = commands.getoutput("hg status --all --rev %(latest_node)s" % { "latest_node": latest_node }) | |
file_status_list = file_statuses.split('\n') | |
latest_files = [x[2:] for x in file_status_list if len(x) >= 3 and x[0] != "A" and x[0] != " "] | |
latest_file_set = set([x.lower() for x in latest_files]) | |
case_sensitive_file_count = len(latest_files) | |
case_insensitive_file_count = len(latest_file_set) | |
if case_insensitive_file_count < case_sensitive_file_count: | |
print "Error: You cannot push changesets which cause case folding collision problems." | |
for filename in latest_files: | |
lower_filename = filename.lower() | |
if lower_filename in latest_file_set: | |
print filename | |
break | |
latest_file_set.remove(lower_filename) | |
sys.exit(1) | |
else: | |
sys.exit(0) |
This file contains 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
[hooks] | |
pretxnchangegroup.avoidcasefoldingcollision=/path/to/avoid-case-folding-collision.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment