| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 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 """Wrapper around git blame that ignores certain commits. | 6 """Wrapper around git blame that ignores certain commits. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 from __future__ import print_function | 9 from __future__ import print_function |
| 10 | 10 |
| 11 import argparse | 11 import argparse |
| 12 import collections | 12 import collections |
| 13 import logging | 13 import logging |
| 14 import os | 14 import os |
| 15 import subprocess2 | 15 import subprocess2 |
| 16 import sys | 16 import sys |
| 17 | 17 |
| 18 import git_common | 18 import git_common |
| 19 import git_dates | 19 import git_dates |
| 20 import setup_color |
| 20 | 21 |
| 21 | 22 |
| 22 logging.getLogger().setLevel(logging.INFO) | 23 logging.getLogger().setLevel(logging.INFO) |
| 23 | 24 |
| 24 | 25 |
| 25 DEFAULT_IGNORE_FILE_NAME = '.git-blame-ignore-revs' | 26 DEFAULT_IGNORE_FILE_NAME = '.git-blame-ignore-revs' |
| 26 | 27 |
| 27 | 28 |
| 28 class Commit(object): | 29 class Commit(object): |
| 29 """Info about a commit.""" | 30 """Info about a commit.""" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 try: | 379 try: |
| 379 ignored.add(git_common.hash_one(c)) | 380 ignored.add(git_common.hash_one(c)) |
| 380 except subprocess2.CalledProcessError as e: | 381 except subprocess2.CalledProcessError as e: |
| 381 # Custom warning string (the message from git-rev-parse is inappropriate). | 382 # Custom warning string (the message from git-rev-parse is inappropriate). |
| 382 stderr.write('warning: unknown revision \'%s\'.\n' % c) | 383 stderr.write('warning: unknown revision \'%s\'.\n' % c) |
| 383 | 384 |
| 384 return hyper_blame(ignored, filename, args.revision, out=stdout, err=stderr) | 385 return hyper_blame(ignored, filename, args.revision, out=stdout, err=stderr) |
| 385 | 386 |
| 386 | 387 |
| 387 if __name__ == '__main__': # pragma: no cover | 388 if __name__ == '__main__': # pragma: no cover |
| 389 setup_color.init() |
| 388 with git_common.less() as less_input: | 390 with git_common.less() as less_input: |
| 389 sys.exit(main(sys.argv[1:], stdout=less_input)) | 391 sys.exit(main(sys.argv[1:], stdout=less_input)) |
| OLD | NEW |