[MERGE] Fix a case of look before you leap in knit.py
Robert Collins
robertc at robertcollins.net
Wed Aug 22 09:03:24 BST 2007
This removes a spurious lookup in _get_component_maps in favour of
raising in get_method when a version_id is not present. No explicit
tests changes, but get_method is currently not a public interface
anyway; and there are explicit tests for the methods that depend on
get_method.
-Rob
=== modified file 'bzrlib/knit.py'
--- bzrlib/knit.py 2007-08-22 00:00:26 +0000
+++ bzrlib/knit.py 2007-08-22 07:50:19 +0000
@@ -877,9 +877,6 @@
the requested versions and content_map contains the KnitContents.
Both dicts take version_ids as their keys.
"""
- for version_id in version_ids:
- if not self.has_version(version_id):
- raise RevisionNotPresent(version_id, self.filename)
record_map = self._get_record_map(version_ids)
text_map = {}
@@ -1321,7 +1318,10 @@
def get_method(self, version_id):
"""Return compression method of specified version."""
- options = self._cache[version_id][1]
+ try:
+ options = self._cache[version_id][1]
+ except KeyError:
+ raise RevisionNotPresent(version_id, self._filename)
if 'fulltext' in options:
return 'fulltext'
else:
@@ -1560,7 +1560,10 @@
return 'fulltext'
def _get_node(self, version_id):
- return list(self._get_entries(self._version_ids_to_keys([version_id])))[0]
+ try:
+ return list(self._get_entries(self._version_ids_to_keys([version_id])))[0]
+ except IndexError:
+ raise RevisionNotPresent(version_id, self)
def get_options(self, version_id):
"""Return a string represention options.
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070822/bc0300f4/attachment.pgp
More information about the bazaar
mailing list