diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-04-05 05:34:08 +0200 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-04-05 14:30:22 -0400 |
commit | fa84e9dcae169c7e6f9800572cb94bad2c09c51e (patch) | |
tree | a676209c6925c6d0d0d8e64a6591ce23ffd5487a | |
parent | 137adc8edc476aecb2a3e6e9b0953c50a3be44c6 (diff) |
Update bzr plugin to use new start_commit hook.
-rwxr-xr-x[-rw-r--r--] | etckeeper-bzr.py | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/etckeeper-bzr.py b/etckeeper-bzr.py index 4a51085..97a8689 100644..100755 --- a/etckeeper-bzr.py +++ b/etckeeper-bzr.py @@ -1,28 +1,26 @@ #!/usr/bin/python -# bzr plugin that runs etckeeper pre-commit when necessary +# Bazaar plugin that runs etckeeper pre-commit when necessary -from bzrlib.branch import Branch +"""Runs etckeeper pre-commit when necessary.""" + +from bzrlib.mutabletree import MutableTree from bzrlib.errors import BzrError, NotLocalUrl import os import subprocess -def etckeeper_precommit_hook(local, master, old_revno, old_revid, - new_revno, new_revid, tree_delta, future_tree): - if local is None: - branch = master - else: - branch = local - try: - base = branch.bzrdir.root_transport.local_abspath(".") - except NotLocalUrl: - # No point in running etckeeper when committing to a remote branch - return - if not os.path.exists(os.path.join(base, ".etckeeper")): +def etckeeper_startcommit_hook(tree): + if not os.path.exists(tree.abspath(".etckeeper")): # Only run the commit hook when this is an etckeeper branch return - ret = subprocess.call(["etckeeper", "pre-commit", base]) + ret = subprocess.call(["etckeeper", "pre-commit", tree.abspath(".")]) if ret != 0: raise BzrError("etckeeper pre-commit failed") -Branch.hooks.install_hook('pre_commit', etckeeper_precommit_hook) -Branch.hooks.name_hook(etckeeper_precommit_hook, "etckeeper") +MutableTree.hooks.install_hook('start_commit', etckeeper_startcommit_hook) +MutableTree.hooks.name_hook(etckeeper_startcommit_hook, "etckeeper") + +if __name__ == "__main__": + from distutils.core import setup + setup(name="bzr-etckeeper", + package_dir={"bzrlib.plugins.etckeeper":__file__}, + py_modules=["bzrlib.plugins.etckeeper"]) |