1374
1370
Hooks.__init__(self)
1375
# Introduced in 0.15:
1376
# invoked whenever the revision history has been set
1377
# with set_revision_history. The api signature is
1378
# (branch, revision_history), and the branch will
1381
# Invoked after a branch is opened. The api signature is (branch).
1383
# invoked after a push operation completes.
1384
# the api signature is
1386
# containing the members
1387
# (source, local, master, old_revno, old_revid, new_revno, new_revid)
1388
# where local is the local target branch or None, master is the target
1389
# master branch, and the rest should be self explanatory. The source
1390
# is read locked and the target branches write locked. Source will
1391
# be the local low-latency branch.
1392
self['post_push'] = []
1393
# invoked after a pull operation completes.
1394
# the api signature is
1396
# containing the members
1397
# (source, local, master, old_revno, old_revid, new_revno, new_revid)
1398
# where local is the local branch or None, master is the target
1399
# master branch, and the rest should be self explanatory. The source
1400
# is read locked and the target branches write locked. The local
1401
# branch is the low-latency branch.
1402
self['post_pull'] = []
1403
# invoked before a commit operation takes place.
1404
# the api signature is
1405
# (local, master, old_revno, old_revid, future_revno, future_revid,
1406
# tree_delta, future_tree).
1407
# old_revid is NULL_REVISION for the first commit to a branch
1408
# tree_delta is a TreeDelta object describing changes from the basis
1409
# revision, hooks MUST NOT modify this delta
1410
# future_tree is an in-memory tree obtained from
1411
# CommitBuilder.revision_tree() and hooks MUST NOT modify this tree
1412
self['pre_commit'] = []
1413
# invoked after a commit operation completes.
1414
# the api signature is
1415
# (local, master, old_revno, old_revid, new_revno, new_revid)
1416
# old_revid is NULL_REVISION for the first commit to a branch.
1417
self['post_commit'] = []
1418
# invoked after a uncommit operation completes.
1419
# the api signature is
1420
# (local, master, old_revno, old_revid, new_revno, new_revid) where
1421
# local is the local branch or None, master is the target branch,
1422
# and an empty branch recieves new_revno of 0, new_revid of None.
1423
self['post_uncommit'] = []
1425
# Invoked before the tip of a branch changes.
1426
# the api signature is
1427
# (params) where params is a ChangeBranchTipParams with the members
1428
# (branch, old_revno, new_revno, old_revid, new_revid)
1429
self['pre_change_branch_tip'] = []
1431
# Invoked after the tip of a branch changes.
1432
# the api signature is
1433
# (params) where params is a ChangeBranchTipParams with the members
1434
# (branch, old_revno, new_revno, old_revid, new_revid)
1435
self['post_change_branch_tip'] = []
1437
# Invoked when a stacked branch activates its fallback locations and
1438
# allows the transformation of the url of said location.
1439
# the api signature is
1440
# (branch, url) where branch is the branch having its fallback
1441
# location activated and url is the url for the fallback location.
1442
# The hook should return a url.
1443
self['transform_fallback_location'] = []
1371
self.create_hook(HookPoint('set_rh',
1372
"Invoked whenever the revision history has been set via "
1373
"set_revision_history. The api signature is (branch, "
1374
"revision_history), and the branch will be write-locked. "
1375
"The set_rh hook can be expensive for bzr to trigger, a better "
1376
"hook to use is Branch.post_change_branch_tip.", (0, 15), None))
1377
self.create_hook(HookPoint('open',
1378
"Called with the Branch object that has been opened after a "
1379
"branch is opened.", (1, 8), None))
1380
self.create_hook(HookPoint('post_push',
1381
"Called after a push operation completes. post_push is called "
1382
"with a bzrlib.branch.BranchPushResult object and only runs in the "
1383
"bzr client.", (0, 15), None))
1384
self.create_hook(HookPoint('post_pull',
1385
"Called after a pull operation completes. post_pull is called "
1386
"with a bzrlib.branch.PullResult object and only runs in the "
1387
"bzr client.", (0, 15), None))
1388
self.create_hook(HookPoint('pre_commit',
1389
"Called after a commit is calculated but before it is is "
1390
"completed. pre_commit is called with (local, master, old_revno, "
1391
"old_revid, future_revno, future_revid, tree_delta, future_tree"
1392
"). old_revid is NULL_REVISION for the first commit to a branch, "
1393
"tree_delta is a TreeDelta object describing changes from the "
1394
"basis revision. hooks MUST NOT modify this delta. "
1395
" future_tree is an in-memory tree obtained from "
1396
"CommitBuilder.revision_tree() and hooks MUST NOT modify this "
1397
"tree.", (0,91), None))
1398
self.create_hook(HookPoint('post_commit',
1399
"Called in the bzr client after a commit has completed. "
1400
"post_commit is called with (local, master, old_revno, old_revid, "
1401
"new_revno, new_revid). old_revid is NULL_REVISION for the first "
1402
"commit to a branch.", (0, 15), None))
1403
self.create_hook(HookPoint('post_uncommit',
1404
"Called in the bzr client after an uncommit completes. "
1405
"post_uncommit is called with (local, master, old_revno, "
1406
"old_revid, new_revno, new_revid) where local is the local branch "
1407
"or None, master is the target branch, and an empty branch "
1408
"recieves new_revno of 0, new_revid of None.", (0, 15), None))
1409
self.create_hook(HookPoint('pre_change_branch_tip',
1410
"Called in bzr client and server before a change to the tip of a "
1411
"branch is made. pre_change_branch_tip is called with a "
1412
"bzrlib.branch.ChangeBranchTipParams. Note that push, pull, "
1413
"commit, uncommit will all trigger this hook.", (1, 6), None))
1414
self.create_hook(HookPoint('post_change_branch_tip',
1415
"Called in bzr client and server after a change to the tip of a "
1416
"branch is made. post_change_branch_tip is called with a "
1417
"bzrlib.branch.ChangeBranchTipParams. Note that push, pull, "
1418
"commit, uncommit will all trigger this hook.", (1, 4), None))
1419
self.create_hook(HookPoint('transform_fallback_location',
1420
"Called when a stacked branch is activating its fallback "
1421
"locations. transform_fallback_location is called with (branch, "
1422
"url), and should return a new url. Returning the same url "
1423
"allows it to be used as-is, returning a different one can be "
1424
"used to cause the branch to stack on a closer copy of that "
1425
"fallback_location. Note that the branch cannot have history "
1426
"accessing methods called on it during this hook because the "
1427
"fallback locations have not been activated. When there are "
1428
"multiple hooks installed for transform_fallback_location, "
1429
"all are called with the url returned from the previous hook."
1430
"The order is however undefined.", (1, 9), None))
1446
1433
# install the default hooks into the Branch class.