| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
| 9 | 9 |
| 10 from __future__ import print_function | 10 from __future__ import print_function |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 def print_stats(similarity, find_copies, args): | 718 def print_stats(similarity, find_copies, args): |
| 719 """Prints statistics about the change to the user.""" | 719 """Prints statistics about the change to the user.""" |
| 720 # --no-ext-diff is broken in some versions of Git, so try to work around | 720 # --no-ext-diff is broken in some versions of Git, so try to work around |
| 721 # this by overriding the environment (but there is still a problem if the | 721 # this by overriding the environment (but there is still a problem if the |
| 722 # git config key "diff.external" is used). | 722 # git config key "diff.external" is used). |
| 723 env = GetNoGitPagerEnv() | 723 env = GetNoGitPagerEnv() |
| 724 if 'GIT_EXTERNAL_DIFF' in env: | 724 if 'GIT_EXTERNAL_DIFF' in env: |
| 725 del env['GIT_EXTERNAL_DIFF'] | 725 del env['GIT_EXTERNAL_DIFF'] |
| 726 | 726 |
| 727 if find_copies: | 727 if find_copies: |
| 728 similarity_options = ['--find-copies-harder', '-l100000', | 728 similarity_options = ['-l100000', '-C%s' % similarity] |
| 729 '-C%s' % similarity] | |
| 730 else: | 729 else: |
| 731 similarity_options = ['-M%s' % similarity] | 730 similarity_options = ['-M%s' % similarity] |
| 732 | 731 |
| 733 try: | 732 try: |
| 734 stdout = sys.stdout.fileno() | 733 stdout = sys.stdout.fileno() |
| 735 except AttributeError: | 734 except AttributeError: |
| 736 stdout = None | 735 stdout = None |
| 737 return subprocess2.call( | 736 return subprocess2.call( |
| 738 ['git', | 737 ['git', |
| 739 'diff', '--no-ext-diff', '--stat'] + similarity_options + args, | 738 'diff', '--no-ext-diff', '--stat'] + similarity_options + args, |
| (...skipping 4654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5394 if __name__ == '__main__': | 5393 if __name__ == '__main__': |
| 5395 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5394 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 5396 # unit testing. | 5395 # unit testing. |
| 5397 fix_encoding.fix_encoding() | 5396 fix_encoding.fix_encoding() |
| 5398 setup_color.init() | 5397 setup_color.init() |
| 5399 try: | 5398 try: |
| 5400 sys.exit(main(sys.argv[1:])) | 5399 sys.exit(main(sys.argv[1:])) |
| 5401 except KeyboardInterrupt: | 5400 except KeyboardInterrupt: |
| 5402 sys.stderr.write('interrupted\n') | 5401 sys.stderr.write('interrupted\n') |
| 5403 sys.exit(1) | 5402 sys.exit(1) |
| OLD | NEW |