summaryrefslogtreecommitdiff
path: root/etckeeper-bzr.py
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-27 21:44:04 +0100
committerJoey Hess <joey@kodama.kitenet.net>2008-04-05 14:30:14 -0400
commit137adc8edc476aecb2a3e6e9b0953c50a3be44c6 (patch)
tree66af79519f644f164a47f80885af439526314d4e /etckeeper-bzr.py
parent891808766de69b9c3143143a2b220e43ed3cdfee (diff)
Rename bzr etckeeper plugin to clarify it's for bzr.
Remove warning about install bzr pre-commit hook.
Diffstat (limited to 'etckeeper-bzr.py')
-rw-r--r--etckeeper-bzr.py28
1 files changed, 28 insertions, 0 deletions
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")