Implement $Hg$ scheme with update hook
The pivotal line for update hook is:
repo.dirstate.update(kwupdates, 'n')
This forces hg to consider the freshly written files as not modified.
Thanks to wfile(), this keeps executable bits etc.
Still needs more testing.
No need to check for basename/filename in keyword trigger.
update hook does not need re.
TODO:
Walk back in history, if last change of file didn't happen in 1
of the provided changesets (update/merge?)?
# $Hg$
import kwexpander
def updatekw(ui, repo, hooktype, **args):
'''Important: returns False on success, True on failure.'''
if hooktype != 'update':
# bail out with error
return True
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=node1, node2=node2)
candidates = modified + added + clean
return kwexpander.expandkw(ui, repo,
node1, p1, candidates, update=True)