equal
deleted
inserted
replaced
71 '''return module with given extension name''' |
71 '''return module with given extension name''' |
72 mod = None |
72 mod = None |
73 try: |
73 try: |
74 mod = _extensions[name] |
74 mod = _extensions[name] |
75 except KeyError: |
75 except KeyError: |
76 for k, v in pycompat.iteritems(_extensions): |
76 for k, v in _extensions.items(): |
77 if k.endswith(b'.' + name) or k.endswith(b'/' + name): |
77 if k.endswith(b'.' + name) or k.endswith(b'/' + name): |
78 mod = v |
78 mod = v |
79 break |
79 break |
80 if not mod: |
80 if not mod: |
81 raise KeyError(name) |
81 raise KeyError(name) |
168 _cmdfuncattrs = (b'norepo', b'optionalrepo', b'inferrepo') |
168 _cmdfuncattrs = (b'norepo', b'optionalrepo', b'inferrepo') |
169 |
169 |
170 |
170 |
171 def _validatecmdtable(ui, cmdtable): |
171 def _validatecmdtable(ui, cmdtable): |
172 """Check if extension commands have required attributes""" |
172 """Check if extension commands have required attributes""" |
173 for c, e in pycompat.iteritems(cmdtable): |
173 for c, e in cmdtable.items(): |
174 f = e[0] |
174 f = e[0] |
175 missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)] |
175 missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)] |
176 if not missing: |
176 if not missing: |
177 continue |
177 continue |
178 raise error.ProgrammingError( |
178 raise error.ProgrammingError( |
576 extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks, |
576 extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks, |
577 synopsis, docstring) |
577 synopsis, docstring) |
578 ''' |
578 ''' |
579 assert callable(wrapper) |
579 assert callable(wrapper) |
580 aliases, entry = cmdutil.findcmd(command, table) |
580 aliases, entry = cmdutil.findcmd(command, table) |
581 for alias, e in pycompat.iteritems(table): |
581 for alias, e in table.items(): |
582 if e is entry: |
582 if e is entry: |
583 key = alias |
583 key = alias |
584 break |
584 break |
585 |
585 |
586 origfn = entry[0] |
586 origfn = entry[0] |
753 if not os.path.exists(path): |
753 if not os.path.exists(path): |
754 continue |
754 continue |
755 if name in exts or name in _order or name == b'__init__': |
755 if name in exts or name in _order or name == b'__init__': |
756 continue |
756 continue |
757 exts[name] = path |
757 exts[name] = path |
758 for name, path in pycompat.iteritems(_disabledextensions): |
758 for name, path in _disabledextensions.items(): |
759 # If no path was provided for a disabled extension (e.g. "color=!"), |
759 # If no path was provided for a disabled extension (e.g. "color=!"), |
760 # don't replace the path we already found by the scan above. |
760 # don't replace the path we already found by the scan above. |
761 if path: |
761 if path: |
762 exts[name] = path |
762 exts[name] = path |
763 return exts |
763 return exts |
815 try: |
815 try: |
816 from hgext import __index__ # pytype: disable=import-error |
816 from hgext import __index__ # pytype: disable=import-error |
817 |
817 |
818 return { |
818 return { |
819 name: gettext(desc) |
819 name: gettext(desc) |
820 for name, desc in pycompat.iteritems(__index__.docs) |
820 for name, desc in __index__.docs.items() |
821 if name not in _order |
821 if name not in _order |
822 } |
822 } |
823 except (ImportError, AttributeError): |
823 except (ImportError, AttributeError): |
824 pass |
824 pass |
825 |
825 |
826 paths = _disabledpaths() |
826 paths = _disabledpaths() |
827 if not paths: |
827 if not paths: |
828 return {} |
828 return {} |
829 |
829 |
830 exts = {} |
830 exts = {} |
831 for name, path in pycompat.iteritems(paths): |
831 for name, path in paths.items(): |
832 doc = _disabledhelp(path) |
832 doc = _disabledhelp(path) |
833 if doc and name != b'__index__': |
833 if doc and name != b'__index__': |
834 exts[name] = doc.splitlines()[0] |
834 exts[name] = doc.splitlines()[0] |
835 |
835 |
836 return exts |
836 return exts |
915 path = paths.pop(cmd, None) |
915 path = paths.pop(cmd, None) |
916 if path: |
916 if path: |
917 ext = _finddisabledcmd(ui, cmd, cmd, path, strict=strict) |
917 ext = _finddisabledcmd(ui, cmd, cmd, path, strict=strict) |
918 if not ext: |
918 if not ext: |
919 # otherwise, interrogate each extension until there's a match |
919 # otherwise, interrogate each extension until there's a match |
920 for name, path in pycompat.iteritems(paths): |
920 for name, path in paths.items(): |
921 ext = _finddisabledcmd(ui, cmd, name, path, strict=strict) |
921 ext = _finddisabledcmd(ui, cmd, name, path, strict=strict) |
922 if ext: |
922 if ext: |
923 break |
923 break |
924 if ext: |
924 if ext: |
925 return ext |
925 return ext |
940 return exts |
940 return exts |
941 |
941 |
942 |
942 |
943 def notloaded(): |
943 def notloaded(): |
944 '''return short names of extensions that failed to load''' |
944 '''return short names of extensions that failed to load''' |
945 return [ |
945 return [name for name, mod in _extensions.items() if mod is None] |
946 name for name, mod in pycompat.iteritems(_extensions) if mod is None |
|
947 ] |
|
948 |
946 |
949 |
947 |
950 def moduleversion(module): |
948 def moduleversion(module): |
951 '''return version information from given module as a string''' |
949 '''return version information from given module as a string''' |
952 if util.safehasattr(module, b'getversion') and callable(module.getversion): |
950 if util.safehasattr(module, b'getversion') and callable(module.getversion): |