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 import owners_finder | |
37 import glob | |
M-A Ruel
2013/04/24 13:04:45
this one is a stdlib, move it in the group above.
Bei Zhang
2013/04/24 16:42:01
Done.
| |
36 | 38 |
37 | 39 |
38 DEFAULT_SERVER = 'https://codereview.appspot.com' | 40 DEFAULT_SERVER = 'https://codereview.appspot.com' |
39 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' | 41 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' |
40 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' | 42 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' |
41 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit' | 43 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit' |
42 CHANGE_ID = 'Change-Id:' | 44 CHANGE_ID = 'Change-Id:' |
43 | 45 |
44 | 46 |
45 # Initialized in main() | 47 # Initialized in main() |
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1887 _, args = parser.parse_args(args) | 1889 _, args = parser.parse_args(args) |
1888 if args: | 1890 if args: |
1889 parser.error('Unrecognized args: %s' % ' '.join(args)) | 1891 parser.error('Unrecognized args: %s' % ' '.join(args)) |
1890 cl = Changelist() | 1892 cl = Changelist() |
1891 # Ensure there actually is an issue to close. | 1893 # Ensure there actually is an issue to close. |
1892 cl.GetDescription() | 1894 cl.GetDescription() |
1893 cl.CloseIssue() | 1895 cl.CloseIssue() |
1894 return 0 | 1896 return 0 |
1895 | 1897 |
1896 | 1898 |
1899 def CMDowners(parser, args): | |
1900 """Interactively find the owners for reviewing""" | |
M-A Ruel
2013/04/24 13:04:45
"""interactively ...
because it's printed as-is i
Bei Zhang
2013/04/24 16:42:01
Done.
| |
1901 group = optparse.OptionGroup(parser, 'Find owners options') | |
1902 group.add_option( | |
1903 '--no-color', | |
1904 action='store_true', | |
1905 help=('Use this option to disable color output')) | |
M-A Ruel
2013/04/24 13:04:45
help='Use this option to disable color output')
Bei Zhang
2013/04/24 16:42:01
Done.
| |
1906 parser.add_option_group(group) | |
1907 opt, args = parser.parse_args(args) | |
M-A Ruel
2013/04/24 13:04:45
please use the same naming conversion than the oth
Bei Zhang
2013/04/24 16:42:01
Done.
| |
1908 cl = Changelist() | |
1909 | |
1910 if args: | |
1911 if len(args) > 1: | |
M-A Ruel
2013/04/24 13:04:45
Do this check first, before creating cl.
Bei Zhang
2013/04/24 16:42:01
Done.
| |
1912 parser.error('Unknown args') | |
1913 return | |
M-A Ruel
2013/04/24 13:04:45
not needed, remove. error() calls sys.exit()
Bei Zhang
2013/04/24 16:42:01
Done.
| |
1914 base_branch = args[0] | |
1915 else: | |
1916 # Default to diffing against the common ancestor of the upstream branch. | |
1917 base_branch = RunGit(['merge-base', cl.GetUpstreamBranch(), 'HEAD']).strip() | |
1918 | |
1919 change = cl.GetChange(base_branch, None) | |
1920 return owners_finder.OwnersFinder( | |
1921 [f.LocalPath() for f in | |
1922 cl.GetChange(base_branch, None).AffectedFiles()], | |
1923 change.RepositoryRoot(), | |
1924 fopen=file, os_path=os.path, glob=glob.glob, | |
1925 disable_color=opt.no_color).run() | |
1926 | |
1927 | |
1897 def Command(name): | 1928 def Command(name): |
1898 return getattr(sys.modules[__name__], 'CMD' + name, None) | 1929 return getattr(sys.modules[__name__], 'CMD' + name, None) |
1899 | 1930 |
1900 | 1931 |
1901 def CMDhelp(parser, args): | 1932 def CMDhelp(parser, args): |
1902 """print list of commands or help for a specific command""" | 1933 """print list of commands or help for a specific command""" |
1903 _, args = parser.parse_args(args) | 1934 _, args = parser.parse_args(args) |
1904 if len(args) == 1: | 1935 if len(args) == 1: |
1905 return main(args + ['--help']) | 1936 return main(args + ['--help']) |
1906 parser.print_help() | 1937 parser.print_help() |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1968 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1999 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1969 | 2000 |
1970 # Not a known command. Default to help. | 2001 # Not a known command. Default to help. |
1971 GenUsage(parser, 'help') | 2002 GenUsage(parser, 'help') |
1972 return CMDhelp(parser, argv) | 2003 return CMDhelp(parser, argv) |
1973 | 2004 |
1974 | 2005 |
1975 if __name__ == '__main__': | 2006 if __name__ == '__main__': |
1976 fix_encoding.fix_encoding() | 2007 fix_encoding.fix_encoding() |
1977 sys.exit(main(sys.argv[1:])) | 2008 sys.exit(main(sys.argv[1:])) |
OLD | NEW |