hgkw/updatekw.py
author Christian Ebert <blacktrash@gmx.net>
Sun, 17 Dec 2006 15:32:34 +0100
branchupdatehook
changeset 29 bda83c13da42
parent 28 c7f5821f3513
child 32 b70b38b15fa4
permissions -rw-r--r--
Clean up variable names; do not explicitly return False
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
28
c7f5821f3513 Do not explicitly exit False; rename node1/2 to r1/2, p1/2 to n1/2
Christian Ebert <blacktrash@gmx.net>
parents: 19
diff changeset
    12
    n1, n2 = args['parent1'], args['parent2']
c7f5821f3513 Do not explicitly exit False; rename node1/2 to r1/2, p1/2 to n1/2
Christian Ebert <blacktrash@gmx.net>
parents: 19
diff changeset
    13
    r1 = repo.changelog.lookup(n1)
c7f5821f3513 Do not explicitly exit False; rename node1/2 to r1/2, p1/2 to n1/2
Christian Ebert <blacktrash@gmx.net>
parents: 19
diff changeset
    14
    if n2:
c7f5821f3513 Do not explicitly exit False; rename node1/2 to r1/2, p1/2 to n1/2
Christian Ebert <blacktrash@gmx.net>
parents: 19
diff changeset
    15
        r2 = repo.changelog.lookup(n2)
19
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)
28
c7f5821f3513 Do not explicitly exit False; rename node1/2 to r1/2, p1/2 to n1/2
Christian Ebert <blacktrash@gmx.net>
parents: 19
diff changeset
    17
        ui.warn('parent2: %s\n' % n2)
19
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
    18
    else:
28
c7f5821f3513 Do not explicitly exit False; rename node1/2 to r1/2, p1/2 to n1/2
Christian Ebert <blacktrash@gmx.net>
parents: 19
diff changeset
    19
        r2 = 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,
28
c7f5821f3513 Do not explicitly exit False; rename node1/2 to r1/2, p1/2 to n1/2
Christian Ebert <blacktrash@gmx.net>
parents: 19
diff changeset
    22
            unknown, ignored, clean) = repo.status(node1=r1, node2=r2)
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
28
c7f5821f3513 Do not explicitly exit False; rename node1/2 to r1/2, p1/2 to n1/2
Christian Ebert <blacktrash@gmx.net>
parents: 19
diff changeset
    25
    if  candidates:
c7f5821f3513 Do not explicitly exit False; rename node1/2 to r1/2, p1/2 to n1/2
Christian Ebert <blacktrash@gmx.net>
parents: 19
diff changeset
    26
        return kwexpander.expandkw(ui, repo, r1, n1, candidates, update=True)