From 137adc8edc476aecb2a3e6e9b0953c50a3be44c6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 27 Jan 2008 21:44:04 +0100 Subject: Rename bzr etckeeper plugin to clarify it's for bzr. Remove warning about install bzr pre-commit hook. --- etckeeper-bzr.py | 28 ++++++++++++++++++++++++++++ etckeeper.py | 23 ----------------------- 2 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 etckeeper-bzr.py delete mode 100644 etckeeper.py diff --git a/etckeeper-bzr.py b/etckeeper-bzr.py new file mode 100644 index 0000000..4a51085 --- /dev/null +++ b/etckeeper-bzr.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +# bzr plugin that runs etckeeper pre-commit when necessary + +from bzrlib.branch import Branch +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")): + # Only run the commit hook when this is an etckeeper branch + return + ret = subprocess.call(["etckeeper", "pre-commit", base]) + 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") diff --git a/etckeeper.py b/etckeeper.py deleted file mode 100644 index ad73853..0000000 --- a/etckeeper.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python -# bzr plugin that runs etckeeper pre-commit when necessary - -from bzrlib.branch import Branch -from bzrlib.errors import BzrError -import os -import subprocess - -def branch_pre_commit_hook(local, master, old_revno, old_revid, - new_revno, new_revid, tree_delta, future_tree): - if local is None: - branch = master - else: - branch = local - base = branch.bzrdir.root_transport.local_abspath(".") - if not os.path.exists(os.path.join(base, ".etckeeper")): - return - ret = subprocess.call(["etckeeper", "pre-commit", base]) - if ret != 0: - raise BzrError("etckeeper pre-commit failed") - -Branch.hooks.install_hook('pre_commit', branch_pre_commit_hook) -Branch.hooks.name_hook(branch_pre_commit_hook, "shell-hooks") -- cgit v1.2.3