diff options
Diffstat (limited to 'tools/upstream/upstream-diff')
-rwxr-xr-x | tools/upstream/upstream-diff | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/upstream/upstream-diff b/tools/upstream/upstream-diff index f52fdb5b03..b689b3338c 100755 --- a/tools/upstream/upstream-diff +++ b/tools/upstream/upstream-diff @@ -51,6 +51,8 @@ or to investigate which version of upstream introduced a change: import argparse import os +import os.path +import re import subprocess import sys @@ -60,27 +62,39 @@ def run_diff(diff, repositories, rel_paths): # Root of repository snapshots. See go/libcore-o-verify for how you'd want to set this. ojluni_upstreams = os.environ['OJLUNI_UPSTREAMS'] for rel_path in rel_paths: - if not rel_path.endswith('.java'): - # Might be a fully qualified class name + # Paths end with a dot and lowercase file extension (.c, .java, ...) but + # fully qualified class names do not. + if ('/' not in rel_path) and (not re.match('.+\\.[a-z]{1,4}$', rel_path)): + # Assume a fully qualified class name rel_path = rel_path.replace('.', '/') + '.java' paths = [] for repository in repositories: - if repository == "ojluni": - paths.append('%s/libcore/ojluni/src/main/java/%s' % (android_build_top, rel_path)) + if repository == 'ojluni': + file_group = 'java/' if rel_path.endswith('.java') else 'native/' + paths.append('%s/libcore/ojluni/src/main/%s/%s' + % (android_build_top, file_group, rel_path)) else: paths.append('%s/%s/%s' % (ojluni_upstreams, repository, rel_path)) subprocess.call([diff] + paths) def main(): parser = argparse.ArgumentParser( - description='Compare files between libcore/ojluni and ${OJLUNI_UPSTREAMS}.') + description='Compare files between libcore/ojluni and ${OJLUNI_UPSTREAMS}.', + formatter_class=argparse.ArgumentDefaultsHelpFormatter, # include default values in help + ) + upstreams = os.environ['OJLUNI_UPSTREAMS'] + # natsort.natsorted() would be a nicer sort order, but I'd rather avoid the dependency + repositories = ['ojluni'] + sorted( + [d for d in os.listdir(upstreams) if os.path.isdir(os.path.join(upstreams, d))] + ) parser.add_argument('-r', '--repositories', default='ojluni,expected', - help='Comma-separated list of >= 2 repositories to compare.') + help='Comma-separated list of 2-3 repositories, to compare, in order; ' + 'available repositories: ' + ' '.join(repositories) + '.') parser.add_argument('-d', '--diff', default='meld', help='Application to use for diffing.') parser.add_argument('rel_path', nargs="+", - help='File to compare: either a relative path below ' - 'libcore/ojluni/src/main/java, or a fully qualified class name.') + help='File to compare: either a relative path below libcore/ojluni/' + 'src/main/{java,native}, or a fully qualified class name.') args = parser.parse_args() repositories = args.repositories.split(',') if (len(repositories) < 2): |