Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: commit_queue.py

Issue 23483019: Changes to support One-Click Revert in Commit Queue (Closed) Base URL: https://src.chromium.org/chrome/trunk/tools/commit-queue/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | context.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: commit_queue.py
===================================================================
--- commit_queue.py (revision 220012)
+++ commit_queue.py (working copy)
@@ -35,9 +35,11 @@
class OnlyIssueRietveld(rietveld.Rietveld):
"""Returns a single issue for end-to-end in prod testing."""
- def __init__(self, url, email, password, extra_headers, only_issue):
+ def __init__(self, url, email, password, extra_headers, only_issue,
+ only_revert_issue):
super(OnlyIssueRietveld, self).__init__(url, email, password, extra_headers)
self._only_issue = only_issue
+ self._only_revert_issue = only_revert_issue
def get_pending_issues(self):
"""If it's set to return a single issue, only return this one."""
@@ -45,11 +47,19 @@
return [self._only_issue]
return []
+ def get_revert_issues(self):
+ """If it's set to return a single revert issue, only return this one."""
+ if self._only_revert_issue:
+ return [self._only_revert_issue]
+ return []
+
def get_issue_properties(self, issue, messages):
"""Hacks the result to fake that the issue has the commit bit set."""
data = super(OnlyIssueRietveld, self).get_issue_properties(issue, messages)
if issue == self._only_issue:
data['commit'] = True
+ elif issue == self._only_revert_issue:
+ data['revert'] = True
return data
def set_flag(self, issue, patchset, flag, value):
@@ -59,10 +69,12 @@
class ReadOnlyRietveld(rietveld.Rietveld):
- def __init__(self, url, email, password, extra_headers, only_issue):
+ def __init__(self, url, email, password, extra_headers, only_issue,
+ only_revert_issue):
super(ReadOnlyRietveld, self).__init__(url, email, password, extra_headers)
self._only_issue = only_issue
- self._restricted = bool(only_issue)
+ self._only_revert_issue = only_revert_issue
+ self._restricted = bool(only_issue) or bool(only_revert_issue)
def _send(self, request_path, **kwargs):
"""Ignore all post requests."""
@@ -79,11 +91,21 @@
return []
return super(ReadOnlyRietveld, self).get_pending_issues()
+ def get_revert_issues(self):
+ """If it's set to return a single issue, only return this one."""
+ if self._restricted:
+ if self._only_revert_issue:
+ return [self._only_revert_issue]
+ return []
+ return super(ReadOnlyRietveld, self).get_revert_issues()
+
def get_issue_properties(self, issue, messages):
"""Hacks the result to fake that the issue has the commit bit set."""
data = super(ReadOnlyRietveld, self).get_issue_properties(issue, messages)
if issue == self._only_issue:
data['commit'] = True
+ elif issue == self._only_revert_issue:
+ data['revert'] = True
return data
def set_flag(self, issue, patchset, flag, value):
@@ -165,7 +187,8 @@
default=True,
help='Run for real instead of dry-run mode which is the default. '
'WARNING: while the CQ won\'t touch rietveld in dry-run mode, the '
- 'Try Server will. So it is recommended to use --only-issue')
+ 'Try Server will. So it is recommended to use --only-issue or '
+ '--only-revert-issue')
parser.add_option(
'--only-issue',
type='int',
@@ -173,6 +196,12 @@
'will fake that the issue has the CQ bit set, so only try with an '
'issue you don\'t mind about.')
parser.add_option(
+ '--only-revert-issue',
+ type='int',
+ help='Limits to a single issue to revert. Useful for live testing; '
+ 'WARNING: it will fake that the issue has the revert bit set, so only '
+ 'try with an issue you don\'t mind about.')
+ parser.add_option(
'--fake',
action='store_true',
help='Run with a fake checkout to speed up testing')
@@ -222,6 +251,10 @@
print(
'Using read-only Rietveld; using only issue %d' %
options.only_issue)
+ elif options.only_revert_issue:
+ print(
+ 'Using read-only Rietveld; using only issue %d to revert' %
+ options.only_revert_issue)
else:
print('Using read-only Rietveld')
# Make sure rietveld is not modified.
@@ -230,18 +263,23 @@
options.user,
gaia_creds.get(options.user),
None,
- options.only_issue)
+ options.only_issue,
+ options.only_revert_issue)
else:
AlertOnUncleanCheckout()
print('WARNING: The Commit Queue is going to commit stuff')
- if options.only_issue:
- print('Using only issue %d' % options.only_issue)
+ if options.only_issue or options.only_revert_issue:
+ if options.only_issue:
+ print('Using only issue %d' % options.only_issue)
+ else:
+ print('Using only issue %d to revert' % options.only_revert_issue)
rietveld_obj = OnlyIssueRietveld(
url,
options.user,
gaia_creds.get(options.user),
None,
- options.only_issue)
+ options.only_issue,
+ options.only_revert_issue)
else:
rietveld_obj = rietveld.Rietveld(
url,
@@ -307,9 +345,9 @@
# size.
pc.save(db_path)
- # More than a second to wait and due to sync.
+ # More than a 2 seconds to wait and due to sync.
now = time.time()
- if (next_loop - now) >= 1 and (next_sync - now) <= 0:
+ if (next_loop - now) >= 2 and (next_sync - now) <= 0:
if sys.stdout.isatty():
sys.stdout.write('Syncing while waiting \r')
sys.stdout.flush()
« no previous file with comments | « no previous file | context.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698