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

Side by Side Diff: presubmit_support.py

Issue 2269413002: Delete gcl, drover, and trychange (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Comments Created 4 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 unified diff | Download patch
« no previous file with comments | « git_cl.py ('k') | tests/trychange_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Enables directory-specific presubmit checks to run at upload and/or commit. 6 """Enables directory-specific presubmit checks to run at upload and/or commit.
7 """ 7 """
8 8
9 __version__ = '1.8.0' 9 __version__ = '1.8.0'
10 10
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 return _RightHandSideLinesImpl( 1002 return _RightHandSideLinesImpl(
1003 x for x in self.AffectedFiles(include_deletes=False) 1003 x for x in self.AffectedFiles(include_deletes=False)
1004 if x.IsTextFile()) 1004 if x.IsTextFile())
1005 1005
1006 1006
1007 class SvnChange(Change): 1007 class SvnChange(Change):
1008 _AFFECTED_FILES = SvnAffectedFile 1008 _AFFECTED_FILES = SvnAffectedFile
1009 scm = 'svn' 1009 scm = 'svn'
1010 _changelists = None 1010 _changelists = None
1011 1011
1012 def _GetChangeLists(self):
1013 """Get all change lists."""
1014 if self._changelists == None:
1015 previous_cwd = os.getcwd()
1016 os.chdir(self.RepositoryRoot())
1017 # Need to import here to avoid circular dependency.
1018 import gcl
1019 self._changelists = gcl.GetModifiedFiles()
1020 os.chdir(previous_cwd)
1021 return self._changelists
1022
1023 def GetAllModifiedFiles(self):
1024 """Get all modified files."""
1025 changelists = self._GetChangeLists()
1026 all_modified_files = []
1027 for cl in changelists.values():
1028 all_modified_files.extend(
1029 [os.path.join(self.RepositoryRoot(), f[1]) for f in cl])
1030 return all_modified_files
1031
1032 def GetModifiedFiles(self):
1033 """Get modified files in the current CL."""
1034 changelists = self._GetChangeLists()
1035 return [os.path.join(self.RepositoryRoot(), f[1])
1036 for f in changelists[self.Name()]]
1037
1038 def AllFiles(self, root=None): 1012 def AllFiles(self, root=None):
1039 """List all files under source control in the repo.""" 1013 """List all files under source control in the repo."""
1040 root = root or self.RepositoryRoot() 1014 root = root or self.RepositoryRoot()
1041 return subprocess.check_output( 1015 return subprocess.check_output(
1042 ['svn', 'ls', '-R', '.'], cwd=root).splitlines() 1016 ['svn', 'ls', '-R', '.'], cwd=root).splitlines()
1043 1017
1044 1018
1045 class GitChange(Change): 1019 class GitChange(Change):
1046 _AFFECTED_FILES = GitAffectedFile 1020 _AFFECTED_FILES = GitAffectedFile
1047 scm = 'git' 1021 scm = 'git'
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 1380
1407 return results 1381 return results
1408 1382
1409 1383
1410 class PresubmitExecuter(object): 1384 class PresubmitExecuter(object):
1411 def __init__(self, change, committing, rietveld_obj, verbose, 1385 def __init__(self, change, committing, rietveld_obj, verbose,
1412 gerrit_obj=None, dry_run=None): 1386 gerrit_obj=None, dry_run=None):
1413 """ 1387 """
1414 Args: 1388 Args:
1415 change: The Change object. 1389 change: The Change object.
1416 committing: True if 'gcl commit' is running, False if 'gcl upload' is. 1390 committing: True if 'git cl land' is running, False if 'git cl upload' is.
1417 rietveld_obj: rietveld.Rietveld client object. 1391 rietveld_obj: rietveld.Rietveld client object.
1418 gerrit_obj: provides basic Gerrit codereview functionality. 1392 gerrit_obj: provides basic Gerrit codereview functionality.
1419 dry_run: if true, some Checks will be skipped. 1393 dry_run: if true, some Checks will be skipped.
1420 """ 1394 """
1421 self.change = change 1395 self.change = change
1422 self.committing = committing 1396 self.committing = committing
1423 self.rietveld = rietveld_obj 1397 self.rietveld = rietveld_obj
1424 self.gerrit = gerrit_obj 1398 self.gerrit = gerrit_obj
1425 self.verbose = verbose 1399 self.verbose = verbose
1426 self.dry_run = dry_run 1400 self.dry_run = dry_run
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 1467
1494 This finds all PRESUBMIT.py files in directories enclosing the files in the 1468 This finds all PRESUBMIT.py files in directories enclosing the files in the
1495 change (up to the repository root) and calls the relevant entrypoint function 1469 change (up to the repository root) and calls the relevant entrypoint function
1496 depending on whether the change is being committed or uploaded. 1470 depending on whether the change is being committed or uploaded.
1497 1471
1498 Prints errors, warnings and notifications. Prompts the user for warnings 1472 Prints errors, warnings and notifications. Prompts the user for warnings
1499 when needed. 1473 when needed.
1500 1474
1501 Args: 1475 Args:
1502 change: The Change object. 1476 change: The Change object.
1503 committing: True if 'gcl commit' is running, False if 'gcl upload' is. 1477 committing: True if 'git cl land' is running, False if 'git cl upload' is.
1504 verbose: Prints debug info. 1478 verbose: Prints debug info.
1505 output_stream: A stream to write output from presubmit tests to. 1479 output_stream: A stream to write output from presubmit tests to.
1506 input_stream: A stream to read input from the user. 1480 input_stream: A stream to read input from the user.
1507 default_presubmit: A default presubmit script to execute in any case. 1481 default_presubmit: A default presubmit script to execute in any case.
1508 may_prompt: Enable (y/n) questions on warning or error. 1482 may_prompt: Enable (y/n) questions on warning or error.
1509 rietveld_obj: rietveld.Rietveld object. 1483 rietveld_obj: rietveld.Rietveld object.
1510 gerrit_obj: provides basic Gerrit codereview functionality. 1484 gerrit_obj: provides basic Gerrit codereview functionality.
1511 dry_run: if true, some Checks will be skipped. 1485 dry_run: if true, some Checks will be skipped.
1512 1486
1513 Warning: 1487 Warning:
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 return 2 1799 return 2
1826 1800
1827 1801
1828 if __name__ == '__main__': 1802 if __name__ == '__main__':
1829 fix_encoding.fix_encoding() 1803 fix_encoding.fix_encoding()
1830 try: 1804 try:
1831 sys.exit(main()) 1805 sys.exit(main())
1832 except KeyboardInterrupt: 1806 except KeyboardInterrupt:
1833 sys.stderr.write('interrupted\n') 1807 sys.stderr.write('interrupted\n')
1834 sys.exit(2) 1808 sys.exit(2)
OLDNEW
« no previous file with comments | « git_cl.py ('k') | tests/trychange_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698