Show More
@@ -38,6 +38,7 b' import os' | |||
|
38 | 38 | |
|
39 | 39 | from mercurial import ( |
|
40 | 40 | pycompat, |
|
41 | util, | |
|
41 | 42 | ) |
|
42 | 43 | from mercurial.utils import ( |
|
43 | 44 | procutil, |
@@ -49,17 +50,22 b' from mercurial.utils import (' | |||
|
49 | 50 | # leave the attribute unspecified. |
|
50 | 51 | testedwith = 'ships-with-hg-core' |
|
51 | 52 | |
|
52 | def uisetup(ui): | |
|
53 | ||
|
54 | class logtoprocessui(ui.__class__): | |
|
55 | def log(self, event, *msg, **opts): | |
|
53 | class processlogger(object): | |
|
56 | 54 |
|
|
57 | 55 | |
|
58 | 56 |
|
|
57 | """ | |
|
59 | 58 | |
|
60 | """ | |
|
61 |
|
|
|
62 | if script: | |
|
59 | def __init__(self, ui): | |
|
60 | self._scripts = dict(ui.configitems(b'logtoprocess')) | |
|
61 | ||
|
62 | def tracked(self, event): | |
|
63 | return bool(self._scripts.get(event)) | |
|
64 | ||
|
65 | def log(self, ui, event, msg, opts): | |
|
66 | script = self._scripts.get(event) | |
|
67 | if not script: | |
|
68 | return | |
|
63 | 69 |
|
|
64 | 70 |
|
|
65 | 71 |
|
@@ -70,6 +76,24 b' def uisetup(ui):' | |||
|
70 | 76 |
|
|
71 | 77 |
|
|
72 | 78 |
|
|
79 | ||
|
80 | def uisetup(ui): | |
|
81 | ||
|
82 | class logtoprocessui(ui.__class__): | |
|
83 | def __init__(self, src=None): | |
|
84 | super(logtoprocessui, self).__init__(src) | |
|
85 | if src and r'_ltplogger' in src.__dict__: | |
|
86 | self._ltplogger = src._ltplogger | |
|
87 | ||
|
88 | # trick to initialize logger after configuration is loaded, which | |
|
89 | # can be replaced later with processlogger(ui) in uisetup(), where | |
|
90 | # both user and repo configurations should be available. | |
|
91 | @util.propertycache | |
|
92 | def _ltplogger(self): | |
|
93 | return processlogger(self) | |
|
94 | ||
|
95 | def log(self, event, *msg, **opts): | |
|
96 | self._ltplogger.log(self, event, msg, opts) | |
|
73 | 97 | return super(logtoprocessui, self).log(event, *msg, **opts) |
|
74 | 98 | |
|
75 | 99 | # Replace the class for this instance and all clones created from it: |
General Comments 0
You need to be logged in to leave comments.
Login now