Commit d9141bff authored by maruel@chromium.org's avatar maruel@chromium.org

After much refactory, finally add significant functionalities to trychanges.py

Add real logging support.
Fix the patch path mungling that was broken earlier.
Add and proper refactor automatic gclient and gcl settings detection.
Factored so it is possible to add other autodetection algorithms.
Now works standalone in hybrid svn&git checkouts within a gclient meta-checkout.

TEST=bah
BUG=none
TBR=bradnelson

Review URL: http://codereview.chromium.org/517005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@35218 0039d316-1c4b-4281-b951-d872f2087c98
parent ee4071d4
...@@ -820,23 +820,6 @@ def TryChange(change_info, args, swallow_exception): ...@@ -820,23 +820,6 @@ def TryChange(change_info, args, swallow_exception):
ErrorExit("You need to install trychange.py to use the try server.") ErrorExit("You need to install trychange.py to use the try server.")
trychange_args = [] trychange_args = []
settings = {
'port': GetCodeReviewSetting('TRYSERVER_HTTP_PORT'),
'host': GetCodeReviewSetting('TRYSERVER_HTTP_HOST'),
'svn_repo': GetCodeReviewSetting('TRYSERVER_SVN_URL'),
'project': GetCodeReviewSetting('TRYSERVER_PROJECT'),
'root': GetCodeReviewSetting('TRYSERVER_ROOT'),
'patchlevel': GetCodeReviewSetting('TRYSERVER_PATCHLEVEL'),
}
for (k, v) in settings.iteritems():
if v:
trychange_args.extend(['--' + k, v])
gclient_root = gclient_utils.FindGclientRoot(GetRepositoryRoot())
if gclient_root:
trychange_args.extend(['--root',
gclient_utils.PathDifference(gclient_root,
GetRepositoryRoot())])
if change_info: if change_info:
trychange_args.extend(['--name', change_info.name]) trychange_args.extend(['--name', change_info.name])
if change_info.issue: if change_info.issue:
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"""Generic utils.""" """Generic utils."""
import errno import errno
import logging
import os import os
import re import re
import stat import stat
...@@ -40,6 +41,7 @@ def CheckCall(command, cwd=None, print_error=True): ...@@ -40,6 +41,7 @@ def CheckCall(command, cwd=None, print_error=True):
Works on python 2.4 Works on python 2.4
""" """
logging.debug(command)
try: try:
stderr = None stderr = None
if not print_error: if not print_error:
...@@ -162,6 +164,7 @@ def RemoveDirectory(*path): ...@@ -162,6 +164,7 @@ def RemoveDirectory(*path):
In the ordinary case, this is not a problem: for our purposes, the user In the ordinary case, this is not a problem: for our purposes, the user
will never lack write permission on *path's parent. will never lack write permission on *path's parent.
""" """
logging.debug(path)
file_path = os.path.join(*path) file_path = os.path.join(*path)
if not os.path.exists(file_path): if not os.path.exists(file_path):
return return
...@@ -256,7 +259,7 @@ def SubprocessCallAndFilter(command, ...@@ -256,7 +259,7 @@ def SubprocessCallAndFilter(command,
exit with an exit status of fail_status. If fail_status is None (the exit with an exit status of fail_status. If fail_status is None (the
default), gclient will raise an Error exception. default), gclient will raise an Error exception.
""" """
logging.debug(command)
if print_messages: if print_messages:
print("\n________ running \'%s\' in \'%s\'" print("\n________ running \'%s\' in \'%s\'"
% (' '.join(command), in_directory)) % (' '.join(command), in_directory))
...@@ -316,6 +319,7 @@ def FindGclientRoot(from_dir): ...@@ -316,6 +319,7 @@ def FindGclientRoot(from_dir):
if not next[1]: if not next[1]:
return None return None
path = next[0] path = next[0]
logging.info('Found gclient root at ' + path)
return path return path
def PathDifference(root, subpath): def PathDifference(root, subpath):
......
...@@ -54,7 +54,9 @@ class SVNUnittest(TryChangeTestsBase): ...@@ -54,7 +54,9 @@ class SVNUnittest(TryChangeTestsBase):
"""trychange.SVN tests.""" """trychange.SVN tests."""
def testMembersChanged(self): def testMembersChanged(self):
members = [ members = [
'GenerateDiff', 'GetBots', 'GetFileNames', 'GetLocalRoot', 'AutomagicalSettings', 'GclStyleSettings', 'GclientStyleSettings',
'GetCodeReviewSetting', 'ReadRootFile',
'GenerateDiff', 'GetFileNames', 'GetLocalRoot',
] ]
# If this test fails, you should add the relevant test. # If this test fails, you should add the relevant test.
self.compareMembers(trychange.SVN, members) self.compareMembers(trychange.SVN, members)
...@@ -75,7 +77,9 @@ class GITUnittest(TryChangeTestsBase): ...@@ -75,7 +77,9 @@ class GITUnittest(TryChangeTestsBase):
"""trychange.GIT tests.""" """trychange.GIT tests."""
def testMembersChanged(self): def testMembersChanged(self):
members = [ members = [
'GenerateDiff', 'GetBots', 'GetFileNames', 'GetLocalRoot', 'AutomagicalSettings', 'GclStyleSettings', 'GclientStyleSettings',
'GetCodeReviewSetting', 'ReadRootFile',
'GenerateDiff', 'GetFileNames', 'GetLocalRoot',
] ]
# If this test fails, you should add the relevant test. # If this test fails, you should add the relevant test.
self.compareMembers(trychange.GIT, members) self.compareMembers(trychange.GIT, members)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment