| 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.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 import json | 10 import json |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 from third_party import upload | 27 from third_party import upload |
| 28 import breakpad # pylint: disable=W0611 | 28 import breakpad # pylint: disable=W0611 |
| 29 import fix_encoding | 29 import fix_encoding |
| 30 import gclient_utils | 30 import gclient_utils |
| 31 import presubmit_support | 31 import presubmit_support |
| 32 import rietveld | 32 import rietveld |
| 33 import scm | 33 import scm |
| 34 import subprocess2 | 34 import subprocess2 |
| 35 import watchlists | 35 import watchlists |
| 36 | 36 import find_owners |
| 37 | 37 |
| 38 DEFAULT_SERVER = 'https://codereview.appspot.com' | 38 DEFAULT_SERVER = 'https://codereview.appspot.com' |
| 39 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' | 39 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' |
| 40 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' | 40 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' |
| 41 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit' | 41 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit' |
| 42 CHANGE_ID = 'Change-Id:' | 42 CHANGE_ID = 'Change-Id:' |
| 43 | 43 |
| 44 | 44 |
| 45 # Initialized in main() | 45 # Initialized in main() |
| 46 settings = None | 46 settings = None |
| (...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 """close the issue""" | 1801 """close the issue""" |
| 1802 _, args = parser.parse_args(args) | 1802 _, args = parser.parse_args(args) |
| 1803 if args: | 1803 if args: |
| 1804 parser.error('Unrecognized args: %s' % ' '.join(args)) | 1804 parser.error('Unrecognized args: %s' % ' '.join(args)) |
| 1805 cl = Changelist() | 1805 cl = Changelist() |
| 1806 # Ensure there actually is an issue to close. | 1806 # Ensure there actually is an issue to close. |
| 1807 cl.GetDescription() | 1807 cl.GetDescription() |
| 1808 cl.CloseIssue() | 1808 cl.CloseIssue() |
| 1809 return 0 | 1809 return 0 |
| 1810 | 1810 |
| 1811 def CMDowners(parser, args): |
| 1812 """Interactively find the owners for reviewing""" |
| 1813 group = optparse.OptionGroup(parser, "Find owners options") |
| 1814 group.add_option( |
| 1815 "--no-color", dest="ncolor", default=False, |
| 1816 action="store_true", |
| 1817 help=("Use this option to disable color output")) |
| 1818 parser.add_option_group(group) |
| 1819 opt, args = parser.parse_args(args) |
| 1820 cl = Changelist() |
| 1821 |
| 1822 if args: |
| 1823 base_branch = args[0] |
| 1824 else: |
| 1825 # Default to diffing against the common ancestor of the upstream branch. |
| 1826 base_branch = RunGit(['merge-base', cl.GetUpstreamBranch(), 'HEAD']).strip() |
| 1827 |
| 1828 change = cl.GetChange(base_branch, None) |
| 1829 return find_owners.FindOwners( |
| 1830 [f.LocalPath() for f in |
| 1831 cl.GetChange(base_branch, None).AffectedFiles()], |
| 1832 change.RepositoryRoot(), opt.ncolor).run() |
| 1811 | 1833 |
| 1812 def Command(name): | 1834 def Command(name): |
| 1813 return getattr(sys.modules[__name__], 'CMD' + name, None) | 1835 return getattr(sys.modules[__name__], 'CMD' + name, None) |
| 1814 | 1836 |
| 1815 | 1837 |
| 1816 def CMDhelp(parser, args): | 1838 def CMDhelp(parser, args): |
| 1817 """print list of commands or help for a specific command""" | 1839 """print list of commands or help for a specific command""" |
| 1818 _, args = parser.parse_args(args) | 1840 _, args = parser.parse_args(args) |
| 1819 if len(args) == 1: | 1841 if len(args) == 1: |
| 1820 return main(args + ['--help']) | 1842 return main(args + ['--help']) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1905 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1884 | 1906 |
| 1885 # Not a known command. Default to help. | 1907 # Not a known command. Default to help. |
| 1886 GenUsage(parser, 'help') | 1908 GenUsage(parser, 'help') |
| 1887 return CMDhelp(parser, argv) | 1909 return CMDhelp(parser, argv) |
| 1888 | 1910 |
| 1889 | 1911 |
| 1890 if __name__ == '__main__': | 1912 if __name__ == '__main__': |
| 1891 fix_encoding.fix_encoding() | 1913 fix_encoding.fix_encoding() |
| 1892 sys.exit(main(sys.argv[1:])) | 1914 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |