aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2010-01-25 07:54:37 -0500
committerW. Trevor King <wking@drexel.edu>2010-01-25 07:54:37 -0500
commit9518e1a98e642175a2de74a8d6e54126b9399210 (patch)
treeb4032c74b2d2f55d6657df4b157978c10426068e
parenta87dde3eab86554f0ff70fb53d142ca7bca28b55 (diff)
downloadbugseverywhere-9518e1a98e642175a2de74a8d6e54126b9399210.tar.gz
Rework fix for #bea/8fc# : be crashes on outdated id-cache
Now we re-run CachedPathID.init in an 'append' mode, rather than starting over from scratch. This avoids problems like ====================================================================== ERROR: Should not be able to add children to non-directories. ---------------------------------------------------------------------- Traceback (most recent call last): File ".../be.wtk/libbe/storage/base.py", line 680, in test_add_invalid_directory self.s.add('child', 'parent', directory=False) File ".../be.wtk/libbe/storage/base.py", line 248, in add self._add(id, *args, **kwargs) File ".../be.wtk/libbe/storage/vcs/base.py", line 737, in _add path = self._cached_path_id.add_id(id, parent) File ".../be.wtk/libbe/storage/vcs/base.py", line 267, in add_id parent_path = self.path(parent, relpath=True) File ".../be.wtk/libbe/storage/vcs/base.py", line 246, in path raise InvalidID(uuid) InvalidID: parent in revision None and similar.
-rw-r--r--libbe/storage/vcs/base.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/libbe/storage/vcs/base.py b/libbe/storage/vcs/base.py
index 2269424..8335cfa 100644
--- a/libbe/storage/vcs/base.py
+++ b/libbe/storage/vcs/base.py
@@ -182,13 +182,16 @@ class CachedPathID (object):
self._cache_path = os.path.join(
self._root, self._spacer_dirs[0], 'id-cache')
- def init(self, verbose=True):
+ def init(self, verbose=True, cache=None):
"""
Create cache file for an existing .be directory.
File if multiple lines of the form:
UUID\tPATH
"""
- self._cache = {}
+ if cache == None:
+ self._cache = {}
+ else:
+ self._cache = cache
spaced_root = os.path.join(self._root, self._spacer_dirs[0])
for dirpath, dirnames, filenames in os.walk(spaced_root):
if dirpath == spaced_root:
@@ -202,8 +205,10 @@ class CachedPathID (object):
self._cache[id] = relpath
except InvalidPath:
pass
- self._changed = True
- self.disconnect()
+ if self._cache != cache:
+ self._changed = True
+ if cache == None:
+ self.disconnect()
def destroy(self):
if os.path.exists(self._cache_path):
@@ -239,9 +244,7 @@ class CachedPathID (object):
else:
extra = fields[1:]
if uuid not in self._cache:
- self.disconnect()
- self.init(verbose=False)
- self.connect()
+ self.init(verbose=False, cache=self._cache)
if uuid not in self._cache:
raise InvalidID(uuid)
if relpath == True: