Rev 1806: Avoid writing to cache file during tests, since we run out of fds. in file:///data/jelmer/bzr-svn/trunk/

Jelmer Vernooij jelmer at samba.org
Thu Sep 4 16:47:05 BST 2008


At file:///data/jelmer/bzr-svn/trunk/

------------------------------------------------------------
revno: 1806
revision-id: jelmer at samba.org-20080904154701-jvb1fcryb93unbn7
parent: jelmer at samba.org-20080904152313-u1106gusjwpl4rlu
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Thu 2008-09-04 17:47:01 +0200
message:
  Avoid writing to cache file during tests, since we run out of fds.
modified:
  cache.py                       cache.py-20070520185908-qbtlcet08bllgs0f-1
  convert.py                     svn2bzr.py-20051018015439-cb4563bff29e632d
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/__init__.py              __init__.py-20060508151940-e9f4d914801a2535
=== modified file 'cache.py'
--- a/cache.py	2008-08-30 22:02:23 +0000
+++ b/cache.py	2008-09-04 15:47:01 +0000
@@ -83,6 +83,7 @@
             'module')
     raise bzrlib.errors.BzrError("missing sqlite library")
 
+connect_cachefile = sqlite3.connect
 
 class CacheTable(object):
     """Simple base class for SQLite-based caches."""

=== modified file 'convert.py'
--- a/convert.py	2008-09-04 10:15:15 +0000
+++ b/convert.py	2008-09-04 15:47:01 +0000
@@ -104,11 +104,14 @@
     else:
         file = open(dumpfile)
     try:
-        r.load_fs(file, StringIO(), repos.LOAD_UUID_DEFAULT)
-    except SubversionException, (_, num):
-        if num == ERR_STREAM_MALFORMED_DATA:
-            raise NotDumpFile(dumpfile)
-        raise
+        try:
+            r.load_fs(file, StringIO(), repos.LOAD_UUID_DEFAULT)
+        except SubversionException, (_, num):
+            if num == ERR_STREAM_MALFORMED_DATA:
+                raise NotDumpFile(dumpfile)
+            raise
+    finally:
+        file.close()
     return r
 
 

=== modified file 'repository.py'
--- a/repository.py	2008-09-04 11:47:09 +0000
+++ b/repository.py	2008-09-04 15:47:01 +0000
@@ -32,9 +32,8 @@
 from itertools import chain
 import os
 
-from bzrlib.plugins.svn import changes, core, errors, logwalker, properties, revmeta
+from bzrlib.plugins.svn import cache, changes, core, errors, logwalker, properties, revmeta
 from bzrlib.plugins.svn.branchprops import PathPropertyProvider
-from bzrlib.plugins.svn.cache import create_cache_dir, sqlite3
 from bzrlib.plugins.svn.changes import changes_path, find_prev_location
 from bzrlib.plugins.svn.config import SvnRepositoryConfig
 from bzrlib.plugins.svn.core import SubversionException
@@ -120,13 +119,13 @@
         self._real_parents_provider = self
         self._cached_tags = {}
 
-        cache = self.get_config().get_use_cache()
+        use_cache = self.get_config().get_use_cache()
 
-        if cache:
+        if use_cache:
             cache_dir = self.create_cache_dir()
             cache_file = os.path.join(cache_dir, 'cache-v%d' % CACHE_DB_VERSION)
             if not cachedbs.has_key(cache_file):
-                cachedbs[cache_file] = sqlite3.connect(cache_file.encode(osutils._fs_enc))
+                cachedbs[cache_file] = cache.connect_cachefile(cache_file)
             self.cachedb = cachedbs[cache_file]
             self._log = logwalker.CachingLogWalker(self._log, cache_db=self.cachedb)
             cachedir_transport = get_transport(cache_dir)
@@ -319,7 +318,7 @@
         return '%s(%r)' % (self.__class__.__name__, self.base)
 
     def create_cache_dir(self):
-        cache_dir = create_cache_dir()
+        cache_dir = cache.create_cache_dir()
         dir = os.path.join(cache_dir, self.uuid)
         if not os.path.exists(dir):
             info("Initialising Subversion metadata cache in %s" % dir)

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2008-09-04 06:14:53 +0000
+++ b/tests/__init__.py	2008-09-04 15:47:01 +0000
@@ -28,7 +28,7 @@
 from bzrlib.trace import mutter
 from bzrlib.workingtree import WorkingTree
 
-from bzrlib.plugins.svn import properties, ra, repos
+from bzrlib.plugins.svn import cache, properties, ra, repos
 from bzrlib.plugins.svn.delta import send_stream
 from bzrlib.plugins.svn.client import Client
 from bzrlib.plugins.svn.ra import Auth, RemoteAccess
@@ -136,8 +136,14 @@
                                      ra.get_ssl_client_cert_pw_file_provider(),
                                      ra.get_ssl_server_trust_file_provider()])
         self.client_ctx.log_msg_func = self.log_message_func
+        self._old_connect_cachefile = cache.connect_cachefile
+        cache.connect_cachefile = lambda path: cache.sqlite3.connect(":memory:")
         #self.client_ctx.notify_func = lambda err: mutter("Error: %s" % err)
 
+    def tearDown(self):
+        super(SubversionTestCase, self).tearDown()
+        cache.connect_cachefile = self._old_connect_cachefile
+
     def log_message_func(self, items):
         return self.next_message
 




More information about the bazaar-commits mailing list