summaryrefslogtreecommitdiff
path: root/etckeeper-bzr
diff options
context:
space:
mode:
authorJoey Hess <joeyh@debian.org>2013-07-31 11:33:45 -0400
committerJoey Hess <joeyh@debian.org>2013-07-31 11:33:45 -0400
commitfdeec420b54e252e611c353ce39fe61c924e3e7d (patch)
tree2a1974e6c8cc56263e3903f49ea2a841ea895c6d /etckeeper-bzr
etckeeper (1.7) unstable; urgency=low
* Fix hilarious typo hardcoding my name. Closes: #718425 # imported from the archive
Diffstat (limited to 'etckeeper-bzr')
-rwxr-xr-xetckeeper-bzr/__init__.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/etckeeper-bzr/__init__.py b/etckeeper-bzr/__init__.py
new file mode 100755
index 0000000..61322fe
--- /dev/null
+++ b/etckeeper-bzr/__init__.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+# Bazaar plugin that runs etckeeper pre-commit when necessary
+
+"""Runs etckeeper pre-commit when necessary."""
+
+from bzrlib.errors import BzrError
+import os
+
+def etckeeper_startcommit_hook(tree):
+ abspath = getattr(tree, "abspath", None)
+ if abspath is None or not os.path.exists(abspath(".etckeeper")):
+ # Only run the commit hook when this is an etckeeper branch
+ return
+ import subprocess
+ ret = subprocess.call(["etckeeper", "pre-commit", abspath(".")])
+ if ret != 0:
+ raise BzrError("etckeeper pre-commit failed")
+
+try:
+ from bzrlib.hooks import install_lazy_named_hook
+except ImportError:
+ from bzrlib.mutabletree import MutableTree
+ MutableTree.hooks.install_named_hook('start_commit',
+ etckeeper_startcommit_hook, 'etckeeper')
+else:
+ install_lazy_named_hook(
+ "bzrlib.mutabletree", "MutableTree.hooks",
+ 'start_commit', etckeeper_startcommit_hook, 'etckeeper')
+
+if __name__ == "__main__":
+ from distutils.core import setup
+ setup(name="bzr-etckeeper",
+ packages=["bzrlib.plugins.etckeeper"],
+ package_dir={"bzrlib.plugins.etckeeper":"etckeeper-bzr"})