hgkw/updatekw.py
author Christian Ebert <blacktrash@gmx.net>
Sat, 16 Dec 2006 15:38:25 +0100
branchupdatehook
changeset 19 d1f478aa61c5
parent 5 85d1f5bf7cfc
child 28 c7f5821f3513
permissions -rw-r--r--
Use the "parent1|2" kwargs to detect file state Can parent2 be of further use? Like in parsing back history? Adapt keyword trigger to $Hg$ scheme.

# $Hg$

import kwexpander

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

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

    p1, p2 = args['parent1'], args['parent2']
    node1 = repo.changelog.lookup(p1)
    if p2:
        node2 = repo.changelog.lookup(p2)
        # next line for debugging only (check merges)
        ui.warn('parent2: %s\n' % p2)
    else:
        node2 = None

    (modified, added, removed, deleted,
            unknown, ignored, clean) = repo.status(node1=node1, node2=node2)
    candidates = modified + added + clean

    return kwexpander.expandkw(ui, repo,
            node1, p1, candidates, update=True)