Mercurial > public > mercurial-scm > hg
comparison mercurial/extensions.py @ 20645:7d83c3b6e8d9
extensions: use normpath to allow trailing '\' on Windows (issue4187)
Fixes same issue as 5c794e7331e7 but now works on Windows too.
With this patch a trailing backward slash won't prevent the extension from
being found on Windows, and we continue to support any combination of forward
and back slashes within the path.
author | Ed Morley <emorley@mozilla.com> |
---|---|
date | Wed, 05 Mar 2014 09:31:05 +0000 |
parents | 352abbb0be88 |
children | 54d7657d7d1e |
comparison
equal
deleted
inserted
replaced
20644:779ceb84f4f7 | 20645:7d83c3b6e8d9 |
---|---|
41 raise KeyError(name) | 41 raise KeyError(name) |
42 return mod | 42 return mod |
43 | 43 |
44 def loadpath(path, module_name): | 44 def loadpath(path, module_name): |
45 module_name = module_name.replace('.', '_') | 45 module_name = module_name.replace('.', '_') |
46 path = util.expandpath(path) | 46 path = util.normpath(util.expandpath(path)) |
47 if os.path.isdir(path): | 47 if os.path.isdir(path): |
48 # module/__init__.py style | 48 # module/__init__.py style |
49 d, f = os.path.split(path.rstrip('/')) | 49 d, f = os.path.split(path) |
50 fd, fpath, desc = imp.find_module(f, [d]) | 50 fd, fpath, desc = imp.find_module(f, [d]) |
51 return imp.load_module(module_name, fd, fpath, desc) | 51 return imp.load_module(module_name, fd, fpath, desc) |
52 else: | 52 else: |
53 try: | 53 try: |
54 return imp.load_source(module_name, path) | 54 return imp.load_source(module_name, path) |