hgkw/pretxnkw.py
author Christian Ebert <blacktrash@gmx.net>
Thu, 14 Dec 2006 10:33:35 +0100
branchupdatehook
changeset 7 e5f131217f87
child 20 6dc2b4268920
permissions -rw-r--r--
Add pretxnkw module for updatehook branch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     1
# $Hg: pretxnkw.py,v$
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     2
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     3
from hgkw import kwexpander
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     4
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     5
def pretxnkw(ui=None, repo=None, hooktype='', **args):
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     6
    '''Important: returns False on success, True on failure.'''
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     7
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     8
    node = args['node'][0:12]
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     9
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    10
    if not ui or not repo or not node or hooktype != 'pretxncommit':
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    11
        # bail out with error
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    12
        return True
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    13
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    14
    modified, added = repo.status()[1:3]
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    15
    candidates = modified + added
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    16
e5f131217f87 Add pretxnkw module for updatehook branch
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    17
    return kwexpander.expandkw(ui, repo, repo.changelog.tip(), node)