Handle extra metrics xml files in git cl format.

This will allow git cl format to handle histograms.xml being
split into several files, and also adds support for UKM.

Bug:699328

Change-Id: I2bfbd333b78b679f69d7cb298f5adaf02f6a4dec
Reviewed-on: https://chromium-review.googlesource.com/483979
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Steven Holte <holte@chromium.org>
changes/79/483979/5
Steven Holte 8 years ago committed by Commit Bot
parent d28b8c8f85
commit 2e664bfa92

@ -5794,24 +5794,30 @@ def CMDformat(parser, args):
DieWithError("gn format failed on " + gn_diff_file +
"\nTry running 'gn format' on this file manually.")
metrics_xml_files = [
os.path.join('tools', 'metrics', 'actions', 'actions.xml'),
os.path.join('tools', 'metrics', 'histograms', 'histograms.xml'),
os.path.join('tools', 'metrics', 'rappor', 'rappor.xml')]
for xml_file in metrics_xml_files:
if xml_file in diff_files:
tool_dir = os.path.join(top_dir, os.path.dirname(xml_file))
cmd = [os.path.join(tool_dir, 'pretty_print.py'), '--non-interactive']
if opts.dry_run or opts.diff:
cmd.append('--diff')
stdout = RunCommand(cmd, cwd=top_dir)
if opts.diff:
sys.stdout.write(stdout)
if opts.dry_run and stdout:
return_value = 2 # Not formatted.
for xml_dir in GetDirtyMetricsDirs(diff_files):
tool_dir = os.path.join(top_dir, xml_dir)
cmd = [os.path.join(tool_dir, 'pretty_print.py'), '--non-interactive']
if opts.dry_run or opts.diff:
cmd.append('--diff')
stdout = RunCommand(cmd, cwd=top_dir)
if opts.diff:
sys.stdout.write(stdout)
if opts.dry_run and stdout:
return_value = 2 # Not formatted.
return return_value
def GetDirtyMetricsDirs(diff_files):
xml_diff_files = [x for x in diff_files if MatchingFileType(x, ['.xml'])]
metrics_xml_dirs = [
os.path.join('tools', 'metrics', 'actions'),
os.path.join('tools', 'metrics', 'histograms'),
os.path.join('tools', 'metrics', 'rappor'),
os.path.join('tools', 'metrics', 'ukm')]
for xml_dir in metrics_xml_dirs:
if any(file.startswith(xml_dir) for file in xml_diff_files):
yield xml_dir
@subcommand.usage('<codereview url or issue id>')
def CMDcheckout(parser, args):

Loading…
Cancel
Save