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