hgkw/updatekw.py
author Christian Ebert <blacktrash@gmx.net>
Tue, 19 Dec 2006 15:57:03 +0100
branchextension
changeset 37 3dc31476c148
parent 32 b70b38b15fa4
permissions -rw-r--r--
Standalone version for keyword.py Check "expand" patterns in the [keyword] config section. Removed keyword in file itself to simplify patterns. Revert (again) to basename.

# $Hg$

import kwexpander

def updatekw(ui, repo, hooktype, **args):
    '''Collects candidates for keyword expansion on update
    and passes them to kwexpander.'''

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

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

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

    if  candidates:
        return kwexpander.expandkw(ui, repo, r1, n1, candidates, update=True)