timestamp /

# - defines a hook for stop commiting case-folding
#               collisions
# Copyright 2009 Friedrich Kastner-Masilko <>
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.

from mercurial.i18n import _
from mercurial import util

def hook(ui, repo, hooktype, parent1=None, parent2=None, **kwargs):
    '''hook for stop commiting case-folding collisions'''
    if hooktype != 'precommit':
        raise util.Abort(_('casestop hook is only allowed for precommit!'))
    modified, added, removed, deleted, unknown, ignored, clean = [
        n for n in repo.status(clean=True)]
    changed = modified + added + clean
    fslow = {}
    for f in changed:
        flow = f.lower()
        if flow in fslow:
            raise util.Abort(_("case-folding collision between %s and %s")
                             % (f, fslow[flow]))
        fslow[flow] = f