Use the "parent1|2" kwargs to detect file state
Can parent2 be of further use? Like in parsing back history?
Adapt keyword trigger to $Hg$ scheme.
--- a/hgkw/updatekw.py Sat Dec 16 15:28:42 2006 +0100
+++ b/hgkw/updatekw.py Sat Dec 16 15:38:25 2006 +0100
@@ -1,20 +1,26 @@
-# $Hg: updatekw.py,v$
+# $Hg$
-from hgkw import kwexpander
+import kwexpander
-def updatekw(ui=None, repo=None, hooktype='', **args):
+def updatekw(ui, repo, hooktype, **args):
'''Important: returns False on success, True on failure.'''
- if not ui or not repo or hooktype != 'update':
+ if hooktype != 'update':
# bail out with error
return True
- parent1 = repo.dirstate.parents()[0]
- node = repo.changectx(parent1)
+ p1, p2 = args['parent1'], args['parent2']
+ node1 = repo.changelog.lookup(p1)
+ if p2:
+ node2 = repo.changelog.lookup(p2)
+ # next line for debugging only (check merges)
+ ui.warn('parent2: %s\n' % p2)
+ else:
+ node2 = None
(modified, added, removed, deleted,
- unknown, ignored, clean) = repo.status(node1=parent1)
-
+ unknown, ignored, clean) = repo.status(node1=node1, node2=node2)
candidates = modified + added + clean
- return kwexpander.expandkw(ui, repo, parent1, node, candidates)
+ return kwexpander.expandkw(ui, repo,
+ node1, p1, candidates, update=True)