hgkw/updatekw.py
author Christian Ebert <blacktrash@gmx.net>
Tue, 19 Dec 2006 10:00:28 +0100
branchextension
changeset 35 a730c9d4ec05
parent 32 b70b38b15fa4
permissions -rw-r--r--
Interim test version in connection with keyword.py Simplify grep pattern. Outcomment filename lookup, will be changed to configitems('keywords'). Update stuff will be removed. And the whole thing will go into pretxncommit. kwupdate.py will be removed.
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):
32
b70b38b15fa4 Update function descriptions
Christian Ebert <blacktrash@gmx.net>
parents: 28
diff changeset
     6
    '''Collects candidates for keyword expansion on update
b70b38b15fa4 Update function descriptions
Christian Ebert <blacktrash@gmx.net>
parents: 28
diff changeset
     7
    and passes them to kwexpander.'''
5
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     8
19
d1f478aa61c5 Use the "parent1|2" kwargs to detect file state
Christian Ebert <blacktrash@gmx.net>
parents: 5
diff changeset
     9
    if hooktype != 'update':
5
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    10
        # bail out with error
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    11
        return True
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    12
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
    13
    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
    14
    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
    15
    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
    16
        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
    17
        # 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
    18
        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
    19
    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
    20
        r2 = None
5
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    21
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    22
    (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
    23
            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
    24
    candidates = modified + added + clean
85d1f5bf7cfc updatehook branch: add kwexpander and updatekw modules
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    25
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
    26
    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
    27
        return kwexpander.expandkw(ui, repo, r1, n1, candidates, update=True)