| OLD | NEW |
| 1 # Copyright 2008 Google Inc. | 1 # Copyright 2008 Google Inc. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 463 |
| 464 Args: | 464 Args: |
| 465 patch: The file to compare. | 465 patch: The file to compare. |
| 466 patchset_id: The file's patchset's key id. | 466 patchset_id: The file's patchset's key id. |
| 467 patchsets: A list of existing patchsets. | 467 patchsets: A list of existing patchsets. |
| 468 | 468 |
| 469 Returns: | 469 Returns: |
| 470 A list of patchset ids. | 470 A list of patchset ids. |
| 471 """ | 471 """ |
| 472 delta = [] | 472 delta = [] |
| 473 if patch.no_base_file: | |
| 474 return delta | |
| 475 for other in patchsets: | 473 for other in patchsets: |
| 476 if patchset_id == other.key.id(): | 474 if patchset_id == other.key.id(): |
| 477 break | 475 break |
| 478 if not hasattr(other, 'parsed_patches'): | 476 if not hasattr(other, 'parsed_patches'): |
| 479 other.parsed_patches = None # cache variable for already parsed patches | 477 other.parsed_patches = None # cache variable for already parsed patches |
| 480 if other.data or other.parsed_patches: | 478 if other.data or other.parsed_patches: |
| 481 # Loading all the Patch entities in every PatchSet takes too long | 479 # Loading all the Patch entities in every PatchSet takes too long |
| 482 # (DeadLineExceeded) and consumes a lot of memory (MemoryError) so instead | 480 # (DeadLineExceeded) and consumes a lot of memory (MemoryError) so instead |
| 483 # just parse the patchset's data. Note we can only do this if the | 481 # just parse the patchset's data. Note we can only do this if the |
| 484 # patchset was small enough to fit in the data property. | 482 # patchset was small enough to fit in the data property. |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 Raises: | 1014 Raises: |
| 1017 FetchError: If there was a problem fetching it. | 1015 FetchError: If there was a problem fetching it. |
| 1018 """ | 1016 """ |
| 1019 try: | 1017 try: |
| 1020 if self.content_key is not None: | 1018 if self.content_key is not None: |
| 1021 content = self.content_key.get() | 1019 content = self.content_key.get() |
| 1022 if content.is_bad: | 1020 if content.is_bad: |
| 1023 msg = 'Bad content. Try to upload again.' | 1021 msg = 'Bad content. Try to upload again.' |
| 1024 logging.warn('Patch.get_content: %s', msg) | 1022 logging.warn('Patch.get_content: %s', msg) |
| 1025 raise FetchError(msg) | 1023 raise FetchError(msg) |
| 1024 if content.file_too_large: |
| 1025 msg = 'File too large.' |
| 1026 logging.warn('Patch.get_content: %s', msg) |
| 1027 raise FetchError(msg) |
| 1026 if content.is_uploaded and content.text == None: | 1028 if content.is_uploaded and content.text == None: |
| 1027 msg = 'Upload in progress.' | 1029 msg = 'Upload in progress.' |
| 1028 logging.warn('Patch.get_content: %s', msg) | 1030 logging.warn('Patch.get_content: %s', msg) |
| 1029 raise FetchError(msg) | 1031 raise FetchError(msg) |
| 1030 else: | 1032 else: |
| 1031 return content | 1033 return content |
| 1032 except db.Error: | 1034 except db.Error: |
| 1033 # This may happen when a Content entity was deleted behind our back. | 1035 # This may happen when a Content entity was deleted behind our back. |
| 1034 self.content_key = None | 1036 self.content_key = None |
| 1035 | 1037 |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 out.issues = sum((i.issues for i in items), []) | 1828 out.issues = sum((i.issues for i in items), []) |
| 1827 out.latencies = sum((i.latencies for i in items), []) | 1829 out.latencies = sum((i.latencies for i in items), []) |
| 1828 out.lgtms = sum((i.lgtms for i in items), []) | 1830 out.lgtms = sum((i.lgtms for i in items), []) |
| 1829 out.review_types = sum((i.review_types for i in items), []) | 1831 out.review_types = sum((i.review_types for i in items), []) |
| 1830 out.score = compute_score(out) | 1832 out.score = compute_score(out) |
| 1831 return ( | 1833 return ( |
| 1832 prev_issues != out.issues or | 1834 prev_issues != out.issues or |
| 1833 prev_latencies != out.latencies or | 1835 prev_latencies != out.latencies or |
| 1834 prev_lgtms != out.lgtms or | 1836 prev_lgtms != out.lgtms or |
| 1835 prev_review_types != out.review_types) | 1837 prev_review_types != out.review_types) |
| OLD | NEW |