def autohook(ui, repo, hooktype, **kwargs):
    """Look for hooks inside the repository to run."""
    cmd = hooktype.replace("-", "_")
    if not repo or not cmd.replace("_", "").isalpha():
        return False
    result = False
    trusted = ui.configlist("autohooks", "trusted")
    if "" not in trusted:
        default_path = ui.config("paths", "default")
        if not default_path:
            return False
        for match in trusted:
            if default_path.startswith(match):
                break
        else:
            return False
    for hookdir in ("hg-autohooks", ".hg-autohooks"):
        dirname = os.path.join(repo.root, hookdir)
        if not os.path.exists(dirname):
            continue
        for leafname in os.listdir(dirname):
            if not leafname.startswith(cmd + "."):
                continue
            filename = os.path.join(dirname, leafname)
            result = _runhook(ui, repo, hooktype, filename, kwargs) or result
    return result
def autohook ( ui , repo , hooktype , ** kwargs ) : cmd = hooktype . replace ( "-" , "_" ) if not repo or not cmd . replace ( "_" , "" ) . isalpha ( ) : return False result = False trusted = ui . configlist ( "autohooks" , "trusted" ) if "" not in trusted : default_path = ui . config ( "paths" , "default" ) if not default_path : return False for match in trusted : if default_path . startswith ( match ) : break else : return False for hookdir in ( "hg-autohooks" , ".hg-autohooks" ) : dirname = os . path . join ( repo . root , hookdir ) if not os . path . exists ( dirname ) : continue for leafname in os . listdir ( dirname ) : if not leafname . startswith ( cmd + "." ) : continue filename = os . path . join ( dirname , leafname ) result = _runhook ( ui , repo , hooktype , filename , kwargs ) or result return result
Look for hooks inside the repository to run.