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

Unified Diff: components/sync/PRESUBMIT.py

Issue 2426613003: [sync] Add store version to model type store backend (Closed)
Patch Set: [sync] Add store version to model type store backend Created 4 years, 2 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 | components/sync/PRESUBMIT_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/PRESUBMIT.py
diff --git a/components/sync/PRESUBMIT.py b/components/sync/PRESUBMIT.py
index 329c7e4e82eafb4e441632ae67e178ac60c805ba..25dcce29a331aec6c4c75137c3ac122eb75c41cd 100644
--- a/components/sync/PRESUBMIT.py
+++ b/components/sync/PRESUBMIT.py
@@ -25,6 +25,12 @@ GRANDFATHERED_MODEL_TYPES = [
'PROXY_TABS', # Doesn't have a root tag or notification type.
'NIGORI'] # Model type string is 'encryption keys'.
+# Root tags are used as prefixes when creating storage keys, so certain strings
+# are blacklisted in order to prevent prefix collision.
+BLACKLISTED_ROOT_TAGS = [
+ '_mts_schema_descriptor'
+]
+
# Number of distinct fields in a map entry; used to create
# sets that check for uniqueness.
MAP_ENTRY_FIELD_COUNT = 6
@@ -113,6 +119,7 @@ def CheckModelTypeInfoMap(input_api, output_api, model_type_file):
entry_problems.extend(
CheckNotificationTypeMatchesProtoMessageName(
output_api, map_entry, proto_field_definitions))
+ entry_problems.extend(CheckRootTagNotInBlackList(output_api, map_entry))
if map_entry.model_type not in GRANDFATHERED_MODEL_TYPES:
entry_problems.extend(
@@ -343,6 +350,20 @@ def CheckRootTagMatchesModelType(output_api, map_entry):
map_entry.affected_lines)]
return []
+def CheckRootTagNotInBlackList(output_api, map_entry):
+ """ Checks that map_entry's root isn't a blacklisted string.
+ Args:
+ output_api: presubmit_support OutputAPI instance
+ map_entry: ModelTypeEnumEntry object to check
+ Returns:
+ A list of PresubmitError objects for each violation
+ """
+ if map_entry.root_tag in BLACKLISTED_ROOT_TAGS:
+ return [FormatPresubmitError(
+ output_api,'root tag "%s" is a blacklisted root tag'
+ % (map_entry.root_tag), map_entry.affected_lines)]
+ return []
+
def FieldNumberToPrototypeString(field_number):
"""Converts a field number enum reference to an EntitySpecifics string.
« no previous file with comments | « no previous file | components/sync/PRESUBMIT_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698