iannucci@chromium.org | c050a5b | 2014-03-26 06:18:50 +0000 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import argparse |
| 7 | import sys |
| 8 | |
| 9 | import subprocess2 |
| 10 | |
| 11 | from git_common import current_branch, get_or_create_merge_base, config_list |
| 12 | from git_common import GIT_EXE |
| 13 | |
| 14 | def main(args): |
| 15 | default_args = config_list('depot-tools.upstream-diff.default-args') |
| 16 | args = default_args + args |
| 17 | |
| 18 | parser = argparse.ArgumentParser() |
| 19 | parser.add_argument('--wordwise', action='store_true', default=False, |
| 20 | help=( |
| 21 | 'Print a colorized wordwise diff ' |
| 22 | 'instead of line-wise diff')) |
| 23 | opts, extra_args = parser.parse_known_args(args) |
| 24 | |
| 25 | cmd = [GIT_EXE, 'diff', '--patience', '-C', '-C'] |
| 26 | if opts.wordwise: |
| 27 | cmd += ['--word-diff=color', r'--word-diff-regex=(\w+|[^[:space:]])'] |
| 28 | cmd += [get_or_create_merge_base(current_branch())] |
| 29 | |
| 30 | cmd += extra_args |
| 31 | |
| 32 | subprocess2.check_call(cmd) |
| 33 | |
| 34 | |
| 35 | if __name__ == '__main__': |
| 36 | sys.exit(main(sys.argv[1:])) |