# $Hg$importkwexpanderfrommercurialimportcmdutil,commandsimportsysdefpretxnkw(ui,repo,hooktype,**args):'''Important: returns False on success, True on failure.'''ifhooktype!='pretxncommit':# bail out with errorreturnTrue# reparse args, opts again as pretxncommit hook is silent about themsysargs,globalopts,cmdopts=commands.parse(ui,sys.argv[1:])[2:]files,match,anypats=cmdutil.matchpats(repo,sysargs,cmdopts)# validity checks should have been done alreadymodified,added=repo.status(files=files,match=match)[:2]candidates=modified+addedifcandidates:r=repo.changelog.tip()n=args['node'][:12]# TODO: check whether we need parent1&2 like in updatekwreturnkwexpander.expandkw(ui,repo,r,n,candidates,update=False)