summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2011-02-20 00:09:06 +0100
committerJoey Hess <joey@kitenet.net>2011-02-19 20:02:40 -0400
commita9784f835351f638919a44f3fe1dbc82ef1e0023 (patch)
tree637b2247c307684eae8d00990d74507fdf2ec882
parent05a29cb5dd6397c62e42465978b95df074ea5fca (diff)
Install bzr hook lazily, clean up some compatibility code.
-rw-r--r--debian/control6
-rwxr-xr-xetckeeper-bzr/__init__.py23
2 files changed, 14 insertions, 15 deletions
diff --git a/debian/control b/debian/control
index 8c7a09f..effc724 100644
--- a/debian/control
+++ b/debian/control
@@ -1,7 +1,7 @@
Source: etckeeper
Section: admin
Priority: optional
-Build-Depends: debhelper (>= 7), dpkg-dev (>= 1.9.0), bzr (>= 1.4~), python-central
+Build-Depends: debhelper (>= 7), dpkg-dev (>= 1.9.0), bzr (>= 1.5~), python-central
Maintainer: Joey Hess <joeyh@debian.org>
Standards-Version: 3.9.0
XS-Python-Version: all
@@ -11,10 +11,10 @@ Homepage: http://kitenet.net/~joey/code/etckeeper/
Package: etckeeper
Architecture: all
Section: admin
-Depends: git-core (>= 1:1.5.4) | git (>= 1:1.7) | mercurial | bzr (>= 1.4~) | darcs, ${misc:Depends}
+Depends: git-core (>= 1:1.5.4) | git (>= 1:1.7) | mercurial | bzr (>= 1.5~) | darcs, ${misc:Depends}
Recommends: cron
Suggests: sudo (>= 1.7.4p4)
-Conflicts: bzr (<< 1.4~)
+Conflicts: bzr (<< 1.5~)
XB-Python-Version: ${python:Versions}
Description: store /etc in git, mercurial, bzr or darcs
The etckeeper program is a tool to let /etc be stored in a git, mercurial,
diff --git a/etckeeper-bzr/__init__.py b/etckeeper-bzr/__init__.py
index 3cf06db..61322fe 100755
--- a/etckeeper-bzr/__init__.py
+++ b/etckeeper-bzr/__init__.py
@@ -3,30 +3,29 @@
"""Runs etckeeper pre-commit when necessary."""
-import bzrlib
-from bzrlib.mutabletree import MutableTree
-from bzrlib.errors import BzrError, NotLocalUrl
+from bzrlib.errors import BzrError
import os
-import subprocess
-
-if not (hasattr(MutableTree, "hooks") and "start_commit" in MutableTree.hooks):
- raise "Version of Bazaar installed does not support required hooks."
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")
-install_named_hook = getattr(MutableTree.hooks, 'install_named_hook', None)
-if install_named_hook is not None:
- install_named_hook('start_commit', etckeeper_startcommit_hook, 'etckeeper')
+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:
- MutableTree.hooks.install_hook('start_commit', etckeeper_startcommit_hook)
- MutableTree.hooks.name_hook(etckeeper_startcommit_hook, "etckeeper")
+ install_lazy_named_hook(
+ "bzrlib.mutabletree", "MutableTree.hooks",
+ 'start_commit', etckeeper_startcommit_hook, 'etckeeper')
if __name__ == "__main__":
from distutils.core import setup