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

Unified Diff: presubmit_support.py

Issue 155489: Add a presubmit check for accidental checkins of files under a SVN modified d... (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 4 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 | « presubmit_canned_checks.py ('k') | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
===================================================================
--- presubmit_support.py (revision 23229)
+++ presubmit_support.py (working copy)
@@ -343,7 +343,7 @@
def ReadFile(self, file, mode='r'):
"""Reads an arbitrary file.
-
+
Deny reading anything outside the repository.
"""
if isinstance(file, AffectedFile):
@@ -372,7 +372,6 @@
self._local_root = repository_root
self._is_directory = None
self._properties = {}
- self.scm = ''
def ServerPath(self):
"""Returns a path string that identifies the file in the SCM system.
@@ -413,7 +412,7 @@
def IsTextFile(self):
"""Returns True if the file is a text file and not a binary file.
-
+
Deleted files are not text file."""
raise NotImplementedError() # Implement when needed
@@ -458,7 +457,6 @@
AffectedFile.__init__(self, *args, **kwargs)
self._server_path = None
self._is_text_file = None
- self.scm = 'svn'
def ServerPath(self):
if self._server_path is None:
@@ -505,7 +503,6 @@
AffectedFile.__init__(self, *args, **kwargs)
self._server_path = None
self._is_text_file = None
- self.scm = 'git'
def ServerPath(self):
if self._server_path is None:
@@ -547,7 +544,7 @@
Used directly by the presubmit scripts to query the current change being
tested.
-
+
Instance members:
tags: Dictionnary of KEY=VALUE pairs found in the change description.
self.KEY: equivalent to tags['KEY']
@@ -567,6 +564,7 @@
self._local_root = local_root
self.issue = issue
self.patchset = patchset
+ self.scm = ''
# From the description text, build up a dictionary of key/value pairs
# plus the description minus all key/value or "tag" lines.
@@ -681,11 +679,32 @@
class SvnChange(Change):
_AFFECTED_FILES = SvnAffectedFile
+ def __init__(self, *args, **kwargs):
+ Change.__init__(self, *args, **kwargs)
+ self.scm = 'svn'
+ def GetAllModifiedFiles(self):
+ """Get all modified files."""
+ changelists = gcl.GetModifiedFiles()
+ all_modified_files = []
+ for cl in changelists.values():
+ all_modified_files.extend([f[1] for f in cl])
+ return all_modified_files
+
+ def GetModifiedFiles(self):
+ """Get modified files in the current CL."""
+ changelists = gcl.GetModifiedFiles()
+ return [f[1] for f in changelists[self.Name()]]
+
+
class GitChange(Change):
_AFFECTED_FILES = GitAffectedFile
+ def __init__(self, *args, **kwargs):
+ Change.__init__(self, *args, **kwargs)
+ self.scm = 'git'
+
def ListRelevantPresubmitFiles(files, root):
"""Finds all presubmit files that apply to a given set of source files.
« no previous file with comments | « presubmit_canned_checks.py ('k') | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698