def update()

in blink/tools/move_blink_source.py [0:0]


    def update(self):
        _log.info('Planning renaming ...')
        file_pairs = plan_blink_move(self._fs, [])
        _log.info('Will move %d files', len(file_pairs))

        self._create_basename_maps(file_pairs)
        dirs = self._update_file_content()

        # Updates #includes in files in directories with updated DEPS +
        # third_party/WebKit/{Source,common,public}.
        self._append_unless_upper_dir_exists(dirs, self._fs.join(self._repo_root, 'third_party', 'WebKit', 'Source'))
        self._append_unless_upper_dir_exists(dirs, self._fs.join(self._repo_root, 'third_party', 'WebKit', 'common'))
        self._append_unless_upper_dir_exists(dirs, self._fs.join(self._repo_root, 'third_party', 'WebKit', 'public'))
        self._append_unless_upper_dir_exists(dirs, self._fs.join(self._repo_root, 'mojo', 'public', 'tools',
                                                                 'bindings', 'generators', 'cpp_templates'))
        self._update_cpp_includes_in_directories(dirs)

        # Content update for individual files.
        # The following is a list of tuples.
        #  Tuple: (<file path relative to repo root>, [replacement commands])
        #  Command: a callable object, or
        #           a tuple of (<original string>, <new string>).
        file_replacement_list = [
            ('DEPS',
             [('src/third_party/WebKit/Source/devtools',
               'src/third_party/blink/renderer/devtools')]),
            ('WATCHLISTS',
             [('third_party/WebKit/Source', 'third_party/blink/renderer'),
              ('third_party/WebKit/public', 'third_party/blink/renderer/public')]),
            ('build/check_gn_headers_whitelist.txt',
             [('third_party/WebKit/Source', 'third_party/blink/renderer'),
              ('third_party/WebKit/public', 'third_party/blink/renderer/public'),
              self._update_basename]),
            ('testing/buildbot/gn_isolate_map.pyl',
             [('third_party/WebKit/Source', 'third_party/blink/renderer')]),
            ('third_party/WebKit/Source/BUILD.gn',
             [('$root_gen_dir/third_party/WebKit',
               '$root_gen_dir/third_party/blink/renderer')]),
            ('third_party/WebKit/Source/config.gni',
             [('snake_case_source_files = false',
               'snake_case_source_files = true')]),
            ('third_party/WebKit/Source/core/css/CSSProperties.json5',
             [self._update_basename]),
            ('third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5',
             [self._update_basename]),
            ('third_party/WebKit/Source/core/css/ComputedStyleFieldAliases.json5',
             [self._update_basename]),
            ('third_party/WebKit/Source/core/html/parser/create-html-entity-table',
             [self._update_basename]),
            ('third_party/WebKit/Source/core/inspector/inspector_protocol_config.json',
             [self._update_basename]),
            ('third_party/WebKit/Source/core/probe/CoreProbes.json5',
             [self._update_basename]),
            ('third_party/WebKit/Source/core/testing/InternalSettings.h',
             [('InternalSettingsGenerated.h', 'internal_settings_generated.h')]),
            ('third_party/WebKit/Source/core/testing/Internals.cpp',
             [('InternalRuntimeFlags.h', 'internal_runtime_flags.h')]),
            ('third_party/WebKit/Source/platform/probe/PlatformProbes.json5',
             [self._update_basename]),
            ('third_party/WebKit/public/BUILD.gn',
             [('$root_gen_dir/third_party/WebKit',
               '$root_gen_dir/third_party/blink/renderer')]),
            ('third_party/WebKit/public/blink_resources.grd',
             [('../Source/', '../')]),
            ('tools/android/eclipse/.classpath',
             [('third_party/WebKit/public', 'third_party/blink/renderer/public')]),
            ('tools/android/loading/cloud/backend/deploy.sh',
             [('third_party/WebKit/Source', 'third_party/blink/renderer')]),
            ('tools/android/loading/emulation_unittest.py',
             [('third_party/WebKit/Source', 'third_party/blink/renderer')]),
            ('tools/android/loading/options.py',
             [('third_party/WebKit/Source', 'third_party/blink/renderer')]),
            ('tools/android/loading/request_track.py',
             [('third_party/WebKit/Source', 'third_party/blink/renderer')]),
            ('tools/gritsettings/resource_ids',
             [('third_party/WebKit/public', 'third_party/blink/renderer/public'),
              ('third_party/WebKit/Source', 'third_party/blink/renderer')]),
            ('tools/metrics/actions/extract_actions.py',
             [('third_party/WebKit/Source', 'third_party/blink/renderer')]),
            ('tools/metrics/histograms/update_editor_commands.py',
             [('third_party/WebKit/Source/core/editing/EditorCommand.cpp',
               'third_party/blink/renderer/core/editing/editor_command.cc')]),
            ('tools/metrics/histograms/update_use_counter_css.py',
             [('third_party/WebKit/Source/core/frame/UseCounter.cpp',
               'third_party/blink/renderer/core/frame/use_counter.cc')]),
            ('tools/metrics/histograms/update_use_counter_feature_enum.py',
             [('third_party/WebKit/public', 'third_party/blink/renderer/public')]),
        ]
        for file_path, replacement_list in file_replacement_list:
            self._update_single_file_content(file_path, replacement_list, should_write=self._options.run)

        if self._options.run:
            _log.info('Formatting updated %d files ...', len(self._updated_files))
            git = Git(cwd=self._repo_root)
            # |git cl format| can't handle too many files at once.
            while len(self._updated_files) > 0:
                end_index = 100
                if end_index > len(self._updated_files):
                    end_index = len(self._updated_files)
                git.run(['cl', 'format'] + self._updated_files[:end_index])
                self._updated_files = self._updated_files[end_index:]

            _log.info('Make a local commit ...')
            git.commit_locally_with_message("""The Great Blink mv for source files, part 1.