[PATCH] hook: try to load python hook starting from repo root if not found

Martin Geisler mg at aragost.com
Wed Dec 8 09:25:09 CST 2010

Alexander Solovyov <alexander at solovyov.net> writes:

> On Tue, Dec 7, 2010 at 21:25, Matt Mackall <mpm at selenic.com> wrote:
>>> -                    mod = extensions.loadpath(path, 'hghook.%s' % hname)
>>> +                    try:
>>> +                        mod = extensions.loadpath(path, 'hghook.%s' % hname)
>> Why does it ever make sense to load extensions relative to a random
>> current working directory?
> Well, because path can be absolute, maybe? Although that could be
> handled with a check, I can rework the patch.

This part will already handle both relative and absolute paths correctly:

+                        mod = extensions.loadpath(os.path.join(repo.root, path),
+                                                  'hghook.%s' % hname)

the trick is that os.path.join(repo.root, path) does the right thing if
path is an absolute path.

Martin Geisler

aragost Trifork
Professional Mercurial support

More information about the Mercurial-devel mailing list