Merge lp:~jelmer/bzr/more-lazy-hooks into lp:bzr
- more-lazy-hooks
- Merge into bzr.dev
Status: | Merged |
---|---|
Approved by: | Vincent Ladeuil |
Approved revision: | no longer in the source branch. |
Merged at revision: | 5748 |
Proposed branch: | lp:~jelmer/bzr/more-lazy-hooks |
Merge into: | lp:bzr |
Prerequisite: | lp:~jelmer/bzr/reset-lazy-hooks |
Diff against target: |
747 lines (+137/-160) 21 files modified
bzrlib/branch.py (+28/-28) bzrlib/bzrdir.py (+5/-5) bzrlib/commands.py (+10/-10) bzrlib/hooks.py (+4/-2) bzrlib/info.py (+3/-4) bzrlib/lock.py (+11/-11) bzrlib/merge.py (+3/-3) bzrlib/merge_directive.py (+3/-3) bzrlib/msgeditor.py (+4/-4) bzrlib/mutabletree.py (+5/-5) bzrlib/plugins/changelog_merge/__init__.py (+6/-17) bzrlib/plugins/launchpad/lp_propose.py (+6/-13) bzrlib/plugins/news_merge/__init__.py (+7/-16) bzrlib/smart/client.py (+3/-3) bzrlib/smart/server.py (+8/-8) bzrlib/status.py (+5/-5) bzrlib/tests/test_hooks.py (+15/-16) bzrlib/tests/test_selftest.py (+5/-5) bzrlib/tests/transport_util.py (+2/-1) bzrlib/version_info_formats/format_rio.py (+1/-1) doc/en/release-notes/bzr-2.4.txt (+3/-0) |
To merge this branch: | bzr merge lp:~jelmer/bzr/more-lazy-hooks |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil | Needs Fixing | ||
Review via email: mp+55523@code.launchpad.net |
Commit message
Support installing lazy hooks for all existing hook points, deprecate Hooks.create_hook.
Description of the change
Support installing lazy hooks for all existing hook points, like was already done for bzrlib.
Deprecate Hooks.create_hook, which doesn't work well together with lazy hooks.
Jelmer Vernooij (jelmer) wrote : | # |
On Thu, 2011-03-31 at 14:26 +0000, Vincent Ladeuil wrote:
> Review: Needs Fixing
> One test failure when run on babune:
> http://
>
> <<< bzrlib.
> Stack Trace
>
> _StringException: Text attachment: log
> ------------
> 1426.373 opening working tree '/private/
> ------------
> Text attachment: traceback
> ------------
> Traceback (most recent call last):
> File "/home/
> File "/home/
> File "/Users/
> hooks = _mod_branch.
> TypeError: __init__() takes exactly 1 argument (3 given)
> ------------
>
> Since the changes are pretty mechanical, it's probably shallow, so tweak.
Fixed, thanks for the review!
Cheers,
Jelmer
Jelmer Vernooij (jelmer) wrote : | # |
sent to pqm by email
Jelmer Vernooij (jelmer) wrote : | # |
sent to pqm by email
Preview Diff
1 | === modified file 'bzrlib/branch.py' | |||
2 | --- bzrlib/branch.py 2011-03-26 01:37:08 +0000 | |||
3 | +++ bzrlib/branch.py 2011-03-31 15:13:30 +0000 | |||
4 | @@ -57,7 +57,7 @@ | |||
5 | 57 | needs_write_lock, | 57 | needs_write_lock, |
6 | 58 | only_raises, | 58 | only_raises, |
7 | 59 | ) | 59 | ) |
9 | 60 | from bzrlib.hooks import HookPoint, Hooks | 60 | from bzrlib.hooks import Hooks |
10 | 61 | from bzrlib.inter import InterObject | 61 | from bzrlib.inter import InterObject |
11 | 62 | from bzrlib.lock import _RelockDebugMixin, LogicalLockResult | 62 | from bzrlib.lock import _RelockDebugMixin, LogicalLockResult |
12 | 63 | from bzrlib import registry | 63 | from bzrlib import registry |
13 | @@ -1808,25 +1808,25 @@ | |||
14 | 1808 | These are all empty initially, because by default nothing should get | 1808 | These are all empty initially, because by default nothing should get |
15 | 1809 | notified. | 1809 | notified. |
16 | 1810 | """ | 1810 | """ |
19 | 1811 | Hooks.__init__(self) | 1811 | Hooks.__init__(self, "bzrlib.branch", "Branch.hooks") |
20 | 1812 | self.create_hook(HookPoint('set_rh', | 1812 | self.add_hook('set_rh', |
21 | 1813 | "Invoked whenever the revision history has been set via " | 1813 | "Invoked whenever the revision history has been set via " |
22 | 1814 | "set_revision_history. The api signature is (branch, " | 1814 | "set_revision_history. The api signature is (branch, " |
23 | 1815 | "revision_history), and the branch will be write-locked. " | 1815 | "revision_history), and the branch will be write-locked. " |
24 | 1816 | "The set_rh hook can be expensive for bzr to trigger, a better " | 1816 | "The set_rh hook can be expensive for bzr to trigger, a better " |
27 | 1817 | "hook to use is Branch.post_change_branch_tip.", (0, 15), None)) | 1817 | "hook to use is Branch.post_change_branch_tip.", (0, 15)) |
28 | 1818 | self.create_hook(HookPoint('open', | 1818 | self.add_hook('open', |
29 | 1819 | "Called with the Branch object that has been opened after a " | 1819 | "Called with the Branch object that has been opened after a " |
32 | 1820 | "branch is opened.", (1, 8), None)) | 1820 | "branch is opened.", (1, 8)) |
33 | 1821 | self.create_hook(HookPoint('post_push', | 1821 | self.add_hook('post_push', |
34 | 1822 | "Called after a push operation completes. post_push is called " | 1822 | "Called after a push operation completes. post_push is called " |
35 | 1823 | "with a bzrlib.branch.BranchPushResult object and only runs in the " | 1823 | "with a bzrlib.branch.BranchPushResult object and only runs in the " |
38 | 1824 | "bzr client.", (0, 15), None)) | 1824 | "bzr client.", (0, 15)) |
39 | 1825 | self.create_hook(HookPoint('post_pull', | 1825 | self.add_hook('post_pull', |
40 | 1826 | "Called after a pull operation completes. post_pull is called " | 1826 | "Called after a pull operation completes. post_pull is called " |
41 | 1827 | "with a bzrlib.branch.PullResult object and only runs in the " | 1827 | "with a bzrlib.branch.PullResult object and only runs in the " |
44 | 1828 | "bzr client.", (0, 15), None)) | 1828 | "bzr client.", (0, 15)) |
45 | 1829 | self.create_hook(HookPoint('pre_commit', | 1829 | self.add_hook('pre_commit', |
46 | 1830 | "Called after a commit is calculated but before it is " | 1830 | "Called after a commit is calculated but before it is " |
47 | 1831 | "completed. pre_commit is called with (local, master, old_revno, " | 1831 | "completed. pre_commit is called with (local, master, old_revno, " |
48 | 1832 | "old_revid, future_revno, future_revid, tree_delta, future_tree" | 1832 | "old_revid, future_revno, future_revid, tree_delta, future_tree" |
49 | @@ -1835,29 +1835,29 @@ | |||
50 | 1835 | "basis revision. hooks MUST NOT modify this delta. " | 1835 | "basis revision. hooks MUST NOT modify this delta. " |
51 | 1836 | " future_tree is an in-memory tree obtained from " | 1836 | " future_tree is an in-memory tree obtained from " |
52 | 1837 | "CommitBuilder.revision_tree() and hooks MUST NOT modify this " | 1837 | "CommitBuilder.revision_tree() and hooks MUST NOT modify this " |
55 | 1838 | "tree.", (0,91), None)) | 1838 | "tree.", (0,91)) |
56 | 1839 | self.create_hook(HookPoint('post_commit', | 1839 | self.add_hook('post_commit', |
57 | 1840 | "Called in the bzr client after a commit has completed. " | 1840 | "Called in the bzr client after a commit has completed. " |
58 | 1841 | "post_commit is called with (local, master, old_revno, old_revid, " | 1841 | "post_commit is called with (local, master, old_revno, old_revid, " |
59 | 1842 | "new_revno, new_revid). old_revid is NULL_REVISION for the first " | 1842 | "new_revno, new_revid). old_revid is NULL_REVISION for the first " |
62 | 1843 | "commit to a branch.", (0, 15), None)) | 1843 | "commit to a branch.", (0, 15)) |
63 | 1844 | self.create_hook(HookPoint('post_uncommit', | 1844 | self.add_hook('post_uncommit', |
64 | 1845 | "Called in the bzr client after an uncommit completes. " | 1845 | "Called in the bzr client after an uncommit completes. " |
65 | 1846 | "post_uncommit is called with (local, master, old_revno, " | 1846 | "post_uncommit is called with (local, master, old_revno, " |
66 | 1847 | "old_revid, new_revno, new_revid) where local is the local branch " | 1847 | "old_revid, new_revno, new_revid) where local is the local branch " |
67 | 1848 | "or None, master is the target branch, and an empty branch " | 1848 | "or None, master is the target branch, and an empty branch " |
70 | 1849 | "receives new_revno of 0, new_revid of None.", (0, 15), None)) | 1849 | "receives new_revno of 0, new_revid of None.", (0, 15)) |
71 | 1850 | self.create_hook(HookPoint('pre_change_branch_tip', | 1850 | self.add_hook('pre_change_branch_tip', |
72 | 1851 | "Called in bzr client and server before a change to the tip of a " | 1851 | "Called in bzr client and server before a change to the tip of a " |
73 | 1852 | "branch is made. pre_change_branch_tip is called with a " | 1852 | "branch is made. pre_change_branch_tip is called with a " |
74 | 1853 | "bzrlib.branch.ChangeBranchTipParams. Note that push, pull, " | 1853 | "bzrlib.branch.ChangeBranchTipParams. Note that push, pull, " |
77 | 1854 | "commit, uncommit will all trigger this hook.", (1, 6), None)) | 1854 | "commit, uncommit will all trigger this hook.", (1, 6)) |
78 | 1855 | self.create_hook(HookPoint('post_change_branch_tip', | 1855 | self.add_hook('post_change_branch_tip', |
79 | 1856 | "Called in bzr client and server after a change to the tip of a " | 1856 | "Called in bzr client and server after a change to the tip of a " |
80 | 1857 | "branch is made. post_change_branch_tip is called with a " | 1857 | "branch is made. post_change_branch_tip is called with a " |
81 | 1858 | "bzrlib.branch.ChangeBranchTipParams. Note that push, pull, " | 1858 | "bzrlib.branch.ChangeBranchTipParams. Note that push, pull, " |
84 | 1859 | "commit, uncommit will all trigger this hook.", (1, 4), None)) | 1859 | "commit, uncommit will all trigger this hook.", (1, 4)) |
85 | 1860 | self.create_hook(HookPoint('transform_fallback_location', | 1860 | self.add_hook('transform_fallback_location', |
86 | 1861 | "Called when a stacked branch is activating its fallback " | 1861 | "Called when a stacked branch is activating its fallback " |
87 | 1862 | "locations. transform_fallback_location is called with (branch, " | 1862 | "locations. transform_fallback_location is called with (branch, " |
88 | 1863 | "url), and should return a new url. Returning the same url " | 1863 | "url), and should return a new url. Returning the same url " |
89 | @@ -1868,23 +1868,23 @@ | |||
90 | 1868 | "fallback locations have not been activated. When there are " | 1868 | "fallback locations have not been activated. When there are " |
91 | 1869 | "multiple hooks installed for transform_fallback_location, " | 1869 | "multiple hooks installed for transform_fallback_location, " |
92 | 1870 | "all are called with the url returned from the previous hook." | 1870 | "all are called with the url returned from the previous hook." |
95 | 1871 | "The order is however undefined.", (1, 9), None)) | 1871 | "The order is however undefined.", (1, 9)) |
96 | 1872 | self.create_hook(HookPoint('automatic_tag_name', | 1872 | self.add_hook('automatic_tag_name', |
97 | 1873 | "Called to determine an automatic tag name for a revision. " | 1873 | "Called to determine an automatic tag name for a revision. " |
98 | 1874 | "automatic_tag_name is called with (branch, revision_id) and " | 1874 | "automatic_tag_name is called with (branch, revision_id) and " |
99 | 1875 | "should return a tag name or None if no tag name could be " | 1875 | "should return a tag name or None if no tag name could be " |
100 | 1876 | "determined. The first non-None tag name returned will be used.", | 1876 | "determined. The first non-None tag name returned will be used.", |
103 | 1877 | (2, 2), None)) | 1877 | (2, 2)) |
104 | 1878 | self.create_hook(HookPoint('post_branch_init', | 1878 | self.add_hook('post_branch_init', |
105 | 1879 | "Called after new branch initialization completes. " | 1879 | "Called after new branch initialization completes. " |
106 | 1880 | "post_branch_init is called with a " | 1880 | "post_branch_init is called with a " |
107 | 1881 | "bzrlib.branch.BranchInitHookParams. " | 1881 | "bzrlib.branch.BranchInitHookParams. " |
108 | 1882 | "Note that init, branch and checkout (both heavyweight and " | 1882 | "Note that init, branch and checkout (both heavyweight and " |
111 | 1883 | "lightweight) will all trigger this hook.", (2, 2), None)) | 1883 | "lightweight) will all trigger this hook.", (2, 2)) |
112 | 1884 | self.create_hook(HookPoint('post_switch', | 1884 | self.add_hook('post_switch', |
113 | 1885 | "Called after a checkout switches branch. " | 1885 | "Called after a checkout switches branch. " |
114 | 1886 | "post_switch is called with a " | 1886 | "post_switch is called with a " |
116 | 1887 | "bzrlib.branch.SwitchHookParams.", (2, 2), None)) | 1887 | "bzrlib.branch.SwitchHookParams.", (2, 2)) |
117 | 1888 | 1888 | ||
118 | 1889 | 1889 | ||
119 | 1890 | 1890 | ||
120 | 1891 | 1891 | ||
121 | === modified file 'bzrlib/bzrdir.py' | |||
122 | --- bzrlib/bzrdir.py 2011-03-24 01:23:35 +0000 | |||
123 | +++ bzrlib/bzrdir.py 2011-03-31 15:13:30 +0000 | |||
124 | @@ -1082,15 +1082,15 @@ | |||
125 | 1082 | 1082 | ||
126 | 1083 | def __init__(self): | 1083 | def __init__(self): |
127 | 1084 | """Create the default hooks.""" | 1084 | """Create the default hooks.""" |
130 | 1085 | hooks.Hooks.__init__(self) | 1085 | hooks.Hooks.__init__(self, "bzrlib.bzrdir", "BzrDir.hooks") |
131 | 1086 | self.create_hook(hooks.HookPoint('pre_open', | 1086 | self.add_hook('pre_open', |
132 | 1087 | "Invoked before attempting to open a BzrDir with the transport " | 1087 | "Invoked before attempting to open a BzrDir with the transport " |
135 | 1088 | "that the open will use.", (1, 14), None)) | 1088 | "that the open will use.", (1, 14)) |
136 | 1089 | self.create_hook(hooks.HookPoint('post_repo_init', | 1089 | self.add_hook('post_repo_init', |
137 | 1090 | "Invoked after a repository has been initialized. " | 1090 | "Invoked after a repository has been initialized. " |
138 | 1091 | "post_repo_init is called with a " | 1091 | "post_repo_init is called with a " |
139 | 1092 | "bzrlib.bzrdir.RepoInitHookParams.", | 1092 | "bzrlib.bzrdir.RepoInitHookParams.", |
141 | 1093 | (2, 2), None)) | 1093 | (2, 2)) |
142 | 1094 | 1094 | ||
143 | 1095 | # install the default hooks | 1095 | # install the default hooks |
144 | 1096 | BzrDir.hooks = BzrDirHooks() | 1096 | BzrDir.hooks = BzrDirHooks() |
145 | 1097 | 1097 | ||
146 | === modified file 'bzrlib/commands.py' | |||
147 | --- bzrlib/commands.py 2011-02-04 22:25:59 +0000 | |||
148 | +++ bzrlib/commands.py 2011-03-31 15:13:30 +0000 | |||
149 | @@ -46,7 +46,7 @@ | |||
150 | 46 | ) | 46 | ) |
151 | 47 | """) | 47 | """) |
152 | 48 | 48 | ||
154 | 49 | from bzrlib.hooks import HookPoint, Hooks | 49 | from bzrlib.hooks import Hooks |
155 | 50 | # Compatibility - Option used to be in commands. | 50 | # Compatibility - Option used to be in commands. |
156 | 51 | from bzrlib.option import Option | 51 | from bzrlib.option import Option |
157 | 52 | from bzrlib.plugin import disable_plugins, load_plugins | 52 | from bzrlib.plugin import disable_plugins, load_plugins |
158 | @@ -775,30 +775,30 @@ | |||
159 | 775 | These are all empty initially, because by default nothing should get | 775 | These are all empty initially, because by default nothing should get |
160 | 776 | notified. | 776 | notified. |
161 | 777 | """ | 777 | """ |
164 | 778 | Hooks.__init__(self) | 778 | Hooks.__init__(self, "bzrlib.commands", "Command.hooks") |
165 | 779 | self.create_hook(HookPoint('extend_command', | 779 | self.add_hook('extend_command', |
166 | 780 | "Called after creating a command object to allow modifications " | 780 | "Called after creating a command object to allow modifications " |
167 | 781 | "such as adding or removing options, docs etc. Called with the " | 781 | "such as adding or removing options, docs etc. Called with the " |
170 | 782 | "new bzrlib.commands.Command object.", (1, 13), None)) | 782 | "new bzrlib.commands.Command object.", (1, 13)) |
171 | 783 | self.create_hook(HookPoint('get_command', | 783 | self.add_hook('get_command', |
172 | 784 | "Called when creating a single command. Called with " | 784 | "Called when creating a single command. Called with " |
173 | 785 | "(cmd_or_None, command_name). get_command should either return " | 785 | "(cmd_or_None, command_name). get_command should either return " |
174 | 786 | "the cmd_or_None parameter, or a replacement Command object that " | 786 | "the cmd_or_None parameter, or a replacement Command object that " |
175 | 787 | "should be used for the command. Note that the Command.hooks " | 787 | "should be used for the command. Note that the Command.hooks " |
176 | 788 | "hooks are core infrastructure. Many users will prefer to use " | 788 | "hooks are core infrastructure. Many users will prefer to use " |
177 | 789 | "bzrlib.commands.register_command or plugin_cmds.register_lazy.", | 789 | "bzrlib.commands.register_command or plugin_cmds.register_lazy.", |
180 | 790 | (1, 17), None)) | 790 | (1, 17)) |
181 | 791 | self.create_hook(HookPoint('get_missing_command', | 791 | self.add_hook('get_missing_command', |
182 | 792 | "Called when creating a single command if no command could be " | 792 | "Called when creating a single command if no command could be " |
183 | 793 | "found. Called with (command_name). get_missing_command should " | 793 | "found. Called with (command_name). get_missing_command should " |
184 | 794 | "either return None, or a Command object to be used for the " | 794 | "either return None, or a Command object to be used for the " |
187 | 795 | "command.", (1, 17), None)) | 795 | "command.", (1, 17)) |
188 | 796 | self.create_hook(HookPoint('list_commands', | 796 | self.add_hook('list_commands', |
189 | 797 | "Called when enumerating commands. Called with a set of " | 797 | "Called when enumerating commands. Called with a set of " |
190 | 798 | "cmd_name strings for all the commands found so far. This set " | 798 | "cmd_name strings for all the commands found so far. This set " |
191 | 799 | " is safe to mutate - e.g. to remove a command. " | 799 | " is safe to mutate - e.g. to remove a command. " |
192 | 800 | "list_commands should return the updated set of command names.", | 800 | "list_commands should return the updated set of command names.", |
194 | 801 | (1, 17), None)) | 801 | (1, 17)) |
195 | 802 | 802 | ||
196 | 803 | Command.hooks = CommandHooks() | 803 | Command.hooks = CommandHooks() |
197 | 804 | 804 | ||
198 | 805 | 805 | ||
199 | === modified file 'bzrlib/hooks.py' | |||
200 | --- bzrlib/hooks.py 2011-02-18 17:44:53 +0000 | |||
201 | +++ bzrlib/hooks.py 2011-03-31 15:13:30 +0000 | |||
202 | @@ -145,10 +145,10 @@ | |||
203 | 145 | else: | 145 | else: |
204 | 146 | callbacks = None | 146 | callbacks = None |
205 | 147 | hookpoint = HookPoint(name=name, doc=doc, introduced=introduced, | 147 | hookpoint = HookPoint(name=name, doc=doc, introduced=introduced, |
208 | 148 | deprecated=deprecated, | 148 | deprecated=deprecated, callbacks=callbacks) |
207 | 149 | callbacks=callbacks) | ||
209 | 150 | self[name] = hookpoint | 149 | self[name] = hookpoint |
210 | 151 | 150 | ||
211 | 151 | @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4))) | ||
212 | 152 | def create_hook(self, hook): | 152 | def create_hook(self, hook): |
213 | 153 | """Create a hook which can have callbacks registered for it. | 153 | """Create a hook which can have callbacks registered for it. |
214 | 154 | 154 | ||
215 | @@ -392,6 +392,8 @@ | |||
216 | 392 | return '\n'.join(segments) | 392 | return '\n'.join(segments) |
217 | 393 | 393 | ||
218 | 394 | 394 | ||
219 | 395 | # Lazily registered hooks. Maps (module, name, hook_name) tuples | ||
220 | 396 | # to lists of tuples with objectgetters and names | ||
221 | 395 | _lazy_hooks = {} | 397 | _lazy_hooks = {} |
222 | 396 | 398 | ||
223 | 397 | 399 | ||
224 | 398 | 400 | ||
225 | === modified file 'bzrlib/info.py' | |||
226 | --- bzrlib/info.py 2010-04-30 11:35:43 +0000 | |||
227 | +++ bzrlib/info.py 2011-03-31 15:13:30 +0000 | |||
228 | @@ -481,12 +481,11 @@ | |||
229 | 481 | """Hooks for the info command.""" | 481 | """Hooks for the info command.""" |
230 | 482 | 482 | ||
231 | 483 | def __init__(self): | 483 | def __init__(self): |
234 | 484 | super(InfoHooks, self).__init__() | 484 | super(InfoHooks, self).__init__("bzrlib.info", "hooks") |
235 | 485 | self.create_hook(_mod_hooks.HookPoint('repository', | 485 | self.add_hook('repository', |
236 | 486 | "Invoked when displaying the statistics for a repository. " | 486 | "Invoked when displaying the statistics for a repository. " |
237 | 487 | "repository is called with a statistics dictionary as returned " | 487 | "repository is called with a statistics dictionary as returned " |
240 | 488 | "by the repository and a file-like object to write to.", (1, 15), | 488 | "by the repository and a file-like object to write to.", (1, 15)) |
239 | 489 | None)) | ||
241 | 490 | 489 | ||
242 | 491 | 490 | ||
243 | 492 | hooks = InfoHooks() | 491 | hooks = InfoHooks() |
244 | 493 | 492 | ||
245 | === modified file 'bzrlib/lock.py' | |||
246 | --- bzrlib/lock.py 2010-05-11 08:36:16 +0000 | |||
247 | +++ bzrlib/lock.py 2011-03-31 15:13:30 +0000 | |||
248 | @@ -45,22 +45,22 @@ | |||
249 | 45 | osutils, | 45 | osutils, |
250 | 46 | trace, | 46 | trace, |
251 | 47 | ) | 47 | ) |
253 | 48 | from bzrlib.hooks import HookPoint, Hooks | 48 | from bzrlib.hooks import Hooks |
254 | 49 | 49 | ||
255 | 50 | 50 | ||
256 | 51 | class LockHooks(Hooks): | 51 | class LockHooks(Hooks): |
257 | 52 | 52 | ||
258 | 53 | def __init__(self): | 53 | def __init__(self): |
269 | 54 | Hooks.__init__(self) | 54 | Hooks.__init__(self, "bzrlib.lock", "Lock.hooks") |
270 | 55 | self.create_hook(HookPoint('lock_acquired', | 55 | self.add_hook('lock_acquired', |
271 | 56 | "Called with a bzrlib.lock.LockResult when a physical lock is " | 56 | "Called with a bzrlib.lock.LockResult when a physical lock is " |
272 | 57 | "acquired.", (1, 8), None)) | 57 | "acquired.", (1, 8)) |
273 | 58 | self.create_hook(HookPoint('lock_released', | 58 | self.add_hook('lock_released', |
274 | 59 | "Called with a bzrlib.lock.LockResult when a physical lock is " | 59 | "Called with a bzrlib.lock.LockResult when a physical lock is " |
275 | 60 | "released.", (1, 8), None)) | 60 | "released.", (1, 8)) |
276 | 61 | self.create_hook(HookPoint('lock_broken', | 61 | self.add_hook('lock_broken', |
277 | 62 | "Called with a bzrlib.lock.LockResult when a physical lock is " | 62 | "Called with a bzrlib.lock.LockResult when a physical lock is " |
278 | 63 | "broken.", (1, 15), None)) | 63 | "broken.", (1, 15)) |
279 | 64 | 64 | ||
280 | 65 | 65 | ||
281 | 66 | class Lock(object): | 66 | class Lock(object): |
282 | 67 | 67 | ||
283 | === modified file 'bzrlib/merge.py' | |||
284 | --- bzrlib/merge.py 2011-02-07 04:14:29 +0000 | |||
285 | +++ bzrlib/merge.py 2011-03-31 15:13:30 +0000 | |||
286 | @@ -62,8 +62,8 @@ | |||
287 | 62 | class MergeHooks(hooks.Hooks): | 62 | class MergeHooks(hooks.Hooks): |
288 | 63 | 63 | ||
289 | 64 | def __init__(self): | 64 | def __init__(self): |
292 | 65 | hooks.Hooks.__init__(self) | 65 | hooks.Hooks.__init__(self, "bzrlib.merge", "Merger.hooks") |
293 | 66 | self.create_hook(hooks.HookPoint('merge_file_content', | 66 | self.add_hook('merge_file_content', |
294 | 67 | "Called with a bzrlib.merge.Merger object to create a per file " | 67 | "Called with a bzrlib.merge.Merger object to create a per file " |
295 | 68 | "merge object when starting a merge. " | 68 | "merge object when starting a merge. " |
296 | 69 | "Should return either None or a subclass of " | 69 | "Should return either None or a subclass of " |
297 | @@ -73,7 +73,7 @@ | |||
298 | 73 | "side has deleted the file and the other has changed it). " | 73 | "side has deleted the file and the other has changed it). " |
299 | 74 | "See the AbstractPerFileMerger API docs for details on how it is " | 74 | "See the AbstractPerFileMerger API docs for details on how it is " |
300 | 75 | "used by merge.", | 75 | "used by merge.", |
302 | 76 | (2, 1), None)) | 76 | (2, 1)) |
303 | 77 | 77 | ||
304 | 78 | 78 | ||
305 | 79 | class AbstractPerFileMerger(object): | 79 | class AbstractPerFileMerger(object): |
306 | 80 | 80 | ||
307 | === modified file 'bzrlib/merge_directive.py' | |||
308 | --- bzrlib/merge_directive.py 2011-02-19 21:00:05 +0000 | |||
309 | +++ bzrlib/merge_directive.py 2011-03-31 15:13:30 +0000 | |||
310 | @@ -59,12 +59,12 @@ | |||
311 | 59 | """Hooks for MergeDirective classes.""" | 59 | """Hooks for MergeDirective classes.""" |
312 | 60 | 60 | ||
313 | 61 | def __init__(self): | 61 | def __init__(self): |
316 | 62 | hooks.Hooks.__init__(self) | 62 | hooks.Hooks.__init__(self, "bzrlib.merge_directive", "BaseMergeDirective.hooks") |
317 | 63 | self.create_hook(hooks.HookPoint('merge_request_body', | 63 | self.add_hook('merge_request_body', |
318 | 64 | "Called with a MergeRequestBodyParams when a body is needed for" | 64 | "Called with a MergeRequestBodyParams when a body is needed for" |
319 | 65 | " a merge request. Callbacks must return a body. If more" | 65 | " a merge request. Callbacks must return a body. If more" |
320 | 66 | " than one callback is registered, the output of one callback is" | 66 | " than one callback is registered, the output of one callback is" |
322 | 67 | " provided to the next.", (1, 15, 0), False)) | 67 | " provided to the next.", (1, 15, 0)) |
323 | 68 | 68 | ||
324 | 69 | 69 | ||
325 | 70 | class BaseMergeDirective(object): | 70 | class BaseMergeDirective(object): |
326 | 71 | 71 | ||
327 | === modified file 'bzrlib/msgeditor.py' | |||
328 | --- bzrlib/msgeditor.py 2011-02-07 01:30:38 +0000 | |||
329 | +++ bzrlib/msgeditor.py 2011-03-31 15:13:30 +0000 | |||
330 | @@ -31,7 +31,7 @@ | |||
331 | 31 | ui, | 31 | ui, |
332 | 32 | ) | 32 | ) |
333 | 33 | from bzrlib.errors import BzrError, BadCommitMessageEncoding | 33 | from bzrlib.errors import BzrError, BadCommitMessageEncoding |
335 | 34 | from bzrlib.hooks import HookPoint, Hooks | 34 | from bzrlib.hooks import Hooks |
336 | 35 | 35 | ||
337 | 36 | 36 | ||
338 | 37 | def _get_editor(): | 37 | def _get_editor(): |
339 | @@ -302,8 +302,8 @@ | |||
340 | 302 | 302 | ||
341 | 303 | These are all empty initially. | 303 | These are all empty initially. |
342 | 304 | """ | 304 | """ |
345 | 305 | Hooks.__init__(self) | 305 | Hooks.__init__(self, "bzrlib.msgeditor", "hooks") |
346 | 306 | self.create_hook(HookPoint('commit_message_template', | 306 | self.add_hook('commit_message_template', |
347 | 307 | "Called when a commit message is being generated. " | 307 | "Called when a commit message is being generated. " |
348 | 308 | "commit_message_template is called with the bzrlib.commit.Commit " | 308 | "commit_message_template is called with the bzrlib.commit.Commit " |
349 | 309 | "object and the message that is known so far. " | 309 | "object and the message that is known so far. " |
350 | @@ -311,7 +311,7 @@ | |||
351 | 311 | "could be the same as it was given. When there are multiple " | 311 | "could be the same as it was given. When there are multiple " |
352 | 312 | "hooks registered for commit_message_template, they are chained " | 312 | "hooks registered for commit_message_template, they are chained " |
353 | 313 | "with the result from the first passed into the second, and so " | 313 | "with the result from the first passed into the second, and so " |
355 | 314 | "on.", (1, 10), None)) | 314 | "on.", (1, 10)) |
356 | 315 | 315 | ||
357 | 316 | 316 | ||
358 | 317 | hooks = MessageEditorHooks() | 317 | hooks = MessageEditorHooks() |
359 | 318 | 318 | ||
360 | === modified file 'bzrlib/mutabletree.py' | |||
361 | --- bzrlib/mutabletree.py 2011-03-06 18:10:47 +0000 | |||
362 | +++ bzrlib/mutabletree.py 2011-03-31 15:13:30 +0000 | |||
363 | @@ -652,17 +652,17 @@ | |||
364 | 652 | """Create the default hooks. | 652 | """Create the default hooks. |
365 | 653 | 653 | ||
366 | 654 | """ | 654 | """ |
369 | 655 | hooks.Hooks.__init__(self) | 655 | hooks.Hooks.__init__(self, "bzrlib.mutabletree", "MutableTree.hooks") |
370 | 656 | self.create_hook(hooks.HookPoint('start_commit', | 656 | self.add_hook('start_commit', |
371 | 657 | "Called before a commit is performed on a tree. The start commit " | 657 | "Called before a commit is performed on a tree. The start commit " |
372 | 658 | "hook is able to change the tree before the commit takes place. " | 658 | "hook is able to change the tree before the commit takes place. " |
373 | 659 | "start_commit is called with the bzrlib.mutabletree.MutableTree " | 659 | "start_commit is called with the bzrlib.mutabletree.MutableTree " |
376 | 660 | "that the commit is being performed on.", (1, 4), None)) | 660 | "that the commit is being performed on.", (1, 4)) |
377 | 661 | self.create_hook(hooks.HookPoint('post_commit', | 661 | self.add_hook('post_commit', |
378 | 662 | "Called after a commit is performed on a tree. The hook is " | 662 | "Called after a commit is performed on a tree. The hook is " |
379 | 663 | "called with a bzrlib.mutabletree.PostCommitHookParams object. " | 663 | "called with a bzrlib.mutabletree.PostCommitHookParams object. " |
380 | 664 | "The mutable tree the commit was performed on is available via " | 664 | "The mutable tree the commit was performed on is available via " |
382 | 665 | "the mutable_tree attribute of that object.", (2, 0), None)) | 665 | "the mutable_tree attribute of that object.", (2, 0)) |
383 | 666 | 666 | ||
384 | 667 | 667 | ||
385 | 668 | # install the default hooks into the MutableTree class. | 668 | # install the default hooks into the MutableTree class. |
386 | 669 | 669 | ||
387 | === modified file 'bzrlib/plugins/changelog_merge/__init__.py' | |||
388 | --- bzrlib/plugins/changelog_merge/__init__.py 2011-03-15 07:56:42 +0000 | |||
389 | +++ bzrlib/plugins/changelog_merge/__init__.py 2011-03-31 15:13:30 +0000 | |||
390 | @@ -55,27 +55,17 @@ | |||
391 | 55 | 55 | ||
392 | 56 | # Since we are a built-in plugin we share the bzrlib version | 56 | # Since we are a built-in plugin we share the bzrlib version |
393 | 57 | from bzrlib import version_info | 57 | from bzrlib import version_info |
394 | 58 | from bzrlib.hooks import install_lazy_named_hook | ||
395 | 58 | 59 | ||
396 | 59 | # Put most of the code in a separate module that we lazy-import to keep the | 60 | # Put most of the code in a separate module that we lazy-import to keep the |
397 | 60 | # overhead of this plugin as minimal as possible. | 61 | # overhead of this plugin as minimal as possible. |
398 | 61 | from bzrlib.lazy_import import lazy_import | ||
399 | 62 | lazy_import(globals(), """ | ||
400 | 63 | from bzrlib.plugins.changelog_merge import changelog_merge as _mod_changelog_merge | ||
401 | 64 | """) | ||
402 | 65 | |||
403 | 66 | from bzrlib.merge import Merger | ||
404 | 67 | |||
405 | 68 | |||
406 | 69 | def changelog_merge_hook(merger): | 62 | def changelog_merge_hook(merger): |
407 | 70 | """Merger.merge_file_content hook for GNU-format ChangeLog files.""" | 63 | """Merger.merge_file_content hook for GNU-format ChangeLog files.""" |
416 | 71 | return _mod_changelog_merge.ChangeLogMerger(merger) | 64 | from bzrlib.plugins.changelog_merge.changelog_merge import ChangeLogMerger |
417 | 72 | 65 | return ChangeLogMerger(merger) | |
418 | 73 | 66 | ||
419 | 74 | def install_hook(): | 67 | install_lazy_named_hook("bzrlib.merge", "Merger.hooks", "merge_file_content", |
420 | 75 | Merger.hooks.install_named_hook( | 68 | changelog_merge_hook, 'GNU ChangeLog file merge') |
413 | 76 | 'merge_file_content', changelog_merge_hook, 'GNU ChangeLog file merge') | ||
414 | 77 | install_hook() | ||
415 | 78 | |||
421 | 79 | 69 | ||
422 | 80 | def load_tests(basic_tests, module, loader): | 70 | def load_tests(basic_tests, module, loader): |
423 | 81 | testmod_names = [ | 71 | testmod_names = [ |
424 | @@ -84,4 +74,3 @@ | |||
425 | 84 | basic_tests.addTest(loader.loadTestsFromModuleNames( | 74 | basic_tests.addTest(loader.loadTestsFromModuleNames( |
426 | 85 | ["%s.%s" % (__name__, tmn) for tmn in testmod_names])) | 75 | ["%s.%s" % (__name__, tmn) for tmn in testmod_names])) |
427 | 86 | return basic_tests | 76 | return basic_tests |
428 | 87 | |||
429 | 88 | 77 | ||
430 | === modified file 'bzrlib/plugins/launchpad/lp_propose.py' | |||
431 | --- bzrlib/plugins/launchpad/lp_propose.py 2011-01-19 16:57:38 +0000 | |||
432 | +++ bzrlib/plugins/launchpad/lp_propose.py 2011-03-31 15:13:30 +0000 | |||
433 | @@ -36,19 +36,12 @@ | |||
434 | 36 | """Hooks for proposing a merge on Launchpad.""" | 36 | """Hooks for proposing a merge on Launchpad.""" |
435 | 37 | 37 | ||
436 | 38 | def __init__(self): | 38 | def __init__(self): |
450 | 39 | hooks.Hooks.__init__(self) | 39 | hooks.Hooks.__init__(self, "bzrlib.plugins.launchpad.lp_propose", |
451 | 40 | self.create_hook( | 40 | "Proposer.hooks") |
452 | 41 | hooks.HookPoint( | 41 | self.add_hook('get_prerequisite', |
453 | 42 | 'get_prerequisite', | 42 | "Return the prerequisite branch for proposing as merge.", (2, 1)) |
454 | 43 | "Return the prerequisite branch for proposing as merge.", | 43 | self.add_hook('merge_proposal_body', |
455 | 44 | (2, 1), None), | 44 | "Return an initial body for the merge proposal message.", (2, 1)) |
443 | 45 | ) | ||
444 | 46 | self.create_hook( | ||
445 | 47 | hooks.HookPoint( | ||
446 | 48 | 'merge_proposal_body', | ||
447 | 49 | "Return an initial body for the merge proposal message.", | ||
448 | 50 | (2, 1), None), | ||
449 | 51 | ) | ||
456 | 52 | 45 | ||
457 | 53 | 46 | ||
458 | 54 | class Proposer(object): | 47 | class Proposer(object): |
459 | 55 | 48 | ||
460 | === modified file 'bzrlib/plugins/news_merge/__init__.py' | |||
461 | --- bzrlib/plugins/news_merge/__init__.py 2010-05-03 04:08:50 +0000 | |||
462 | +++ bzrlib/plugins/news_merge/__init__.py 2011-03-31 15:13:30 +0000 | |||
463 | @@ -33,26 +33,17 @@ | |||
464 | 33 | 33 | ||
465 | 34 | # Since we are a built-in plugin we share the bzrlib version | 34 | # Since we are a built-in plugin we share the bzrlib version |
466 | 35 | from bzrlib import version_info | 35 | from bzrlib import version_info |
476 | 36 | 36 | from bzrlib.hooks import install_lazy_named_hook | |
468 | 37 | # Put most of the code in a separate module that we lazy-import to keep the | ||
469 | 38 | # overhead of this plugin as minimal as possible. | ||
470 | 39 | from bzrlib.lazy_import import lazy_import | ||
471 | 40 | lazy_import(globals(), """ | ||
472 | 41 | from bzrlib.plugins.news_merge import news_merge as _mod_news_merge | ||
473 | 42 | """) | ||
474 | 43 | |||
475 | 44 | from bzrlib.merge import Merger | ||
477 | 45 | 37 | ||
478 | 46 | 38 | ||
479 | 47 | def news_merge_hook(merger): | 39 | def news_merge_hook(merger): |
480 | 48 | """Merger.merge_file_content hook for bzr-format NEWS files.""" | 40 | """Merger.merge_file_content hook for bzr-format NEWS files.""" |
488 | 49 | return _mod_news_merge.NewsMerger(merger) | 41 | from bzrlib.plugins.news_merge.news_merge import NewsMerger |
489 | 50 | 42 | return NewsMerger(merger) | |
490 | 51 | 43 | ||
491 | 52 | def install_hook(): | 44 | |
492 | 53 | Merger.hooks.install_named_hook( | 45 | install_lazy_named_hook("bzrlib.merge", "Merger.hooks", "merge_file_content", |
493 | 54 | 'merge_file_content', news_merge_hook, 'NEWS file merge') | 46 | news_merge_hook, "NEWS file merge") |
487 | 55 | install_hook() | ||
494 | 56 | 47 | ||
495 | 57 | 48 | ||
496 | 58 | def load_tests(basic_tests, module, loader): | 49 | def load_tests(basic_tests, module, loader): |
497 | 59 | 50 | ||
498 | === modified file 'bzrlib/smart/client.py' | |||
499 | --- bzrlib/smart/client.py 2010-02-17 17:11:16 +0000 | |||
500 | +++ bzrlib/smart/client.py 2011-03-31 15:13:30 +0000 | |||
501 | @@ -194,12 +194,12 @@ | |||
502 | 194 | class SmartClientHooks(hooks.Hooks): | 194 | class SmartClientHooks(hooks.Hooks): |
503 | 195 | 195 | ||
504 | 196 | def __init__(self): | 196 | def __init__(self): |
507 | 197 | hooks.Hooks.__init__(self) | 197 | hooks.Hooks.__init__(self, "bzrlib.smart.client", "_SmartClient.hooks") |
508 | 198 | self.create_hook(hooks.HookPoint('call', | 198 | self.add_hook('call', |
509 | 199 | "Called when the smart client is submitting a request to the " | 199 | "Called when the smart client is submitting a request to the " |
510 | 200 | "smart server. Called with a bzrlib.smart.client.CallHookParams " | 200 | "smart server. Called with a bzrlib.smart.client.CallHookParams " |
511 | 201 | "object. Streaming request bodies, and responses, are not " | 201 | "object. Streaming request bodies, and responses, are not " |
513 | 202 | "accessible.", None, None)) | 202 | "accessible.", None) |
514 | 203 | 203 | ||
515 | 204 | 204 | ||
516 | 205 | _SmartClient.hooks = SmartClientHooks() | 205 | _SmartClient.hooks = SmartClientHooks() |
517 | 206 | 206 | ||
518 | === modified file 'bzrlib/smart/server.py' | |||
519 | --- bzrlib/smart/server.py 2011-03-05 02:26:26 +0000 | |||
520 | +++ bzrlib/smart/server.py 2011-03-31 15:13:30 +0000 | |||
521 | @@ -22,7 +22,7 @@ | |||
522 | 22 | import sys | 22 | import sys |
523 | 23 | import threading | 23 | import threading |
524 | 24 | 24 | ||
526 | 25 | from bzrlib.hooks import HookPoint, Hooks | 25 | from bzrlib.hooks import Hooks |
527 | 26 | from bzrlib import ( | 26 | from bzrlib import ( |
528 | 27 | errors, | 27 | errors, |
529 | 28 | trace, | 28 | trace, |
530 | @@ -239,21 +239,21 @@ | |||
531 | 239 | These are all empty initially, because by default nothing should get | 239 | These are all empty initially, because by default nothing should get |
532 | 240 | notified. | 240 | notified. |
533 | 241 | """ | 241 | """ |
536 | 242 | Hooks.__init__(self) | 242 | Hooks.__init__(self, "bzrlib.smart.server", "SmartTCPServer.hooks") |
537 | 243 | self.create_hook(HookPoint('server_started', | 243 | self.add_hook('server_started', |
538 | 244 | "Called by the bzr server when it starts serving a directory. " | 244 | "Called by the bzr server when it starts serving a directory. " |
539 | 245 | "server_started is called with (backing urls, public url), " | 245 | "server_started is called with (backing urls, public url), " |
540 | 246 | "where backing_url is a list of URLs giving the " | 246 | "where backing_url is a list of URLs giving the " |
541 | 247 | "server-specific directory locations, and public_url is the " | 247 | "server-specific directory locations, and public_url is the " |
544 | 248 | "public URL for the directory being served.", (0, 16), None)) | 248 | "public URL for the directory being served.", (0, 16)) |
545 | 249 | self.create_hook(HookPoint('server_started_ex', | 249 | self.add_hook('server_started_ex', |
546 | 250 | "Called by the bzr server when it starts serving a directory. " | 250 | "Called by the bzr server when it starts serving a directory. " |
547 | 251 | "server_started is called with (backing_urls, server_obj).", | 251 | "server_started is called with (backing_urls, server_obj).", |
550 | 252 | (1, 17), None)) | 252 | (1, 17)) |
551 | 253 | self.create_hook(HookPoint('server_stopped', | 253 | self.add_hook('server_stopped', |
552 | 254 | "Called by the bzr server when it stops serving a directory. " | 254 | "Called by the bzr server when it stops serving a directory. " |
553 | 255 | "server_stopped is called with the same parameters as the " | 255 | "server_stopped is called with the same parameters as the " |
555 | 256 | "server_started hook: (backing_urls, public_url).", (0, 16), None)) | 256 | "server_started hook: (backing_urls, public_url).", (0, 16)) |
556 | 257 | 257 | ||
557 | 258 | SmartTCPServer.hooks = SmartServerHooks() | 258 | SmartTCPServer.hooks = SmartServerHooks() |
558 | 259 | 259 | ||
559 | 260 | 260 | ||
560 | === modified file 'bzrlib/status.py' | |||
561 | --- bzrlib/status.py 2011-01-31 22:09:46 +0000 | |||
562 | +++ bzrlib/status.py 2011-03-31 15:13:30 +0000 | |||
563 | @@ -379,23 +379,23 @@ | |||
564 | 379 | These are all empty initially, because by default nothing should get | 379 | These are all empty initially, because by default nothing should get |
565 | 380 | notified. | 380 | notified. |
566 | 381 | """ | 381 | """ |
569 | 382 | _mod_hooks.Hooks.__init__(self) | 382 | _mod_hooks.Hooks.__init__(self, "bzrlib.status", "hooks") |
570 | 383 | self.create_hook(_mod_hooks.HookPoint('post_status', | 383 | self.add_hook('post_status', |
571 | 384 | "Called with argument StatusHookParams after Bazaar has " | 384 | "Called with argument StatusHookParams after Bazaar has " |
572 | 385 | "displayed the status. StatusHookParams has the attributes " | 385 | "displayed the status. StatusHookParams has the attributes " |
573 | 386 | "(old_tree, new_tree, to_file, versioned, show_ids, short, " | 386 | "(old_tree, new_tree, to_file, versioned, show_ids, short, " |
574 | 387 | "verbose). The last four arguments correspond to the command " | 387 | "verbose). The last four arguments correspond to the command " |
575 | 388 | "line options specified by the user for the status command. " | 388 | "line options specified by the user for the status command. " |
576 | 389 | "to_file is the output stream for writing.", | 389 | "to_file is the output stream for writing.", |
579 | 390 | (2, 3), None)) | 390 | (2, 3)) |
580 | 391 | self.create_hook(_mod_hooks.HookPoint('pre_status', | 391 | self.add_hook('pre_status', |
581 | 392 | "Called with argument StatusHookParams before Bazaar " | 392 | "Called with argument StatusHookParams before Bazaar " |
582 | 393 | "displays the status. StatusHookParams has the attributes " | 393 | "displays the status. StatusHookParams has the attributes " |
583 | 394 | "(old_tree, new_tree, to_file, versioned, show_ids, short, " | 394 | "(old_tree, new_tree, to_file, versioned, show_ids, short, " |
584 | 395 | "verbose). The last four arguments correspond to the command " | 395 | "verbose). The last four arguments correspond to the command " |
585 | 396 | "line options specified by the user for the status command. " | 396 | "line options specified by the user for the status command. " |
586 | 397 | "to_file is the output stream for writing.", | 397 | "to_file is the output stream for writing.", |
588 | 398 | (2, 3), None)) | 398 | (2, 3)) |
589 | 399 | 399 | ||
590 | 400 | 400 | ||
591 | 401 | class StatusHookParams(object): | 401 | class StatusHookParams(object): |
592 | 402 | 402 | ||
593 | === modified file 'bzrlib/tests/test_hooks.py' | |||
594 | --- bzrlib/tests/test_hooks.py 2011-03-30 12:24:06 +0000 | |||
595 | +++ bzrlib/tests/test_hooks.py 2011-03-31 15:13:30 +0000 | |||
596 | @@ -39,39 +39,38 @@ | |||
597 | 39 | class TestHooks(tests.TestCase): | 39 | class TestHooks(tests.TestCase): |
598 | 40 | 40 | ||
599 | 41 | def test_create_hook_first(self): | 41 | def test_create_hook_first(self): |
601 | 42 | hooks = Hooks() | 42 | hooks = Hooks("bzrlib.tests.test_hooks", "some_hooks") |
602 | 43 | doc = ("Invoked after changing the tip of a branch object. Called with" | 43 | doc = ("Invoked after changing the tip of a branch object. Called with" |
603 | 44 | "a bzrlib.branch.PostChangeBranchTipParams object") | 44 | "a bzrlib.branch.PostChangeBranchTipParams object") |
604 | 45 | hook = HookPoint("post_tip_change", doc, (0, 15), None) | 45 | hook = HookPoint("post_tip_change", doc, (0, 15), None) |
606 | 46 | hooks.create_hook(hook) | 46 | self.applyDeprecated(deprecated_in((2, 4)), hooks.create_hook, hook) |
607 | 47 | self.assertEqual(hook, hooks['post_tip_change']) | 47 | self.assertEqual(hook, hooks['post_tip_change']) |
608 | 48 | 48 | ||
609 | 49 | def test_create_hook_name_collision_errors(self): | 49 | def test_create_hook_name_collision_errors(self): |
611 | 50 | hooks = Hooks() | 50 | hooks = Hooks("bzrlib.tests.test_hooks", "some_hooks") |
612 | 51 | doc = ("Invoked after changing the tip of a branch object. Called with" | 51 | doc = ("Invoked after changing the tip of a branch object. Called with" |
613 | 52 | "a bzrlib.branch.PostChangeBranchTipParams object") | 52 | "a bzrlib.branch.PostChangeBranchTipParams object") |
614 | 53 | hook = HookPoint("post_tip_change", doc, (0, 15), None) | 53 | hook = HookPoint("post_tip_change", doc, (0, 15), None) |
615 | 54 | hook2 = HookPoint("post_tip_change", None, None, None) | 54 | hook2 = HookPoint("post_tip_change", None, None, None) |
618 | 55 | hooks.create_hook(hook) | 55 | self.applyDeprecated(deprecated_in((2, 4)), hooks.create_hook, hook) |
619 | 56 | self.assertRaises(errors.DuplicateKey, hooks.create_hook, hook2) | 56 | self.assertRaises(errors.DuplicateKey, self.applyDeprecated, |
620 | 57 | deprecated_in((2, 4, 0)), hooks.create_hook, hook2) | ||
621 | 57 | self.assertEqual(hook, hooks['post_tip_change']) | 58 | self.assertEqual(hook, hooks['post_tip_change']) |
622 | 58 | 59 | ||
623 | 59 | def test_docs(self): | 60 | def test_docs(self): |
624 | 60 | """docs() should return something reasonable about the Hooks.""" | 61 | """docs() should return something reasonable about the Hooks.""" |
625 | 61 | class MyHooks(Hooks): | 62 | class MyHooks(Hooks): |
626 | 62 | pass | 63 | pass |
628 | 63 | hooks = MyHooks() | 64 | hooks = MyHooks("bzrlib.tests.test_hooks", "some_hooks") |
629 | 64 | hooks['legacy'] = [] | 65 | hooks['legacy'] = [] |
631 | 65 | hook1 = HookPoint('post_tip_change', | 66 | hooks.add_hook('post_tip_change', |
632 | 66 | "Invoked after the tip of a branch changes. Called with " | 67 | "Invoked after the tip of a branch changes. Called with " |
635 | 67 | "a ChangeBranchTipParams object.", (1, 4), None) | 68 | "a ChangeBranchTipParams object.", (1, 4)) |
636 | 68 | hook2 = HookPoint('pre_tip_change', | 69 | hooks.add_hook('pre_tip_change', |
637 | 69 | "Invoked before the tip of a branch changes. Called with " | 70 | "Invoked before the tip of a branch changes. Called with " |
638 | 70 | "a ChangeBranchTipParams object. Hooks should raise " | 71 | "a ChangeBranchTipParams object. Hooks should raise " |
639 | 71 | "TipChangeRejected to signal that a tip change is not permitted.", | 72 | "TipChangeRejected to signal that a tip change is not permitted.", |
640 | 72 | (1, 6), None) | 73 | (1, 6), None) |
641 | 73 | hooks.create_hook(hook1) | ||
642 | 74 | hooks.create_hook(hook2) | ||
643 | 75 | self.assertEqualDiff( | 74 | self.assertEqualDiff( |
644 | 76 | "MyHooks\n" | 75 | "MyHooks\n" |
645 | 77 | "-------\n" | 76 | "-------\n" |
646 | @@ -99,18 +98,18 @@ | |||
647 | 99 | "signal that a tip change is not permitted.\n", hooks.docs()) | 98 | "signal that a tip change is not permitted.\n", hooks.docs()) |
648 | 100 | 99 | ||
649 | 101 | def test_install_named_hook_raises_unknown_hook(self): | 100 | def test_install_named_hook_raises_unknown_hook(self): |
651 | 102 | hooks = Hooks() | 101 | hooks = Hooks("bzrlib.tests.test_hooks", "some_hooks") |
652 | 103 | self.assertRaises(errors.UnknownHook, hooks.install_named_hook, 'silly', | 102 | self.assertRaises(errors.UnknownHook, hooks.install_named_hook, 'silly', |
653 | 104 | None, "") | 103 | None, "") |
654 | 105 | 104 | ||
655 | 106 | def test_install_named_hook_appends_known_hook(self): | 105 | def test_install_named_hook_appends_known_hook(self): |
657 | 107 | hooks = Hooks() | 106 | hooks = Hooks("bzrlib.tests.test_hooks", "some_hooks") |
658 | 108 | hooks['set_rh'] = [] | 107 | hooks['set_rh'] = [] |
659 | 109 | hooks.install_named_hook('set_rh', None, "demo") | 108 | hooks.install_named_hook('set_rh', None, "demo") |
660 | 110 | self.assertEqual(hooks['set_rh'], [None]) | 109 | self.assertEqual(hooks['set_rh'], [None]) |
661 | 111 | 110 | ||
662 | 112 | def test_install_named_hook_and_retrieve_name(self): | 111 | def test_install_named_hook_and_retrieve_name(self): |
664 | 113 | hooks = Hooks() | 112 | hooks = Hooks("bzrlib.tests.test_hooks", "somehooks") |
665 | 114 | hooks['set_rh'] = [] | 113 | hooks['set_rh'] = [] |
666 | 115 | hooks.install_named_hook('set_rh', None, "demo") | 114 | hooks.install_named_hook('set_rh', None, "demo") |
667 | 116 | self.assertEqual("demo", hooks.get_hook_name(None)) | 115 | self.assertEqual("demo", hooks.get_hook_name(None)) |
668 | @@ -134,7 +133,7 @@ | |||
669 | 134 | set_rh = lambda: None | 133 | set_rh = lambda: None |
670 | 135 | 134 | ||
671 | 136 | def test_install_named_hook_lazy(self): | 135 | def test_install_named_hook_lazy(self): |
673 | 137 | hooks = Hooks() | 136 | hooks = Hooks("bzrlib.tests.hooks", "some_hooks") |
674 | 138 | hooks['set_rh'] = HookPoint("set_rh", "doc", (0, 15), None) | 137 | hooks['set_rh'] = HookPoint("set_rh", "doc", (0, 15), None) |
675 | 139 | hooks.install_named_hook_lazy('set_rh', 'bzrlib.tests.test_hooks', | 138 | hooks.install_named_hook_lazy('set_rh', 'bzrlib.tests.test_hooks', |
676 | 140 | 'TestHooks.set_rh', "demo") | 139 | 'TestHooks.set_rh', "demo") |
677 | @@ -143,7 +142,7 @@ | |||
678 | 143 | def test_install_named_hook_lazy_old(self): | 142 | def test_install_named_hook_lazy_old(self): |
679 | 144 | # An exception is raised if a lazy hook is raised for | 143 | # An exception is raised if a lazy hook is raised for |
680 | 145 | # an old style hook point. | 144 | # an old style hook point. |
682 | 146 | hooks = Hooks() | 145 | hooks = Hooks("bzrlib.tests.hooks", "some_hooks") |
683 | 147 | hooks['set_rh'] = [] | 146 | hooks['set_rh'] = [] |
684 | 148 | self.assertRaises(errors.UnsupportedOperation, | 147 | self.assertRaises(errors.UnsupportedOperation, |
685 | 149 | hooks.install_named_hook_lazy, | 148 | hooks.install_named_hook_lazy, |
686 | 150 | 149 | ||
687 | === modified file 'bzrlib/tests/test_selftest.py' | |||
688 | --- bzrlib/tests/test_selftest.py 2011-03-29 04:30:03 +0000 | |||
689 | +++ bzrlib/tests/test_selftest.py 2011-03-31 15:13:30 +0000 | |||
690 | @@ -1437,12 +1437,12 @@ | |||
691 | 1437 | # Note this test won't fail with hooks that the core library doesn't | 1437 | # Note this test won't fail with hooks that the core library doesn't |
692 | 1438 | # use - but it trigger with a plugin that adds hooks, so its still a | 1438 | # use - but it trigger with a plugin that adds hooks, so its still a |
693 | 1439 | # useful warning in that case. | 1439 | # useful warning in that case. |
697 | 1440 | self.assertEqual(bzrlib.branch.BranchHooks(), | 1440 | self.assertEqual(bzrlib.branch.BranchHooks(), bzrlib.branch.Branch.hooks) |
698 | 1441 | bzrlib.branch.Branch.hooks) | 1441 | self.assertEqual( |
699 | 1442 | self.assertEqual(bzrlib.smart.server.SmartServerHooks(), | 1442 | bzrlib.smart.server.SmartServerHooks(), |
700 | 1443 | bzrlib.smart.server.SmartTCPServer.hooks) | 1443 | bzrlib.smart.server.SmartTCPServer.hooks) |
703 | 1444 | self.assertEqual(bzrlib.commands.CommandHooks(), | 1444 | self.assertEqual( |
704 | 1445 | bzrlib.commands.Command.hooks) | 1445 | bzrlib.commands.CommandHooks(), bzrlib.commands.Command.hooks) |
705 | 1446 | 1446 | ||
706 | 1447 | def test__gather_lsprof_in_benchmarks(self): | 1447 | def test__gather_lsprof_in_benchmarks(self): |
707 | 1448 | """When _gather_lsprof_in_benchmarks is on, accumulate profile data. | 1448 | """When _gather_lsprof_in_benchmarks is on, accumulate profile data. |
708 | 1449 | 1449 | ||
709 | === modified file 'bzrlib/tests/transport_util.py' | |||
710 | --- bzrlib/tests/transport_util.py 2011-01-26 19:34:58 +0000 | |||
711 | +++ bzrlib/tests/transport_util.py 2011-03-31 15:13:30 +0000 | |||
712 | @@ -47,7 +47,8 @@ | |||
713 | 47 | """Dict-mapping hook name to a list of callables for transport hooks""" | 47 | """Dict-mapping hook name to a list of callables for transport hooks""" |
714 | 48 | 48 | ||
715 | 49 | def __init__(self): | 49 | def __init__(self): |
717 | 50 | super(TransportHooks, self).__init__() | 50 | super(TransportHooks, self).__init__("bzrlib.tests.transport_util", |
718 | 51 | "InstrumentedTransport.hooks") | ||
719 | 51 | # Invoked when the transport has just created a new connection. | 52 | # Invoked when the transport has just created a new connection. |
720 | 52 | # The api signature is (transport, connection, credentials) | 53 | # The api signature is (transport, connection, credentials) |
721 | 53 | self['_set_connection'] = [] | 54 | self['_set_connection'] = [] |
722 | 54 | 55 | ||
723 | === modified file 'bzrlib/version_info_formats/format_rio.py' | |||
724 | --- bzrlib/version_info_formats/format_rio.py 2011-02-18 19:01:43 +0000 | |||
725 | +++ bzrlib/version_info_formats/format_rio.py 2011-03-31 15:13:30 +0000 | |||
726 | @@ -89,7 +89,7 @@ | |||
727 | 89 | self.add_hook('revision', | 89 | self.add_hook('revision', |
728 | 90 | "Invoked when adding information about a revision to the" | 90 | "Invoked when adding information about a revision to the" |
729 | 91 | " RIO stanza that is printed. revision is called with a" | 91 | " RIO stanza that is printed. revision is called with a" |
731 | 92 | " revision object and a RIO stanza.", (1, 15), None) | 92 | " revision object and a RIO stanza.", (1, 15)) |
732 | 93 | 93 | ||
733 | 94 | 94 | ||
734 | 95 | RioVersionInfoBuilder.hooks = RioVersionInfoBuilderHooks() | 95 | RioVersionInfoBuilder.hooks = RioVersionInfoBuilderHooks() |
735 | 96 | 96 | ||
736 | === modified file 'doc/en/release-notes/bzr-2.4.txt' | |||
737 | --- doc/en/release-notes/bzr-2.4.txt 2011-03-30 10:54:24 +0000 | |||
738 | +++ doc/en/release-notes/bzr-2.4.txt 2011-03-31 15:13:30 +0000 | |||
739 | @@ -56,6 +56,9 @@ | |||
740 | 56 | .. Changes that may require updates in plugins or other code that uses | 56 | .. Changes that may require updates in plugins or other code that uses |
741 | 57 | bzrlib. | 57 | bzrlib. |
742 | 58 | 58 | ||
743 | 59 | * ``Hooks.create_hook`` is now deprecated in favour of ``Hooks.add_hook``. | ||
744 | 60 | (Jelmer Vernooij) | ||
745 | 61 | |||
746 | 59 | Internals | 62 | Internals |
747 | 60 | ********* | 63 | ********* |
748 | 61 | 64 |
One test failure when run on babune: babune. ladeuil. net:24842/ view/debug/ job/selftest- subset- all/108/ aggregatedTestR eport/
http://
<<< bzrlib. tests.test_ branch. TestHooks. test_constructo r
Stack Trace
_StringException: Text attachment: log tmp/testbzr- EefziM. tmp' vila/lib/ python/ testtools/ runtest. py", line 144, in _run_user vila/lib/ python/ testtools/ testcase. py", line 487, in _run_test_method babune/ babune/ slaves/ macadam. local/workspace /selftest- subset- macadam/ bzrlib/ tests/test_ branch. py", line 574, in test_constructor BranchHooks( "bzrlib. tests.test_ branch" , "branch.hooks")
------------
1426.373 opening working tree '/private/
------------
Text attachment: traceback
------------
Traceback (most recent call last):
File "/home/
File "/home/
File "/Users/
hooks = _mod_branch.
TypeError: __init__() takes exactly 1 argument (3 given)
------------
Since the changes are pretty mechanical, it's probably shallow, so tweak.