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