Mercurial > hg
changeset 5869:2c565b9598b8
hooks: fix pre- and post- hooks specified in .hg/hgrc
We were looking up hooks in the wrong ui object. Also, we weren't
handling hooks to commands without a repo.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 18 Jan 2008 09:03:17 -0600 |
parents | 838fa52abcc1 |
children | 5692bed8230b |
files | mercurial/dispatch.py mercurial/hook.py |
diffstat | 2 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dispatch.py Fri Jan 18 08:23:29 2008 -0600 +++ b/mercurial/dispatch.py Fri Jan 18 09:03:17 2008 -0600 @@ -354,12 +354,12 @@ d = lambda: func(ui, *args, **cmdoptions) # run pre-hook, and abort if it fails - ret = hook.hook(ui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs)) + ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs)) if ret: return ret ret = _runcommand(ui, options, cmd, d) # run post-hook, passing command result - hook.hook(ui, repo, "post-%s" % cmd, False, args=" ".join(fullargs), + hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs), result = ret) return ret
--- a/mercurial/hook.py Fri Jan 18 08:23:29 2008 -0600 +++ b/mercurial/hook.py Fri Jan 18 09:03:17 2008 -0600 @@ -71,7 +71,11 @@ def _exthook(ui, repo, name, cmd, args, throw): ui.note(_("running hook %s: %s\n") % (name, cmd)) env = dict([('HG_' + k.upper(), v) for k, v in args.iteritems()]) - r = util.system(cmd, environ=env, cwd=repo.root) + if repo: + cwd = repo.root + else: + cwd = os.getcwd() + r = util.system(cmd, environ=env, cwd=cwd) if r: desc, r = util.explain_exit(r) if throw: