David James has posted comments on this change.
Change subject: Add script for syncing Chrome to a specified directory.
......................................................................
Patch Set 2: (14 inline comments)
....................................................
File lib/gclient.py
Line 5: """Common functions used for syncing Chrome."""
I've added a link to the documentation to the WriteConfigFile function, which is the function all the docstrings point at.
Line 15: def _UseGoloMirror():
Why? This function takes 0.026ms to run. We could optimize it to run faster, but this seems like unnecessary complexity given how fast it runs already.
Line 19:
golo.chromium.org.
Done
Line 46: rev_str = '@%s' % rev if rev else ''
Does not work.
>>> rev = None
>>> '@%s' % rev or ''
'@None'
>>> '@%s' % rev if rev else ''
''
Line 58: """Get the solutions array to write to the gclient file.
I don't think this is really necessary given that gclient has its own documentation describing how the gclient file format works. I've updated the WriteConfigFile function to link to the gclient documentation.
Line 68: 'svn_url': SVN_MIRROR_URL,
Yeah, that's intentional -- those tests are fairly small (with the exception of src/third_party/WebKit/LayoutTests which is 5.1G) and the list of DEPS to exclude is prone to getting out of date (it's already out of date). So just excluding the 1 big thing is more maintainable. Long term we want to move that logic into the DEPS file itself.
Line 71: 'sourceforge_url': SVN_MIRROR_URL + '/%(repo)s'
This is used in the DEPS file itself -- they substitute in the repo.
Line 94: return 'solutions = %s\n' % pprint.pformat(solutions)
Solution files are documented as being Python format, not JSON
Line 97: def WriteConfigFile(gclient, cwd, internal, use_pdf, rev):
I don't think we're going to be using gclient for anything else -- if anything, Chrome is moving away from gclient so we don't want to start adding gclient APIs for doing other things. The same is true for the few other projects that use gclient.
The main reason I called this gclient.py as opposed to chrome.py, is that I don't want this file growing to contain everything related to Chrome. gclient.py gives it a clear scope (i.e. just for gclient-related things.)
Line 123: cros_build_lib.RunCommand([gclient, 'revert', '--nohooks'], cwd=cwd)
Done
Line 129: cros_build_lib.RunCommand(cmd, cwd=cwd)
Some problems with this: 1) Hiding the input or output prevents users from being able to enter in their password if they were using this script. 2) gclient is prone to take a long time, so hiding the output means that buildbot may timeout while waiting for output from gclient. And if buildbot times out while we were waiting for output, we get no debugging information at all as to what the problem was. So I think that just switching to CaptureOutput here would be a bad idea.
We currently don't limit the output of gclient at all inside the Chrome ebuild, so how about we table this discussion until sync_chrome is added into cbuildbot? At that point we can look at output limiting and/or progress indicators.
....................................................
File scripts/sync_chrome.py
Line 13: """Creates the argparse parser."""
I'm going to disagree here because all of our existing code has GetParser in a function, so it's a convention. If you want to change the convention, I'd suggest we discuss it on chromeos-build@ or submit a big CL rather than just update it in 1 place and not in the rest.
Line 23: action='store_true', default=False)
Nope, but I think it's cleaner to be True or False rather than True or None.
Line 41: gclient.Sync(options.gclient, options.chrome_root, options.reset)
If the sync fails, we throw an exception so failure code is returned. As for the specific error code, I don't think that matters here.
Gerrit-MessageType: comment
Gerrit-Change-Id: I8a1e8c2c9191495cd641c62d43938195ed621e1f
Gerrit-PatchSet: 2
Gerrit-Project: chromiumos/chromite
Gerrit-Branch: master
Gerrit-Owner: David James <
david...@chromium.org>