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

Unified Diff: PRESUBMIT.py

Issue 149503005: Change actions.txt to actions.xml (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delay file loading to until it's needed. Created 6 years, 10 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 | tools/metrics/actions/OWNERS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 1e6526f26ea9c9dca0f46179f948e5a14216afed..ec62cb399587394469bb6bbcf450f080c0aa0d2f 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1014,28 +1014,33 @@ def _CheckCygwinShell(input_api, output_api):
def _CheckUserActionUpdate(input_api, output_api):
"""Checks if any new user action has been added."""
- if any('chromeactions.txt' == input_api.os_path.basename(f) for f in
+ if any('actions.xml' == input_api.os_path.basename(f) for f in
input_api.LocalPaths()):
- # If chromeactions.txt is already included in the changelist, the PRESUBMIT
- # for chromeactions.txt will do a more complete presubmit check.
+ # If actions.xml is already included in the changelist, the PRESUBMIT
+ # for actions.xml will do a more complete presubmit check.
return []
- with open('tools/metrics/actions/chromeactions.txt') as f:
- current_actions = f.read()
-
file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm'))
action_re = r'[^a-zA-Z]UserMetricsAction\("([^"]*)'
for f in input_api.AffectedFiles(file_filter=file_filter):
for line_num, line in f.ChangedContents():
match = input_api.re.search(action_re, line)
if match:
+ # Loads contents in tools/metrics/actions/actions.xml to memory. It's
+ # loaded only once.
+ try:
+ current_actions
Alexei Svitkine (slow) 2014/03/05 18:23:36 Instead, can you put this above the loop: current
Jói 2014/03/06 12:46:49 +1
yiyaoliu 2014/03/06 14:32:46 Done.
+ except NameError: # Variable current_actions is not defined.
+ with open('tools/metrics/actions/actions.xml') as actions_f:
+ current_actions = actions_f.read()
+ # Search for the matched user action name in |current_actions|.
for action_name in match.groups():
- name_pattern = r'\t%s\n' % action_name
- if name_pattern not in current_actions:
+ action = 'name="{0}"'.format(action_name)
+ if action not in current_actions:
return [output_api.PresubmitPromptWarning(
'File %s line %d: %s is missing in '
- 'tools/metrics/actions/chromeactions.txt. Please run '
- 'tools/metrics/actions/extract_actions.py --hash to update.'
+ 'tools/metrics/actions/actions.xml. Please run '
+ 'tools/metrics/actions/extract_actions.py to update.'
% (f.LocalPath(), line_num, action_name))]
return []
« no previous file with comments | « no previous file | tools/metrics/actions/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698