1370
1370
Hooks.__init__(self)
1371
# Introduced in 0.15:
1372
# invoked whenever the revision history has been set
1373
# with set_revision_history. The api signature is
1374
# (branch, revision_history), and the branch will
1377
# Invoked after a branch is opened. The api signature is (branch).
1379
# invoked after a push operation completes.
1380
# the api signature is
1382
# containing the members
1383
# (source, local, master, old_revno, old_revid, new_revno, new_revid)
1384
# where local is the local target branch or None, master is the target
1385
# master branch, and the rest should be self explanatory. The source
1386
# is read locked and the target branches write locked. Source will
1387
# be the local low-latency branch.
1388
self['post_push'] = []
1389
# invoked after a pull operation completes.
1390
# the api signature is
1392
# containing the members
1393
# (source, local, master, old_revno, old_revid, new_revno, new_revid)
1394
# where local is the local branch or None, master is the target
1395
# master branch, and the rest should be self explanatory. The source
1396
# is read locked and the target branches write locked. The local
1397
# branch is the low-latency branch.
1398
self['post_pull'] = []
1399
# invoked before a commit operation takes place.
1400
# the api signature is
1401
# (local, master, old_revno, old_revid, future_revno, future_revid,
1402
# tree_delta, future_tree).
1403
# old_revid is NULL_REVISION for the first commit to a branch
1404
# tree_delta is a TreeDelta object describing changes from the basis
1405
# revision, hooks MUST NOT modify this delta
1406
# future_tree is an in-memory tree obtained from
1407
# CommitBuilder.revision_tree() and hooks MUST NOT modify this tree
1408
self['pre_commit'] = []
1409
# invoked after a commit operation completes.
1410
# the api signature is
1411
# (local, master, old_revno, old_revid, new_revno, new_revid)
1412
# old_revid is NULL_REVISION for the first commit to a branch.
1413
self['post_commit'] = []
1414
# invoked after a uncommit operation completes.
1415
# the api signature is
1416
# (local, master, old_revno, old_revid, new_revno, new_revid) where
1417
# local is the local branch or None, master is the target branch,
1418
# and an empty branch recieves new_revno of 0, new_revid of None.
1419
self['post_uncommit'] = []
1421
# Invoked before the tip of a branch changes.
1422
# the api signature is
1423
# (params) where params is a ChangeBranchTipParams with the members
1424
# (branch, old_revno, new_revno, old_revid, new_revid)
1425
self['pre_change_branch_tip'] = []
1427
# Invoked after the tip of a branch changes.
1428
# the api signature is
1429
# (params) where params is a ChangeBranchTipParams with the members
1430
# (branch, old_revno, new_revno, old_revid, new_revid)
1431
self['post_change_branch_tip'] = []
1433
# Invoked when a stacked branch activates its fallback locations and
1434
# allows the transformation of the url of said location.
1435
# the api signature is
1436
# (branch, url) where branch is the branch having its fallback
1437
# location activated and url is the url for the fallback location.
1438
# The hook should return a url.
1439
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))
1442
1433
# install the default hooks into the Branch class.