Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/localrepo.py @ 2581:54b152379589
allow use of extensions in python hooks
extensions are loaded with hgext_ prefix, try to use them if
the module is not found in the normal path
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 09 Jul 2006 11:10:11 +0200 |
parents | cf4f0322851d |
children | 00fc88b0b256 |
comparison
equal
deleted
inserted
replaced
2580:a20a1bb0c396 | 2581:54b152379589 |
---|---|
99 % (hname, funcname)) | 99 % (hname, funcname)) |
100 modname = funcname[:d] | 100 modname = funcname[:d] |
101 try: | 101 try: |
102 obj = __import__(modname) | 102 obj = __import__(modname) |
103 except ImportError: | 103 except ImportError: |
104 raise util.Abort(_('%s hook is invalid ' | 104 try: |
105 '(import of "%s" failed)') % | 105 # extensions are loaded with hgext_ prefix |
106 (hname, modname)) | 106 obj = __import__("hgext_%s" % modname) |
107 except ImportError: | |
108 raise util.Abort(_('%s hook is invalid ' | |
109 '(import of "%s" failed)') % | |
110 (hname, modname)) | |
107 try: | 111 try: |
108 for p in funcname.split('.')[1:]: | 112 for p in funcname.split('.')[1:]: |
109 obj = getattr(obj, p) | 113 obj = getattr(obj, p) |
110 except AttributeError, err: | 114 except AttributeError, err: |
111 raise util.Abort(_('%s hook is invalid ' | 115 raise util.Abort(_('%s hook is invalid ' |