Rev 3725: (robertc) Add a Branch.open hook. (Robert Collins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Sep 23 04:52:04 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3725
revision-id: pqm at pqm.ubuntu.com-20080923035200-4k29gtzxfev8l3a0
parent: pqm at pqm.ubuntu.com-20080923015500-7nb0mp3c7o2wh1zu
parent: robertc at robertcollins.net-20080923032107-ibt7hdhdwcanbvvp
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2008-09-23 04:52:00 +0100
message:
(robertc) Add a Branch.open hook. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/help_topics/en/hooks.txt hooks.txt-20070830033044-xxu2rced13f72dka-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/branch_implementations/test_hooks.py test_hooks.py-20070129154855-blhpwxmvjs07waei-1
------------------------------------------------------------
revno: 3681.1.3
revision-id: robertc at robertcollins.net-20080923032107-ibt7hdhdwcanbvvp
parent: robertc at robertcollins.net-20080923021655-w6fiwcz42r9ju9xs
committer: Robert Collins <robertc at robertcollins.net>
branch nick: integration
timestamp: Tue 2008-09-23 13:21:07 +1000
message:
Update branch open tests to accomodate stacking.
modified:
bzrlib/tests/branch_implementations/test_hooks.py test_hooks.py-20070129154855-blhpwxmvjs07waei-1
------------------------------------------------------------
revno: 3681.1.2
revision-id: robertc at robertcollins.net-20080923021655-w6fiwcz42r9ju9xs
parent: robertc at robertcollins.net-20080904052339-tyyojuqlonks504v
parent: pqm at pqm.ubuntu.com-20080922180718-n946121e40ql2bb3
committer: Robert Collins <robertc at robertcollins.net>
branch nick: integration
timestamp: Tue 2008-09-23 12:16:55 +1000
message:
Adjust for trunk.
added:
bzrlib/_readdir_py.py readdir.py-20060609152855-rm6v321vuaqyh9tu-3
bzrlib/_readdir_pyx.pyx readdir.pyx-20060609152855-rm6v321vuaqyh9tu-1
bzrlib/readdir.h readdir.h-20060609152855-rm6v321vuaqyh9tu-2
bzrlib/tests/test_transport_log.py test_transport_log.p-20080902041816-vh8x5yt5nvdzvew3-3
bzrlib/transport/log.py log.py-20080902041816-vh8x5yt5nvdzvew3-5
doc/developers/overview.txt overview.txt-20080904022501-ww2ggomrs5elxfm0-1
renamed:
bzrlib/tests/repository_implementations => bzrlib/tests/per_repository repository_implementations-20060131092037-ec97814745cc6128
modified:
.bzrignore bzrignore-20050311232317-81f7b71efa2db11a
NEWS NEWS-20050323055033-4e00b5db738777ff
bzr bzr.py-20050313053754-5485f144c7006fa6
bzr.ico bzr.ico-20060629083000-q18ip0hk7lq55i4y-1
bzrlib/__init__.py __init__.py-20050309040759-33e65acf91bbcd5d
bzrlib/atomicfile.py atomicfile.py-20050509044450-dbd24e6c564f7c66
bzrlib/benchmarks/bench_osutils.py bench_osutils.py-20060608153714-apso8cyz1bu2z1ig-1
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/btree_index.py index.py-20080624222253-p0x5f92uyh5hw734-7
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bundle/__init__.py changeset.py-20050513021216-b02ab57fb9738913
bzrlib/bundle/bundle_data.py read_changeset.py-20050619171944-c0d95aa685537640
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/directory_service.py directory_service.py-20080305221044-vr2mkvlsk8jypa2y-1
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/lockdir.py lockdir.py-20060220222025-98258adf27fbdda3
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/memorytree.py memorytree.py-20060906023413-4wlkalbdpsxi2r4y-1
bzrlib/merge.py merge.py-20050513021216-953b65a438527106
bzrlib/missing.py missing.py-20050812153334-097f7097e2a8bcd1
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/revisionspec.py revisionspec.py-20050907152633-17567659fd5c0ddb
bzrlib/smart/branch.py branch.py-20061124031907-mzh3pla28r83r97f-1
bzrlib/smart/client.py client.py-20061116014825-2k6ada6xgulslami-1
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
bzrlib/smart/message.py message.py-20080222013625-ncqmh3nrxjkxab87-1
bzrlib/smart/protocol.py protocol.py-20061108035435-ot0lstk2590yqhzr-1
bzrlib/smart/repository.py repository.py-20061128022038-vr5wy5bubyb8xttk-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/smart/server.py server.py-20061110062051-chzu10y32vx8gvur-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
bzrlib/tests/blackbox/test_export.py test_export.py-20051229024010-e6c26658e460fb1c
bzrlib/tests/blackbox/test_init.py test_init.py-20060309032856-a292116204d86eb7
bzrlib/tests/blackbox/test_outside_wt.py test_outside_wt.py-20060116200058-98edd33e7db8bdde
bzrlib/tests/blackbox/test_remove_tree.py test_remove_tree.py-20061110192919-5j3xjciiaqbs2dvo-1
bzrlib/tests/blackbox/test_switch.py test_switch.py-20071122111948-0c5en6uz92bwl76h-1
bzrlib/tests/branch_implementations/test_break_lock.py test_break_lock.py-20060504111902-9aae411dbe9aadd2
bzrlib/tests/branch_implementations/test_locking.py test_locking.py-20060707151933-tav3o2hpibwi53u4-4
bzrlib/tests/branch_implementations/test_push.py test_push.py-20070130153159-fhfap8uoifevg30j-1
bzrlib/tests/per_repository/__init__.py __init__.py-20060131092037-9564957a7d4a841b
bzrlib/tests/per_repository/helpers.py helpers.py-20070924032407-m460yl9j5gu5ju85-2
bzrlib/tests/per_repository/test__generate_text_key_index.py test__generate_text_-20071114232121-00h9fd8qg8kjfa5k-1
bzrlib/tests/per_repository/test_add_fallback_repository.py test_add_fallback_re-20080215040003-8w9n4ck9uqdxj18m-1
bzrlib/tests/per_repository/test_break_lock.py test_break_lock.py-20060504111704-ee09a107f9f42e43
bzrlib/tests/per_repository/test_check.py test_check.py-20070824124512-38g4d135gcqxo4zb-1
bzrlib/tests/per_repository/test_check_reconcile.py test_broken.py-20070928125406-62236394w0jpbpd6-2
bzrlib/tests/per_repository/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
bzrlib/tests/per_repository/test_fetch.py test_fetch.py-20070814052151-5cxha9slx4c93uog-1
bzrlib/tests/per_repository/test_fileid_involved.py test_file_involved.py-20051215205901-728a172d1014daaa
bzrlib/tests/per_repository/test_find_text_key_references.py test_find_text_key_r-20071114033605-v73bakal8x77qlfi-1
bzrlib/tests/per_repository/test_get_parent_map.py test_get_parent_map.-20080421172708-x1z6ot341osr0jq1-1
bzrlib/tests/per_repository/test_has_revisions.py test_has_revisions.p-20080111035443-xaupgdsx5fw1q54b-1
bzrlib/tests/per_repository/test_has_same_location.py test_has_same_locati-20070807074648-2i2ah82fbe83iys7-1
bzrlib/tests/per_repository/test_is_write_locked.py test_is_write_locked-20071012063748-vk062lmu683qgbc3-1
bzrlib/tests/per_repository/test_iter_reverse_revision_history.py test_iter_reverse_re-20070217015036-spu7j5ggch7pbpyd-1
bzrlib/tests/per_repository/test_pack.py test_pack.py-20070712120702-0c7585lh56p894mo-2
bzrlib/tests/per_repository/test_reconcile.py test_reconcile.py-20060223022332-572ef70a3288e369
bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/per_repository/test_revision.py testrevprops.py-20051013073044-92bc3c68302ce1bf
bzrlib/tests/per_repository/test_statistics.py test_statistics.py-20070203082432-6738e8fl0mm7ikre-1
bzrlib/tests/per_repository/test_write_group.py test_write_group.py-20070716105516-89n34xtogq5frn0m-1
bzrlib/tests/per_repository_reference/__init__.py __init__.py-20080220025549-nnm2s80it1lvcwnc-2
bzrlib/tests/test_annotate.py test_annotate.py-20061213215015-sttc9agsxomls7q0-1
bzrlib/tests/test_btree_index.py test_index.py-20080624222253-p0x5f92uyh5hw734-13
bzrlib/tests/test_bundle.py test.py-20050630184834-092aa401ab9f039c
bzrlib/tests/test_diff.py testdiff.py-20050727164403-d1a3496ebb12e339
bzrlib/tests/test_directory_service.py test_directory_servi-20080305221044-vr2mkvlsk8jypa2y-2
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
bzrlib/tests/test_missing.py test_missing.py-20051212000028-694fa4f658a81f48
bzrlib/tests/test_osutils.py test_osutils.py-20051201224856-e48ee24c12182989
bzrlib/tests/test_reconcile.py test_reconcile.py-20060225054842-50aa618584a86f26
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
bzrlib/tests/test_revisiontree.py test_revisiontree.py-20060615095324-aij44ndxbv1h4c9f-1
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
bzrlib/tests/test_sftp_transport.py testsftp.py-20051027032739-247570325fec7e7e
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
bzrlib/tests/test_transport.py testtransport.py-20050718175618-e5cdb99f4555ddce
bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
bzrlib/tests/tree_implementations/test_inv.py test_inv.py-20070312023226-0cdvk5uwhutis9vg-1
bzrlib/tests/tree_implementations/test_test_trees.py test_tree_trees.py-20060720091921-3nwi5h21lf06vf5p-1
bzrlib/tests/tree_implementations/test_tree.py test_tree.py-20061215160206-usu7lwcj8aq2n3br-1
bzrlib/tests/workingtree_implementations/test_parents.py test_set_parents.py-20060807231740-yicmnlci1mj8smu1-1
bzrlib/tests/workingtree_implementations/test_remove.py test_remove.py-20070413183901-rvnp85rtc0q0sclp-1
bzrlib/tests/workingtree_implementations/test_rename_one.py test_rename_one.py-20070226161242-2d8ibdedl700jgio-1
bzrlib/tests/workingtree_implementations/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/http/__init__.py http_transport.py-20050711212304-506c5fd1059ace96
bzrlib/transport/local.py local_transport.py-20050711165921-9b1f142bfe480c24
bzrlib/transport/sftp.py sftp.py-20051019050329-ab48ce71b7e32dfe
bzrlib/transport/trace.py trace.py-20070828055009-7kt0bbc4t4b92apz-1
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
bzrlib/win32utils.py win32console.py-20051021033308-123c6c929d04973d
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
doc/developers/HACKING.txt HACKING-20050805200004-2a5dc975d870f78c
doc/developers/index.txt index.txt-20070508041241-qznziunkg0nffhiw-1
doc/en/user-guide/http_smart_server.txt fastcgi.txt-20061005091552-rz8pva0olkxv0sd8-3
doc/en/user-guide/undoing_mistakes.txt undoing_mistakes.txt-20071121092300-8fyacngt1w98e5mp-1
profile_imports.py profile_imports.py-20060618020306-k5uw80achysrokj9-1
setup.py setup.py-20050314065409-02f8a0a6e3f9bc70
tools/doc_generate/autodoc_man.py bzrman.py-20050601153041-0ff7f74de456d15e
------------------------------------------------------------
revno: 3681.1.1
revision-id: robertc at robertcollins.net-20080904052339-tyyojuqlonks504v
parent: pqm at pqm.ubuntu.com-20080902220856-plj0mk673ygzwc1k
committer: Robert Collins <robertc at robertcollins.net>
branch nick: branch
timestamp: Thu 2008-09-04 15:23:39 +1000
message:
Create a new hook Branch.open. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/help_topics/en/hooks.txt hooks.txt-20070830033044-xxu2rced13f72dka-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/branch_implementations/test_hooks.py test_hooks.py-20070129154855-blhpwxmvjs07waei-1
=== modified file 'NEWS'
--- a/NEWS 2008-09-22 23:21:26 +0000
+++ b/NEWS 2008-09-23 03:52:00 +0000
@@ -75,6 +75,9 @@
INTERNALS:
+ * A new hook, ``Branch.open``, has been added, which is called when
+ branch objects are opened. (Robert Collins)
+
bzr 1.7rc2 IN DEVELOPMENT
-------------------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2008-09-22 04:48:47 +0000
+++ b/bzrlib/branch.py 2008-09-23 02:16:55 +0000
@@ -91,6 +91,9 @@
self._revision_id_to_revno_cache = None
self._last_revision_info_cache = None
self._open_hook()
+ hooks = Branch.hooks['open']
+ for hook in hooks:
+ hook(self)
def _open_hook(self):
"""Called by init to allow simpler extension of the base class."""
@@ -1068,6 +1071,8 @@
# (branch, revision_history), and the branch will
# be write-locked.
self['set_rh'] = []
+ # Invoked after a branch is opened. The api signature is (branch).
+ self['open'] = []
# invoked after a push operation completes.
# the api signature is
# (push_result)
=== modified file 'bzrlib/help_topics/en/hooks.txt'
--- a/bzrlib/help_topics/en/hooks.txt 2008-07-04 03:19:47 +0000
+++ b/bzrlib/help_topics/en/hooks.txt 2008-09-04 05:23:39 +0000
@@ -15,6 +15,12 @@
The class of each hook is given immediately after each hook type below.
+open (Branch)
+-------------
+
+Called after a Branch object is opened, with the Branch object.
+
+
post_push (Branch)
------------------
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2008-09-17 04:33:24 +0000
+++ b/bzrlib/remote.py 2008-09-23 02:16:55 +0000
@@ -1296,6 +1296,10 @@
self._repo_lock_token = None
self._lock_count = 0
self._leave_lock = False
+ # The base class init is not called, so we duplicate this:
+ hooks = branch.Branch.hooks['open']
+ for hook in hooks:
+ hook(self)
self._setup_stacking()
def _setup_stacking(self):
=== modified file 'bzrlib/tests/branch_implementations/test_hooks.py'
--- a/bzrlib/tests/branch_implementations/test_hooks.py 2008-07-25 06:42:08 +0000
+++ b/bzrlib/tests/branch_implementations/test_hooks.py 2008-09-23 03:21:07 +0000
@@ -16,8 +16,9 @@
"""Tests that branch classes implement hook callouts correctly."""
+from bzrlib.branch import Branch, ChangeBranchTipParams
from bzrlib.errors import HookFailed, TipChangeRejected
-from bzrlib.branch import Branch, ChangeBranchTipParams
+from bzrlib.remote import RemoteBranch
from bzrlib.revision import NULL_REVISION
from bzrlib.tests import TestCaseWithMemoryTransport
@@ -107,6 +108,38 @@
return branch
+class TestOpen(TestCaseWithMemoryTransport):
+
+ def capture_hook(self, branch):
+ self.hook_calls.append(branch)
+
+ def install_hook(self):
+ self.hook_calls = []
+ Branch.hooks.install_named_hook('open', self.capture_hook, None)
+
+ def test_create(self):
+ self.install_hook()
+ b = self.make_branch('.')
+ self.assertEqual([b], self.hook_calls)
+
+ def test_open(self):
+ branch_url = self.make_branch('.').bzrdir.root_transport.base
+ self.install_hook()
+ b = Branch.open(branch_url)
+ if isinstance(b, RemoteBranch):
+ # RemoteBranch open always opens the backing branch to get stacking
+ # details. As that is done remotely we can't see the branch object
+ # nor even compare base url's etc. So we just assert that the first
+ # branch returned is the RemoteBranch, and that the second is a
+ # Branch but not a RemoteBranch.
+ self.assertEqual(2, len(self.hook_calls))
+ self.assertEqual(b, self.hook_calls[0])
+ self.assertIsInstance(self.hook_calls[1], Branch)
+ self.assertFalse(isinstance(self.hook_calls[1], RemoteBranch))
+ else:
+ self.assertEqual([b], self.hook_calls)
+
+
class TestPreChangeBranchTip(ChangeBranchTipTestCase):
"""Tests for pre_change_branch_tip hook.
More information about the bazaar-commits
mailing list