mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1132771 - Implement file-info mach command; r=glandium
Now that we have a mechanism for defining file-based metadata, let's add a mach command to interface with it. Currently, we limit ourselves to simple Bugzilla data dumping. Features will be added over time. --HG-- extra : rebase_source : 8f6c150f2f284097829aa495b4a043827fa5c8cd extra : histedit_source : 41c71d0e9b20c73fc7524fd266e16bc7789ff463
This commit is contained in:
parent
3ee0ca43a1
commit
f2517a80b0
@ -4,13 +4,17 @@
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
from mach.decorators import (
|
||||
CommandArgument,
|
||||
CommandProvider,
|
||||
Command
|
||||
Command,
|
||||
SubCommand,
|
||||
)
|
||||
|
||||
from mozbuild.base import MachCommandBase
|
||||
import mozpack.path as mozpath
|
||||
|
||||
|
||||
@CommandProvider
|
||||
@ -72,3 +76,49 @@ class MozbuildFileCommands(MachCommandBase):
|
||||
print(line)
|
||||
|
||||
return 0
|
||||
|
||||
@Command('file-info', category='build-dev',
|
||||
description='Query for metadata about files.')
|
||||
def file_info(self):
|
||||
pass
|
||||
|
||||
@SubCommand('file-info', 'bugzilla-component',
|
||||
'Show Bugzilla component info for files listed.')
|
||||
@CommandArgument('paths', nargs='+',
|
||||
help='Paths whose data to query')
|
||||
def file_info_bugzilla(self, paths):
|
||||
components = defaultdict(set)
|
||||
for p, m in self._get_files_info(paths).items():
|
||||
components[m.get('BUG_COMPONENT')].add(p)
|
||||
|
||||
for component, files in sorted(components.items(), key=lambda x: (x is None, x)):
|
||||
print('%s :: %s' % (component.product, component.component) if component else 'UNKNOWN')
|
||||
for f in sorted(files):
|
||||
print(' %s' % f)
|
||||
|
||||
@SubCommand('file-info', 'missing-bugzilla',
|
||||
'Show files missing Bugzilla component info')
|
||||
@CommandArgument('paths', nargs='+',
|
||||
help='Paths whose data to query')
|
||||
def file_info_missing_bugzilla(self, paths):
|
||||
for p, m in sorted(self._get_files_info(paths).items()):
|
||||
if 'BUG_COMPONENT' not in m:
|
||||
print(p)
|
||||
|
||||
def _get_reader(self):
|
||||
from mozbuild.frontend.reader import BuildReader
|
||||
config = self.config_environment
|
||||
return BuildReader(config)
|
||||
|
||||
def _get_files_info(self, paths):
|
||||
relpaths = []
|
||||
for p in paths:
|
||||
a = mozpath.abspath(p)
|
||||
if not mozpath.basedir(a, [self.topsrcdir]):
|
||||
print('path is not inside topsrcdir: %s' % p)
|
||||
return 1
|
||||
|
||||
relpaths.append(mozpath.relpath(a, self.topsrcdir))
|
||||
|
||||
reader = self._get_reader()
|
||||
return reader.files_info(relpaths)
|
||||
|
Loading…
Reference in New Issue
Block a user