--- a/hgkw/keyword.py Thu Jan 11 02:22:56 2007 +0100
+++ b/hgkw/keyword.py Thu Jan 11 10:37:50 2007 +0100
@@ -130,15 +130,19 @@
filelog.filelog = kwfilelog
repo.__class__ = kwrepo
# make pretxncommit hook import kwmodule regardless of where it's located
- moddir = os.path.abspath(os.path.dirname(__file__))
- if os.path.dirname(moddir) in sys.path:
- moddir = os.path.split(moddir)[1]+'.'
+ for k, v in sys.modules.iteritems():
+ if v is None:
+ continue
+ if not hasattr(v, '__file__'):
+ continue
+ if v.__file__.startswith(__file__):
+ mod = k
+ break
else:
- sys.path.insert(0, moddir)
- moddir = ''
- ui.setconfig('hooks', 'pretxncommit.keyword', 'python:%s%s.pretxnkw'
- % (moddir, os.path.splitext(os.path.basename(__file__))[0]))
- del moddir
+ sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
+ mod = os.path.splitext(os.path.basename(__file__))[0]
+ ui.setconfig('hooks', 'pretxncommit.keyword', 'python:%s.pretxnkw' % mod)
+ del mod
def pretxnkw(ui, repo, hooktype, **args):