diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-01-27 21:44:04 +0100 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-04-05 14:30:14 -0400 |
commit | 137adc8edc476aecb2a3e6e9b0953c50a3be44c6 (patch) | |
tree | 66af79519f644f164a47f80885af439526314d4e | |
parent | 891808766de69b9c3143143a2b220e43ed3cdfee (diff) |
Rename bzr etckeeper plugin to clarify it's for bzr.
Remove warning about install bzr pre-commit hook.
-rw-r--r-- | etckeeper-bzr.py (renamed from etckeeper.py) | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/etckeeper.py b/etckeeper-bzr.py index ad73853..4a51085 100644 --- a/etckeeper.py +++ b/etckeeper-bzr.py @@ -2,22 +2,27 @@ # bzr plugin that runs etckeeper pre-commit when necessary from bzrlib.branch import Branch -from bzrlib.errors import BzrError +from bzrlib.errors import BzrError, NotLocalUrl import os import subprocess -def branch_pre_commit_hook(local, master, old_revno, old_revid, +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 - base = branch.bzrdir.root_transport.local_abspath(".") + 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', branch_pre_commit_hook) -Branch.hooks.name_hook(branch_pre_commit_hook, "shell-hooks") +Branch.hooks.install_hook('pre_commit', etckeeper_precommit_hook) +Branch.hooks.name_hook(etckeeper_precommit_hook, "etckeeper") |