##// END OF EJS Templates
Add support for extension modules...
mason@suse.com -
r1071:8f0ac653 default
parent child Browse files
Show More
@@ -6,7 +6,7 b''
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 8 from demandload import demandload
9 demandload(globals(), "os re sys signal shutil")
9 demandload(globals(), "os re sys signal shutil imp")
10 10 demandload(globals(), "fancyopts ui hg util lock")
11 11 demandload(globals(), "fnmatch hgweb mdiff random signal time traceback")
12 12 demandload(globals(), "errno socket version struct atexit sets")
@@ -1729,10 +1729,29 b' def dispatch(args):'
1729 1729 except AttributeError:
1730 1730 pass
1731 1731
1732 u = ui.ui()
1733 external = []
1734 for x in u.extensions():
1735 if x[1]:
1736 mod = imp.load_source(x[0], x[1])
1737 else:
1738 def importh(name):
1739 mod = __import__(name)
1740 components = name.split('.')
1741 for comp in components[1:]:
1742 mod = getattr(mod, comp)
1743 return mod
1744 mod = importh(x[0])
1745 external.append(mod)
1746 for x in external:
1747 for t in x.cmdtable:
1748 if t in table:
1749 u.warn("module %s override %s\n" % (x.__name__, t))
1750 table.update(x.cmdtable)
1751
1732 1752 try:
1733 1753 cmd, func, args, options, cmdoptions = parse(args)
1734 1754 except ParseError, inst:
1735 u = ui.ui()
1736 1755 if inst.args[0]:
1737 1756 u.warn("hg %s: %s\n" % (inst.args[0], inst.args[1]))
1738 1757 help_(u, inst.args[0])
@@ -1741,7 +1760,6 b' def dispatch(args):'
1741 1760 help_(u, 'shortlist')
1742 1761 sys.exit(-1)
1743 1762 except UnknownCommand, inst:
1744 u = ui.ui()
1745 1763 u.warn("hg: unknown command '%s'\n" % inst.args[0])
1746 1764 help_(u, 'shortlist')
1747 1765 sys.exit(1)
@@ -1755,12 +1773,11 b' def dispatch(args):'
1755 1773 s = get_times()
1756 1774 def print_time():
1757 1775 t = get_times()
1758 u = ui.ui()
1759 1776 u.warn("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n" %
1760 1777 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
1761 1778 atexit.register(print_time)
1762 1779
1763 u = ui.ui(options["verbose"], options["debug"], options["quiet"],
1780 u.updateopts(options["verbose"], options["debug"], options["quiet"],
1764 1781 not options["noninteractive"])
1765 1782
1766 1783 try:
@@ -1785,6 +1802,8 b' def dispatch(args):'
1785 1802 if cmd not in norepo.split():
1786 1803 path = options["repository"] or ""
1787 1804 repo = hg.repository(ui=u, path=path)
1805 for x in external:
1806 x.reposetup(u, repo)
1788 1807 d = lambda: func(u, repo, *args, **cmdoptions)
1789 1808 else:
1790 1809 d = lambda: func(u, *args, **cmdoptions)
@@ -22,6 +22,10 b' class ui:'
22 22 self.debugflag = self.configbool("ui", "debug")
23 23 self.interactive = self.configbool("ui", "interactive", True)
24 24
25 self.updateopts(verbose, debug, quiet, interactive)
26
27 def updateopts(self, verbose=False, debug=False, quiet=False,
28 interactive=True):
25 29 self.quiet = (self.quiet or quiet) and not verbose and not debug
26 30 self.verbose = (self.verbose or verbose) or debug
27 31 self.debugflag = (self.debugflag or debug)
@@ -63,6 +67,9 b' class ui:'
63 67 yield section, name, value.replace('\n', '\\n')
64 68 seen[section, name] = 1
65 69
70 def extensions(self):
71 return self.configitems("extensions")
72
66 73 def username(self):
67 74 return (os.environ.get("HGUSER") or
68 75 self.config("ui", "username") or
General Comments 0
You need to be logged in to leave comments. Login now