LEFT | RIGHT |
(no file at all) | |
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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 self.key().id(), delta, patchset_id_mapping) | 432 self.key().id(), delta, patchset_id_mapping) |
433 if not patch.is_binary: | 433 if not patch.is_binary: |
434 patchset.total_added += patch.num_added | 434 patchset.total_added += patch.num_added |
435 patchset.total_removed += patch.num_removed | 435 patchset.total_removed += patch.num_removed |
436 return patchsets | 436 return patchsets |
437 finally: | 437 finally: |
438 # Reduce memory usage (see above comment). | 438 # Reduce memory usage (see above comment). |
439 for patchset in patchsets: | 439 for patchset in patchsets: |
440 patchset.parsed_patches = None | 440 patchset.parsed_patches = None |
441 | 441 |
| 442 def to_dict(self, include_messages=False): |
| 443 """Converts an issue into a dict.""" |
| 444 values = { |
| 445 'owner': self.owner.email(), |
| 446 'owner_email': self.owner.email(), |
| 447 'modified': str(self.modified), |
| 448 'created': str(self.created), |
| 449 'closed': self.closed, |
| 450 'cc': self.cc, |
| 451 'reviewers': self.reviewers, |
| 452 'patchsets': [p.key().id() for p in self.patchsets], |
| 453 'description': self.description, |
| 454 'subject': self.subject, |
| 455 'issue': self.key().id(), |
| 456 'base_url': self.base, |
| 457 'private': self.private, |
| 458 'commit': self.commit, |
| 459 } |
| 460 if include_messages: |
| 461 values['messages'] = sorted( |
| 462 ({ |
| 463 'sender': m.sender, |
| 464 'recipients': m.recipients, |
| 465 'date': str(m.date), |
| 466 'text': m.text, |
| 467 'approval': m.approval, |
| 468 'disapproval': m.disapproval, |
| 469 } |
| 470 for m in Message.gql('WHERE ANCESTOR IS :1', self)), |
| 471 key=lambda x: x['date']) |
| 472 return values |
| 473 |
442 | 474 |
443 def _calculate_delta(patch, patchset_id, patchsets): | 475 def _calculate_delta(patch, patchset_id, patchsets): |
444 """Calculates which files in earlier patchsets this file differs from. | 476 """Calculates which files in earlier patchsets this file differs from. |
445 | 477 |
446 Args: | 478 Args: |
447 patch: The file to compare. | 479 patch: The file to compare. |
448 patchset_id: The file's patchset's key id. | 480 patchset_id: The file's patchset's key id. |
449 patchsets: A list of existing patchsets. | 481 patchsets: A list of existing patchsets. |
450 | 482 |
451 Returns: | 483 Returns: |
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 out.issues = sum((i.issues for i in items), []) | 1826 out.issues = sum((i.issues for i in items), []) |
1795 out.latencies = sum((i.latencies for i in items), []) | 1827 out.latencies = sum((i.latencies for i in items), []) |
1796 out.lgtms = sum((i.lgtms for i in items), []) | 1828 out.lgtms = sum((i.lgtms for i in items), []) |
1797 out.review_types = sum((i.review_types for i in items), []) | 1829 out.review_types = sum((i.review_types for i in items), []) |
1798 out.score = compute_score(out) | 1830 out.score = compute_score(out) |
1799 return ( | 1831 return ( |
1800 prev_issues != out.issues or | 1832 prev_issues != out.issues or |
1801 prev_latencies != out.latencies or | 1833 prev_latencies != out.latencies or |
1802 prev_lgtms != out.lgtms or | 1834 prev_lgtms != out.lgtms or |
1803 prev_review_types != out.review_types) | 1835 prev_review_types != out.review_types) |
LEFT | RIGHT |