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

Unified Diff: trychange.py

Issue 8036046: Revert r102783 "Support for |change| argument to |GetPreferredTrySlaves()|." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 3 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 | « tests/trychange_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trychange.py
diff --git a/trychange.py b/trychange.py
index e322f1794bdb257474dcc93cb9ee9e8a7bd4d67e..9825b1e8b7a53058eefc3baa3485c42c2eec77ca 100755
--- a/trychange.py
+++ b/trychange.py
@@ -100,8 +100,7 @@ class SCM(object):
items.append(None)
self.diff_against = items[1]
self.options = options
- self._files = self.options.files
- self._file_tuples = [('M', f) for f in self.files]
+ self.files = self.options.files
self.options.files = None
self.codereview_settings = None
self.codereview_settings_file = 'codereview.settings'
@@ -188,38 +187,6 @@ class SCM(object):
logging.warning('Didn\'t find %s' % filename)
return None
- def _SetFileTuples(self, file_tuples):
- excluded = ['!', '?', 'X', ' ', '~']
- def Excluded(f):
- if f[0][0] in excluded:
- return True
- for r in self.options.exclude:
- if re.search(r, f[1]):
- logging.info('Ignoring "%s"' % f[1])
- return True
- return False
-
- self._file_tuples = [f for f in file_tuples if not Excluded(f)]
- self._files = [f[1] for f in self.file_tuples]
-
- def CaptureStatus(self):
- """Returns the 'svn status' emulated output as an array of (status, file)
- tuples."""
- raise NotImplementedError(
- "abstract method -- subclass %s must override" % self.__class__)
-
- @property
- def files(self):
- if not self._files:
- self._SetFileTuples(self.CaptureStatus())
- return self._files
-
- @property
- def file_tuples(self):
- if not self._file_tuples:
- self._SetFileTuples(self.CaptureStatus())
- return self._file_tuples
-
class SVN(SCM):
"""Gathers the options and diff for a subversion checkout."""
@@ -243,19 +210,29 @@ class SVN(SCM):
logging.debug('%s:\n%s' % (filename, data))
return data
- def CaptureStatus(self):
- previous_cwd = os.getcwd()
- os.chdir(self.checkout_root)
- result = scm.SVN.CaptureStatus(self.checkout_root)
- os.chdir(previous_cwd)
- return result
-
def GenerateDiff(self):
"""Returns a string containing the diff for the given file list.
The files in the list should either be absolute paths or relative to the
given root.
"""
+ if not self.files:
+ previous_cwd = os.getcwd()
+ os.chdir(self.checkout_root)
+
+ excluded = ['!', '?', 'X', ' ', '~']
+ def Excluded(f):
+ if f[0][0] in excluded:
+ return True
+ for r in self.options.exclude:
+ if re.search(r, f[1]):
+ logging.info('Ignoring "%s"' % f[1])
+ return True
+ return False
+
+ self.files = [f[1] for f in scm.SVN.CaptureStatus(self.checkout_root)
+ if not Excluded(f)]
+ os.chdir(previous_cwd)
return scm.SVN.GenerateDiff(self.files, self.checkout_root, full_move=True,
revision=self.diff_against)
@@ -278,10 +255,19 @@ class GIT(SCM):
"(via the --track argument to \"git checkout -b ...\"")
logging.info("GIT(%s)" % self.checkout_root)
- def CaptureStatus(self):
- return scm.GIT.CaptureStatus(self.checkout_root, self.diff_against)
-
def GenerateDiff(self):
+ if not self.files:
+ self.files = scm.GIT.GetDifferentFiles(self.checkout_root,
+ branch=self.diff_against)
+
+ def NotExcluded(f):
+ for r in self.options.exclude:
+ if re.search(r, f):
+ logging.info('Ignoring "%s"' % f)
+ return False
+ return True
+
+ self.files = filter(NotExcluded, self.files)
return scm.GIT.GenerateDiff(self.checkout_root, files=self.files,
full_move=True,
branch=self.diff_against)
@@ -478,7 +464,6 @@ def GetMungedDiff(path_diff, diff):
def TryChange(argv,
- change,
file_list,
swallow_exception,
prog=None,
@@ -716,18 +701,6 @@ def TryChange(argv,
diffs.extend(GetMungedDiff(path_diff, diff))
options.diff = ''.join(diffs)
- if not options.name:
- if options.issue:
- options.name = 'Issue %s' % options.issue
- else:
- options.name = 'Unnamed'
- print('Note: use --name NAME to change the try job name.')
-
- if not options.email:
- parser.error('Using an anonymous checkout. Please use --email or set '
- 'the TRYBOT_RESULTS_EMAIL_ADDRESS environment variable.')
- print('Results will be emailed to: ' + options.email)
-
if not options.bot:
# Get try slaves from PRESUBMIT.py files if not specified.
# Even if the diff comes from options.url, use the local checkout for bot
@@ -735,16 +708,7 @@ def TryChange(argv,
try:
import presubmit_support
root_presubmit = checkouts[0].ReadRootFile('PRESUBMIT.py')
- if change is None:
- change = presubmit_support.Change(options.name,
- '',
- checkouts[0].checkout_root,
- checkouts[0].file_tuples,
- options.issue,
- options.patchset,
- options.email)
options.bot = presubmit_support.DoGetTrySlaves(
- change,
checkouts[0].GetFileNames(),
checkouts[0].checkout_root,
root_presubmit,
@@ -756,6 +720,18 @@ def TryChange(argv,
# If no bot is specified, either the default pool will be selected or the
# try server will refuse the job. Either case we don't need to interfere.
+ if options.name is None:
+ if options.issue:
+ options.name = 'Issue %s' % options.issue
+ else:
+ options.name = 'Unnamed'
+ print('Note: use --name NAME to change the try job name.')
+ if not options.email:
+ parser.error('Using an anonymous checkout. Please use --email or set '
+ 'the TRYBOT_RESULTS_EMAIL_ADDRESS environment variable.')
+ else:
+ print('Results will be emailed to: ' + options.email)
+
# Prevent rietveld updates if we aren't running all the tests.
if options.testfilter is not None:
options.issue = None
@@ -791,4 +767,4 @@ def TryChange(argv,
if __name__ == "__main__":
fix_encoding.fix_encoding()
- sys.exit(TryChange(None, None, [], False))
+ sys.exit(TryChange(None, [], False))
« no previous file with comments | « tests/trychange_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698