Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 """Defines class Rietveld to easily access a rietveld instance. | 5 """Defines class Rietveld to easily access a rietveld instance. |
| 6 | 6 |
| 7 Security implications: | 7 Security implications: |
| 8 | 8 |
| 9 The following hypothesis are made: | 9 The following hypothesis are made: |
| 10 - Rietveld enforces: | 10 - Rietveld enforces: |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 if not messages: | 438 if not messages: |
| 439 # Assumes self._lookup uses deepcopy. | 439 # Assumes self._lookup uses deepcopy. |
| 440 del data['messages'] | 440 del data['messages'] |
| 441 return data | 441 return data |
| 442 | 442 |
| 443 def get_patchset_properties(self, issue, patchset): | 443 def get_patchset_properties(self, issue, patchset): |
| 444 return self._lookup( | 444 return self._lookup( |
| 445 'get_patchset_properties', | 445 'get_patchset_properties', |
| 446 (issue, patchset), | 446 (issue, patchset), |
| 447 super(CachingRietveld, self).get_patchset_properties) | 447 super(CachingRietveld, self).get_patchset_properties) |
| 448 | |
| 449 | |
| 450 class ReadOnlyRietveld(Rietveld): | |
|
Isaac (away)
2013/09/14 07:48:08
I think maybe this should not extend rietveld -- t
Paweł Hajdan Jr.
2013/09/16 14:33:52
Sounds good to me - I'll probably do that on Thurs
M-A Ruel
2013/09/16 14:53:05
Technically, you could just zap POST and be fine.
| |
| 451 """Only provides read operations, and simulates writes locally.""" | |
| 452 | |
| 453 # Dictionary of local changes, indexed by issue number as int. | |
| 454 _local_changes = {} | |
| 455 | |
| 456 def __init__(self, *args, **kwargs): | |
| 457 super(ReadOnlyRietveld, self).__init__(*args, **kwargs) | |
| 458 | |
| 459 def close_issue(self, issue): | |
| 460 logging.info('ReadOnlyRietveld: closing issue %d' % issue) | |
| 461 ReadOnlyRietveld._local_changes.setdefault(issue, {})['closed'] = True | |
| 462 | |
| 463 def get_issue_properties(self, issue, messages): | |
| 464 data = super(ReadOnlyRietveld, self).get_issue_properties(issue, messages) | |
| 465 data.update(ReadOnlyRietveld._local_changes.get(issue, {})) | |
| 466 return data | |
| 467 | |
| 468 def update_description(self, issue, description): | |
| 469 logging.info('ReadOnlyRietveld: new description for issue %d: %s' % | |
| 470 (issue, description)) | |
| 471 | |
| 472 def add_comment(self, issue, message, add_as_reviewer=False): | |
| 473 logging.info('ReadOnlyRietveld: posting comment "%s" to issue %d' % | |
| 474 (message, issue)) | |
| 475 | |
| 476 def set_flag(self, issue, patchset, flag, value): | |
| 477 logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % | |
| 478 (flag, value, issue)) | |
| 479 ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value | |
| 480 | |
| 481 def trigger_try_jobs( | |
| 482 self, issue, patchset, reason, clobber, revision, builders_and_tests): | |
| 483 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | |
| 484 (builders_and_tests, issue)) | |
| OLD | NEW |