hgkw/pretxnkw.py
author Christian Ebert <blacktrash@gmx.net>
Sun, 17 Dec 2006 14:09:06 +0100
branchupdatehook
changeset 27 d00d45c7ddaf
parent 26 bda0dec1aaf1
child 32 b70b38b15fa4
permissions -rw-r--r--
Do not explicitly return False at end

# $Hg$

import kwexpander
from mercurial import cmdutil, commands
import sys

def pretxnkw(ui, repo, hooktype, **args):
    '''Important: returns False on success, True on failure.'''

    if hooktype != 'pretxncommit':
        # bail out with error
        return True

    # reparse args, opts again as pretxncommit hook is silent about them
    sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[2:]
    files, match, anypats = cmdutil.matchpats(repo, sysargs, cmdopts)

    # validity checks should have been done already
    modified, added = repo.status(files=files, match=match)[:2]
    candidates = modified + added

    if candidates:
        r = repo.changelog.tip()
        n = args['node'][:12]
        # TODO: check whether we need parent1&2 like in updatekw
        return kwexpander.expandkw(ui, repo, r, n, candidates, update=False)