# HG changeset patch # User Christian Ebert # Date 1166359108 -3600 # Node ID bda0dec1aaf1565b76485dc704b68e3ab12c65aa # Parent aa3fbe81e9ad8c73a7122481c33f404aee931dac Reparse cmdline to avoid expansion in uncommitted files diff -r aa3fbe81e9ad -r bda0dec1aaf1 hgkw/pretxnkw.py --- a/hgkw/pretxnkw.py Sun Dec 17 10:57:55 2006 +0100 +++ b/hgkw/pretxnkw.py Sun Dec 17 13:38:28 2006 +0100 @@ -1,6 +1,8 @@ # $Hg$ import kwexpander +from mercurial import cmdutil, commands +import sys def pretxnkw(ui, repo, hooktype, **args): '''Important: returns False on success, True on failure.''' @@ -9,10 +11,18 @@ # bail out with error return True - tip = repo.changelog.tip() - modified, added = repo.status()[:2] + # reparse args, opts again as pretxncommit hook is silent about them + sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[2:] + files, match, anypats = cmdutil.matchpats(repo, sysargs, cmdopts) + + # validity checks should have been done already + modified, added = repo.status(files=files, match=match)[:2] candidates = modified + added - # TODO: check whether we need parent1&2 like in updatekw - return kwexpander.expandkw(ui, repo, - tip, args['node'][0:12], candidates, update=False) + if candidates: + r = repo.changelog.tip() + n = args['node'][:12] + # TODO: check whether we need parent1&2 like in updatekw + return kwexpander.expandkw(ui, repo, r, n, candidates, update=False) + + return False