aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/base.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-08 08:54:50 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-08 08:54:50 -0500
commit44b4e3f8b6405d0e1e0ebf6cb526ab62cdbbdb25 (patch)
tree213e8842f2edbede6e31af409200842ff5ad940c /libbe/storage/base.py
parent7a8b1223fac612ef8b3dffd0e4c6832a97aa222d (diff)
downloadbugseverywhere-44b4e3f8b6405d0e1e0ebf6cb526ab62cdbbdb25.tar.gz
Transitioned bugdir.py to new storage format.
Diffstat (limited to 'libbe/storage/base.py')
-rw-r--r--libbe/storage/base.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/libbe/storage/base.py b/libbe/storage/base.py
index 3526462..eb2b94c 100644
--- a/libbe/storage/base.py
+++ b/libbe/storage/base.py
@@ -33,11 +33,11 @@ class InvalidRevision (KeyError):
class NotWriteable (NotSupported):
def __init__(self, msg):
- NotSupported.__init__('write', msg)
+ NotSupported.__init__(self, 'write', msg)
class NotReadable (NotSupported):
def __init__(self, msg):
- NotSupported.__init__('read', msg)
+ NotSupported.__init__(self, 'read', msg)
class EmptyCommit(Exception):
def __init__(self):
@@ -182,7 +182,11 @@ class Storage (object):
"""Add an entry"""
if self.is_writeable() == False:
raise NotWriteable('Cannot add entry to unwriteable storage.')
- self._add(*args, **kwargs)
+ try: # Maybe we've already added that id?
+ self.get(id)
+ pass # yup, no need to add another
+ except InvalidID:
+ self._add(*args, **kwargs)
def _add(self, id, parent=None):
if parent == None:
@@ -438,6 +442,15 @@ if TESTING == True:
def test_add_rooted(self):
"""
+ Adding entries with the same ID should not increase the number of children.
+ """
+ for i in range(10):
+ self.s.add('some id')
+ s = sorted(self.s.children())
+ self.failUnless(s == ['some id'], s)
+
+ def test_add_rooted(self):
+ """
Adding entries should increase the number of children (rooted).
"""
ids = []