hgkw/updatekw.py
author Christian Ebert <blacktrash@gmx.net>
Sun, 17 Dec 2006 10:57:55 +0100
branchupdatehook
changeset 25 aa3fbe81e9ad
parent 19 d1f478aa61c5
child 28 c7f5821f3513
permissions -rw-r--r--
Make wwritekw() and all vars local
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
     1
# $Hg$
5
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     2
19
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
     3
import kwexpander
5
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     4
19
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
     5
def updatekw(ui, repo, hooktype, **args):
5
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     6
    '''Important: returns False on success, True on failure.'''
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     7
19
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
     8
    if hooktype != 'update':
5
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     9
        # bail out with error
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    10
        return True
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    11
19
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    12
    p1, p2 = args['parent1'], args['parent2']
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    13
    node1 = repo.changelog.lookup(p1)
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    14
    if p2:
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    15
        node2 = repo.changelog.lookup(p2)
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    16
        # next line for debugging only (check merges)
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    17
        ui.warn('parent2: %s\n' % p2)
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    18
    else:
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    19
        node2 = None
5
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    20
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    21
    (modified, added, removed, deleted,
19
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    22
            unknown, ignored, clean) = repo.status(node1=node1, node2=node2)
5
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    23
    candidates = modified + added + clean
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    24
19
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    25
    return kwexpander.expandkw(ui, repo,
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    26
            node1, p1, candidates, update=True)