summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-12-06 19:20:45 +0100
committerLars Wirzenius <liw@liw.fi>2015-12-06 19:20:45 +0100
commit2cad8cba639e5d5d7bfa016a53428849331bf321 (patch)
treea6fa12cb320dba51190f78a8097f221239a92212
parentc9f2b8fe9f9d2cf1155325cf01f232e407ecdd3a (diff)
downloadobnam-2cad8cba639e5d5d7bfa016a53428849331bf321.tar.gz
Move shared repo format hooks to RepositoryFactory
-rw-r--r--obnamlib/fmt_6/repo_fmt_6.py4
-rw-r--r--obnamlib/fmt_6/repo_fmt_6_tests.py5
-rw-r--r--obnamlib/fmt_ga/format_tests.py4
-rw-r--r--obnamlib/repo_factory.py6
4 files changed, 13 insertions, 6 deletions
diff --git a/obnamlib/fmt_6/repo_fmt_6.py b/obnamlib/fmt_6/repo_fmt_6.py
index 4a67e399..25156e78 100644
--- a/obnamlib/fmt_6/repo_fmt_6.py
+++ b/obnamlib/fmt_6/repo_fmt_6.py
@@ -70,9 +70,7 @@ class RepositoryFormat6(obnamlib.RepositoryInterface):
@classmethod
def setup_hooks(cls, hooks):
- hooks.new('repository-toplevel-init')
- hooks.new_filter('repository-data')
- hooks.new('repository-add-client')
+ pass
def get_fs(self):
return self._real_fs
diff --git a/obnamlib/fmt_6/repo_fmt_6_tests.py b/obnamlib/fmt_6/repo_fmt_6_tests.py
index e672ba68..31551bc4 100644
--- a/obnamlib/fmt_6/repo_fmt_6_tests.py
+++ b/obnamlib/fmt_6/repo_fmt_6_tests.py
@@ -26,7 +26,10 @@ class RepositoryFormat6Tests(obnamlib.RepositoryInterfaceTests):
self.tempdir = tempfile.mkdtemp()
fs = obnamlib.LocalFS(self.tempdir)
self.hooks = obnamlib.HookManager()
- obnamlib.RepositoryFormat6.setup_hooks(self.hooks)
+
+ repo_factory = obnamlib.RepositoryFactory()
+ repo_factory.setup_hooks(self.hooks)
+
self.repo = obnamlib.RepositoryFormat6(hooks=self.hooks)
self.repo.set_fs(fs)
diff --git a/obnamlib/fmt_ga/format_tests.py b/obnamlib/fmt_ga/format_tests.py
index 4d2bfb9b..0f603a70 100644
--- a/obnamlib/fmt_ga/format_tests.py
+++ b/obnamlib/fmt_ga/format_tests.py
@@ -30,8 +30,8 @@ class RepositoryFormatGATests(obnamlib.RepositoryInterfaceTests):
fs = obnamlib.LocalFS(self.tempdir)
self.hooks = obnamlib.HookManager()
- # FIXME: The following must be format 6, for now.
- obnamlib.RepositoryFormat6.setup_hooks(self.hooks)
+ repo_factory = obnamlib.RepositoryFactory()
+ repo_factory.setup_hooks(self.hooks)
self.repo = obnamlib.RepositoryFormatGA(
hooks=self.hooks,
diff --git a/obnamlib/repo_factory.py b/obnamlib/repo_factory.py
index f61cf888..8c945ba3 100644
--- a/obnamlib/repo_factory.py
+++ b/obnamlib/repo_factory.py
@@ -58,6 +58,12 @@ class RepositoryFactory(object):
def setup_hooks(self, hooks): # pragma: no cover
'''Create all repository related hooks.'''
+ # Create hooks that are independent of repository format.
+ hooks.new('repository-toplevel-init')
+ hooks.new_filter('repository-data')
+ hooks.new('repository-add-client')
+
+ # Ask each repository format to create its own hooks.
for impl in self._implementations:
impl.setup_hooks(hooks)