Check deprecation of preferences
It's a common mistake that developers just remove Register...Pref()
calls for preferences they don't need anymore. If they do this, the
preference stays in the prefs files on disk for ever. A proper approach
is to first ClearPref() the preference for some releases and then to
remove the code.
This CL introduces a presubmit warning if we detect that a
Register...Pref() call is removed from a non-unittest.
Bug: 1153014
Change-Id: If8f19933de039553ef47e0ddce12eb194df45ce1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560205
Commit-Queue: Dominic Battré <[email protected]>
Reviewed-by: Jochen Eisinger <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Reviewed-by: Dominic Battré <[email protected]>
Cr-Commit-Position: refs/heads/master@{#833730}
diff --git a/PRESUBMIT_test_mocks.py b/PRESUBMIT_test_mocks.py
index 0a9e5a5..f8143ae 100644
--- a/PRESUBMIT_test_mocks.py
+++ b/PRESUBMIT_test_mocks.py
@@ -179,16 +179,21 @@
MockInputApi for presubmit unittests.
"""
- def __init__(self, local_path, new_contents, old_contents=None, action='A'):
+ def __init__(self, local_path, new_contents, old_contents=None, action='A',
+ scm_diff=None):
self._local_path = local_path
self._new_contents = new_contents
self._changed_contents = [(i + 1, l) for i, l in enumerate(new_contents)]
self._action = action
- self._scm_diff = "--- /dev/null\n+++ %s\n@@ -0,0 +1,%d @@\n" % (local_path,
- len(new_contents))
+ if scm_diff:
+ self._scm_diff = scm_diff
+ else:
+ self._scm_diff = (
+ "--- /dev/null\n+++ %s\n@@ -0,0 +1,%d @@\n" %
+ (local_path, len(new_contents)))
+ for l in new_contents:
+ self._scm_diff += "+%s\n" % l
self._old_contents = old_contents
- for l in new_contents:
- self._scm_diff += "+%s\n" % l
def Action(self):
return self._action