Ejemplo n.º 1
0
def main(args):
    parser = GetParser()
    options = parser.parse_args(args)

    # Revert any lingering local changes.
    if not osutils.SafeMakedirs(options.chrome_root) and options.reset:
        try:
            gclient.Revert(options.gclient, options.chrome_root)
        except cros_build_lib.RunCommandError:
            osutils.RmDir(options.chrome_root)
            osutils.SafeMakedirs(options.chrome_root)

    # Sync new Chrome.
    gclient.WriteConfigFile(options.gclient, options.chrome_root,
                            options.internal, options.pdf, options.version)
    gclient.Sync(options.gclient, options.chrome_root, options.reset)
    return 0
Ejemplo n.º 2
0
def main(args):
    parser = GetParser()
    options = parser.parse_args(args)

    # Revert any lingering local changes.
    if not osutils.SafeMakedirs(options.chrome_root) and options.reset:
        try:
            gclient.Revert(options.gclient, options.chrome_root)
        except cros_build_lib.RunCommandError:
            osutils.RmDir(options.chrome_root)
            osutils.SafeMakedirs(options.chrome_root)

    # Sync new Chrome.
    gclient.WriteConfigFile(options.gclient, options.chrome_root,
                            options.internal, options.pdf, options.version)
    sync_fn = functools.partial(gclient.Sync,
                                options.gclient,
                                options.chrome_root,
                                reset=options.reset)

    # Sync twice when run with --reset, which implies 'gclient sync -D'.
    #
    # There's a bug with 'gclient sync -D' that gets hit when the location of a
    # dependency checkout (in the DEPS file) is moved to a path that contains
    # (in a directory fashion) its old path.  E.g., when Blink is moved from
    # Webkit/Source/ to Webkit/.  When this happens, a 'gclient sync -D' will
    # blow away Webkit/Source/ after the sync, since it is no longer in the
    # DEPS file, leaving the Blink checkout missing a Source/ subdirectory.
    #
    # This bug also gets hit the other way around - E.g., if Blink moves from
    # Webkit/ to Webkit/Source/.
    #
    # To work around this, we sync twice, so that any directories deleted by
    # the first sync will be restored in the second.
    #
    # TODO(rcui): Remove this workaround when the bug is fixed in gclient, or
    # replace with a more sophisticated solution that syncs twice only when any
    # paths in the DEPS file cannot be found after initial sync.
    if options.reset:
        sync_fn()
    sync_fn()
    return 0
Ejemplo n.º 3
0
def main(argv):
    parser = GetParser()
    options = parser.parse_args(argv)

    if options.gclient == '':
        parser.error('--gclient can not be an empty string!')
    gclient_path = options.gclient or osutils.Which('gclient')
    if not gclient_path:
        gclient_path = os.path.join(constants.DEPOT_TOOLS_DIR, 'gclient')

    try:
        if options.reset:
            # Revert any lingering local changes.
            gclient.Revert(gclient_path, options.chrome_root)

        SyncChrome(gclient_path, options)
    except cros_build_lib.RunCommandError:
        # If we have an error resetting, or syncing, we clobber, and fresh sync.
        logging.warning('Chrome checkout appears corrupt. Clobbering.')
        osutils.RmDir(options.chrome_root, ignore_missing=True, sudo=True)
        osutils.SafeMakedirsNonRoot(options.chrome_root)
        SyncChrome(gclient_path, options)

    return 0
Ejemplo n.º 4
0
 def testRevert(self):
     gclient.Revert(self.fake_gclient, self.cwd)
     self.assertCommandCalled([self.fake_gclient, 'revert', '--nohooks'],
                              cwd=self.cwd)