summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-27 20:43:21 +0100
committerJoey Hess <joey@kodama.kitenet.net>2008-04-05 14:30:03 -0400
commit891808766de69b9c3143143a2b220e43ed3cdfee (patch)
tree5a336feced4e755e1982f2eb4221be9aea63c27b
parent9838b16bd73f2f1a26bb49515dcec597695c912f (diff)
Import plugin for bzr that can run the etckeeper pre-commit script.
-rw-r--r--etckeeper.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/etckeeper.py b/etckeeper.py
new file mode 100644
index 0000000..ad73853
--- /dev/null
+++ b/etckeeper.py
@@ -0,0 +1,23 @@
+#!/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")