diff options
author | W. Trevor King <wking@tremily.us> | 2012-08-29 14:54:33 -0400 |
---|---|---|
committer | W. Trevor King <wking@tremily.us> | 2012-08-29 23:29:56 -0400 |
commit | 2950a115fb106ae73b87f87dc4865156d9311f8e (patch) | |
tree | b989a4bae4e890d0668bd17adbbfbb8d07c00544 | |
parent | 22a4d1c4d953013c64c029374f2e627289591695 (diff) | |
download | bugseverywhere-2950a115fb106ae73b87f87dc4865156d9311f8e.tar.gz |
bugdir: add `update` argument to BugDir.append().
This avoids a deepcopy error where the BugDir tries to update before
the Bug has had it's uuid assigned:
Traceback (most recent call last):
...
File ".../libbe/command/merge.py", line 168, in _run
newCommTree = copy.deepcopy(bugB.comment_root)
File "/usr/lib64/python2.7/copy.py", line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
...
File "/usr/lib64/python2.7/copy.py", line 352, in _reconstruct
y.append(item)
File ".../libbe/bugdir.py", line 263, in append
self._bug_map_gen()
File ".../libbe/bugdir.py", line 152, in _bug_map_gen
map[bug.uuid] = bug
AttributeError: 'Bug' object has no attribute 'uuid'
-rw-r--r-- | libbe/bugdir.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libbe/bugdir.py b/libbe/bugdir.py index 0399a82..a3a388c 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -255,14 +255,16 @@ class BugDir (list, settings_object.SavedSettingsObject): def new_bug(self, summary=None, _uuid=None): bg = bug.Bug(bugdir=self, uuid=_uuid, summary=summary, from_storage=False) - self.append(bg) + self.append(bg, update=True) return bg - def append(self, bug): + def append(self, bug, update=False): super(BugDir, self).append(bug) - self._bug_map_gen() - if hasattr(self, '_uuids_cache') and not bug.uuid in self._uuids_cache: - self._uuids_cache.add(bug.uuid) + if update: + self._bug_map_gen() + if (hasattr(self, '_uuids_cache') and + not bug.uuid in self._uuids_cache): + self._uuids_cache.add(bug.uuid) def remove_bug(self, bug): if hasattr(self, '_uuids_cache') and bug.uuid in self._uuids_cache: @@ -443,7 +445,7 @@ class BugDir (list, settings_object.SavedSettingsObject): bg = bug.Bug(bugdir=self) bg.from_xml( child, preserve_uuids=preserve_uuids, verbose=verbose) - self.append(bg) + self.append(bg, update=True) continue elif child.tag in tags: if child.text == None or len(child.text) == 0: |