Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: git_cl.py

Issue 12712002: An interactive tool to help find owners covering current change list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Refactor scoring Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | owners.py » ('j') | owners.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 difflib 10 import difflib
11 from distutils.version import LooseVersion 11 from distutils.version import LooseVersion
12 import json 12 import json
13 import logging 13 import logging
14 import optparse 14 import optparse
15 import os 15 import os
16 import Queue 16 import Queue
17 import re 17 import re
18 import stat 18 import stat
19 import sys 19 import sys
20 import textwrap 20 import textwrap
21 import threading 21 import threading
22 import urllib2 22 import urllib2
23 import urlparse 23 import urlparse
24 import glob
Dirk Pranke 2013/07/30 22:01:00 Nit: sort the imports so that this is up by json.
Bei Zhang 2013/08/12 22:43:12 Done.
24 25
25 try: 26 try:
26 import readline # pylint: disable=F0401,W0611 27 import readline # pylint: disable=F0401,W0611
27 except ImportError: 28 except ImportError:
28 pass 29 pass
29 30
30 31
31 from third_party import colorama 32 from third_party import colorama
32 from third_party import upload 33 from third_party import upload
33 import breakpad # pylint: disable=W0611 34 import breakpad # pylint: disable=W0611
34 import fix_encoding 35 import fix_encoding
35 import gclient_utils 36 import gclient_utils
36 import presubmit_support 37 import presubmit_support
37 import rietveld 38 import rietveld
38 import scm 39 import scm
39 import subprocess2 40 import subprocess2
40 import watchlists 41 import watchlists
42 import owners_finder
41 43
42 44
43 DEFAULT_SERVER = 'https://codereview.appspot.com' 45 DEFAULT_SERVER = 'https://codereview.appspot.com'
44 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' 46 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
45 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' 47 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
46 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit' 48 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit'
47 CHANGE_ID = 'Change-Id:' 49 CHANGE_ID = 'Change-Id:'
48 50
49 # Shortcut since it quickly becomes redundant. 51 # Shortcut since it quickly becomes redundant.
50 Fore = colorama.Fore 52 Fore = colorama.Fore
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 _, args = parser.parse_args(args) 2071 _, args = parser.parse_args(args)
2070 if args: 2072 if args:
2071 parser.error('Unrecognized args: %s' % ' '.join(args)) 2073 parser.error('Unrecognized args: %s' % ' '.join(args))
2072 cl = Changelist() 2074 cl = Changelist()
2073 # Ensure there actually is an issue to close. 2075 # Ensure there actually is an issue to close.
2074 cl.GetDescription() 2076 cl.GetDescription()
2075 cl.CloseIssue() 2077 cl.CloseIssue()
2076 return 0 2078 return 0
2077 2079
2078 2080
2081 def CMDowners(parser, args):
2082 """interactively find the owners for reviewing"""
2083 parser.add_option(
2084 '--no-color',
2085 action='store_true',
2086 help='Use this option to disable color output')
2087 options, args = parser.parse_args(args)
2088
2089 if args:
2090 if len(args) > 1:
2091 parser.error('Unknown args')
2092 cl = Changelist()
2093 base_branch = args[0]
2094 else:
2095 cl = Changelist()
2096 # Default to diffing against the common ancestor of the upstream branch.
2097 base_branch = RunGit(['merge-base', cl.GetUpstreamBranch(), 'HEAD']).strip()
Dirk Pranke 2013/07/30 22:01:00 What happens if we try to run this on an svn check
Bei Zhang 2013/08/12 22:43:12 This part is copied from CMDpresubmit. So I guess
2098
2099 change = cl.GetChange(base_branch, None)
2100 return owners_finder.OwnersFinder(
2101 [f.LocalPath() for f in
2102 cl.GetChange(base_branch, None).AffectedFiles()],
2103 change.RepositoryRoot(),
2104 fopen=file, os_path=os.path, glob=glob.glob,
2105 disable_color=options.no_color).run()
2106
2107
2079 def CMDformat(parser, args): 2108 def CMDformat(parser, args):
2080 """Runs clang-format on the diff.""" 2109 """Runs clang-format on the diff."""
2081 CLANG_EXTS = ['.cc', '.cpp', '.h'] 2110 CLANG_EXTS = ['.cc', '.cpp', '.h']
2082 parser.add_option('--full', action='store_true', default=False) 2111 parser.add_option('--full', action='store_true', default=False)
2083 opts, args = parser.parse_args(args) 2112 opts, args = parser.parse_args(args)
2084 if args: 2113 if args:
2085 parser.error('Unrecognized args: %s' % ' '.join(args)) 2114 parser.error('Unrecognized args: %s' % ' '.join(args))
2086 2115
2087 # Generate diff for the current branch's changes. 2116 # Generate diff for the current branch's changes.
2088 diff_cmd = ['diff', '--no-ext-diff', '--no-prefix'] 2117 diff_cmd = ['diff', '--no-ext-diff', '--no-prefix']
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 GenUsage(parser, 'help') 2294 GenUsage(parser, 'help')
2266 return CMDhelp(parser, argv) 2295 return CMDhelp(parser, argv)
2267 2296
2268 2297
2269 if __name__ == '__main__': 2298 if __name__ == '__main__':
2270 # These affect sys.stdout so do it outside of main() to simplify mocks in 2299 # These affect sys.stdout so do it outside of main() to simplify mocks in
2271 # unit testing. 2300 # unit testing.
2272 fix_encoding.fix_encoding() 2301 fix_encoding.fix_encoding()
2273 colorama.init() 2302 colorama.init()
2274 sys.exit(main(sys.argv[1:])) 2303 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | owners.py » ('j') | owners.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698