[patch] warn on deprecated formats
mbp at canonical.com
mbp at canonical.com
Fri Aug 11 11:08:09 BST 2006
Here's an updated version that
- adds a test
- turns off the warning during testing to avoid disturbing black box
tests
The second is probably not in quite the right spot - I'm not sure off
hand what is the best place to put test setup with global scope like
this.
--
Martin
-------------- next part --------------
=== modified file 'bzrlib/repository.py'
--- bzrlib/repository.py 2006-08-11 09:10:47 +0000
+++ bzrlib/repository.py 2006-08-11 10:02:55 +0000
@@ -45,6 +45,10 @@
from bzrlib.weave import WeaveFile
+# Old formats display a warning, but only once
+_deprecation_warning_done = False
+
+
class Repository(object):
"""Repository holding history for one or more branches.
@@ -682,6 +686,10 @@
return result
def _warn_if_deprecated(self):
+ global _deprecation_warning_done
+ if _deprecation_warning_done:
+ return
+ _deprecation_warning_done = True
warning("Format %s for %s is deprecated - please use 'bzr upgrade' to get better performance"
% (self._format, self.bzrdir.transport.base))
=== modified file 'bzrlib/tests/__init__.py'
--- bzrlib/tests/__init__.py 2006-07-31 16:29:15 +0000
+++ bzrlib/tests/__init__.py 2006-08-11 09:42:28 +0000
@@ -1226,6 +1226,12 @@
test_suite_factory=None,
lsprof_timed=None):
"""Run the whole test suite under the enhanced runner"""
+ # XXX: Very ugly way to do this...
+ # Disable warning about old formats because we don't want it to disturb
+ # any blackbox tests.
+ from bzrlib import repository
+ repository._deprecation_warning_done = True
+
global default_transport
if transport is None:
transport = default_transport
=== modified file 'bzrlib/tests/blackbox/test_exceptions.py'
--- bzrlib/tests/blackbox/test_exceptions.py 2006-06-15 05:49:38 +0000
+++ bzrlib/tests/blackbox/test_exceptions.py 2006-08-11 10:03:27 +0000
@@ -19,6 +19,8 @@
import os
import sys
+from bzrlib import bzrdir, repository
+
from bzrlib.tests import TestCaseInTempDir, TestCase
from bzrlib.errors import NotBranchError
@@ -35,3 +37,19 @@
# register (and unregister) it from tests that want to touch it.
#
# TODO: Some kind of test for the feature of invoking pdb
+
+
+class TestDeprecationWarning(TestCaseInTempDir):
+
+ def test_repository_deprecation_warning(self):
+ """Old formats give a warning"""
+ # the warning's normally off for testing but we reenable it
+ repository._deprecation_warning_done = False
+ try:
+ os.mkdir('foo')
+ bzrdir.BzrDirFormat5().initialize('foo')
+ out, err = self.run_bzr("status", "foo")
+ self.assertContainsRe(self._get_log(), "bzr upgrade")
+ finally:
+ repository._deprecation_warning_done = True
+
=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- bzrlib/tests/repository_implementations/__init__.py 2006-07-31 16:29:15 +0000
+++ bzrlib/tests/repository_implementations/__init__.py 2006-08-11 09:41:34 +0000
@@ -17,7 +17,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-"""BzrDir implementation tests for bzr.
+"""Repository implementation tests for bzr.
These test the conformance of all the repository variations to the expected API.
Specific tests for individual formats are in the tests/test_repository.py file
More information about the bazaar
mailing list