diff options
author | Chris Larson <chris_larson@mentor.com> | 2011-04-04 09:36:10 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-05-06 15:49:17 +0100 |
commit | 7fc020aa15d918b215575576d91160afae7f4d70 (patch) | |
tree | ed9b029c8b2dfd355396de9183517e852333612b /bitbake | |
parent | fc801b907361cfdb7e329eefac7a0c991e86c736 (diff) | |
download | poky-7fc020aa15d918b215575576d91160afae7f4d70.tar.gz |
persist_data: raise KeyError on missing elements
(Bitbake rev: a4f62433845c29f98c6a9746d5d2847bf9506ea5)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 15 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/git.py | 18 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 15 | ||||
-rw-r--r-- | bitbake/lib/bb/persist_data.py | 3 |
4 files changed, 27 insertions, 24 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index 684e83dcad..95f0d9d553 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py | |||
@@ -759,12 +759,11 @@ class Fetch(object): | |||
759 | pd = bb.persist_data.persist(d) | 759 | pd = bb.persist_data.persist(d) |
760 | revs = pd['BB_URI_HEADREVS'] | 760 | revs = pd['BB_URI_HEADREVS'] |
761 | key = self.generate_revision_key(url, ud, d) | 761 | key = self.generate_revision_key(url, ud, d) |
762 | rev = revs[key] | 762 | try: |
763 | if rev != None: | 763 | return revs[key] |
764 | return str(rev) | 764 | except KeyError: |
765 | 765 | revs[key] = rev = self._latest_revision(url, ud, d) | |
766 | revs[key] = rev = self._latest_revision(url, ud, d) | 766 | return rev |
767 | return rev | ||
768 | 767 | ||
769 | def sortable_revision(self, url, ud, d): | 768 | def sortable_revision(self, url, ud, d): |
770 | """ | 769 | """ |
@@ -778,13 +777,13 @@ class Fetch(object): | |||
778 | key = self.generate_revision_key(url, ud, d) | 777 | key = self.generate_revision_key(url, ud, d) |
779 | 778 | ||
780 | latest_rev = self._build_revision(url, ud, d) | 779 | latest_rev = self._build_revision(url, ud, d) |
781 | last_rev = localcounts[key + '_rev'] | 780 | last_rev = localcounts.get(key + '_rev') |
782 | uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False | 781 | uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False |
783 | count = None | 782 | count = None |
784 | if uselocalcount: | 783 | if uselocalcount: |
785 | count = Fetch.localcount_internal_helper(ud, d) | 784 | count = Fetch.localcount_internal_helper(ud, d) |
786 | if count is None: | 785 | if count is None: |
787 | count = localcounts[key + '_count'] | 786 | count = localcounts.get(key + '_count') |
788 | 787 | ||
789 | if last_rev == latest_rev: | 788 | if last_rev == latest_rev: |
790 | return str(count + "+" + latest_rev) | 789 | return str(count + "+" + latest_rev) |
diff --git a/bitbake/lib/bb/fetch/git.py b/bitbake/lib/bb/fetch/git.py index 6b565e3eb5..35908ca8d4 100644 --- a/bitbake/lib/bb/fetch/git.py +++ b/bitbake/lib/bb/fetch/git.py | |||
@@ -246,18 +246,20 @@ class Git(Fetch): | |||
246 | revs = persisted['BB_URI_HEADREVS'] | 246 | revs = persisted['BB_URI_HEADREVS'] |
247 | 247 | ||
248 | key = self.generate_revision_key(url, ud, d, branch=True) | 248 | key = self.generate_revision_key(url, ud, d, branch=True) |
249 | rev = revs[key] | 249 | |
250 | if rev is None: | 250 | try: |
251 | return revs[key] | ||
252 | except KeyError: | ||
251 | # Compatibility with old key format, no branch included | 253 | # Compatibility with old key format, no branch included |
252 | oldkey = self.generate_revision_key(url, ud, d, branch=False) | 254 | oldkey = self.generate_revision_key(url, ud, d, branch=False) |
253 | rev = revs[oldkey] | 255 | try: |
254 | if rev is not None: | 256 | rev = revs[oldkey] |
255 | del revs[oldkey] | 257 | except KeyError: |
256 | else: | ||
257 | rev = self._latest_revision(url, ud, d) | 258 | rev = self._latest_revision(url, ud, d) |
259 | else: | ||
260 | del revs[oldkey] | ||
258 | revs[key] = rev | 261 | revs[key] = rev |
259 | 262 | return rev | |
260 | return str(rev) | ||
261 | 263 | ||
262 | def sortable_revision(self, url, ud, d): | 264 | def sortable_revision(self, url, ud, d): |
263 | """ | 265 | """ |
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index ca0197e220..a31e26bf75 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -806,12 +806,11 @@ class FetchMethod(object): | |||
806 | pd = persist_data.persist(d) | 806 | pd = persist_data.persist(d) |
807 | revs = pd['BB_URI_HEADREVS'] | 807 | revs = pd['BB_URI_HEADREVS'] |
808 | key = self.generate_revision_key(url, ud, d, name) | 808 | key = self.generate_revision_key(url, ud, d, name) |
809 | rev = revs[key] | 809 | try: |
810 | if rev != None: | 810 | return revs[key] |
811 | return str(rev) | 811 | except KeyError: |
812 | 812 | revs[key] = rev = self._latest_revision(url, ud, d, name) | |
813 | revs[key] = rev = self._latest_revision(url, ud, d, name) | 813 | return rev |
814 | return rev | ||
815 | 814 | ||
816 | def sortable_revision(self, url, ud, d, name): | 815 | def sortable_revision(self, url, ud, d, name): |
817 | """ | 816 | """ |
@@ -825,13 +824,13 @@ class FetchMethod(object): | |||
825 | key = self.generate_revision_key(url, ud, d, name) | 824 | key = self.generate_revision_key(url, ud, d, name) |
826 | 825 | ||
827 | latest_rev = self._build_revision(url, ud, d, name) | 826 | latest_rev = self._build_revision(url, ud, d, name) |
828 | last_rev = localcounts[key + '_rev'] | 827 | last_rev = localcounts.get(key + '_rev') |
829 | uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False | 828 | uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False |
830 | count = None | 829 | count = None |
831 | if uselocalcount: | 830 | if uselocalcount: |
832 | count = FetchMethod.localcount_internal_helper(ud, d, name) | 831 | count = FetchMethod.localcount_internal_helper(ud, d, name) |
833 | if count is None: | 832 | if count is None: |
834 | count = localcounts[key + '_count'] or "0" | 833 | count = localcounts.get(key + '_count') or "0" |
835 | 834 | ||
836 | if last_rev == latest_rev: | 835 | if last_rev == latest_rev: |
837 | return str(count + "+" + latest_rev) | 836 | return str(count + "+" + latest_rev) |
diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py index f51a42efd2..eae64cf792 100644 --- a/bitbake/lib/bb/persist_data.py +++ b/bitbake/lib/bb/persist_data.py | |||
@@ -69,8 +69,11 @@ class SQLTable(collections.MutableMapping): | |||
69 | self.table, [key]) | 69 | self.table, [key]) |
70 | for row in data: | 70 | for row in data: |
71 | return row[1] | 71 | return row[1] |
72 | raise KeyError(key) | ||
72 | 73 | ||
73 | def __delitem__(self, key): | 74 | def __delitem__(self, key): |
75 | if key not in self: | ||
76 | raise KeyError(key) | ||
74 | self._execute("DELETE from %s where key=?;" % self.table, [key]) | 77 | self._execute("DELETE from %s where key=?;" % self.table, [key]) |
75 | 78 | ||
76 | def __setitem__(self, key, value): | 79 | def __setitem__(self, key, value): |