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

Side by Side Diff: git_cl.py

Issue 2148153002: Fix per-file owners check for deleted files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Rebase! Created 4 years, 5 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') | no next file with comments »
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 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
11 11
12 from distutils.version import LooseVersion 12 from distutils.version import LooseVersion
13 from multiprocessing.pool import ThreadPool 13 from multiprocessing.pool import ThreadPool
14 import base64 14 import base64
15 import collections 15 import collections
16 import glob
17 import httplib 16 import httplib
18 import json 17 import json
19 import logging 18 import logging
20 import multiprocessing 19 import multiprocessing
21 import optparse 20 import optparse
22 import os 21 import os
23 import re 22 import re
24 import stat 23 import stat
25 import sys 24 import sys
26 import textwrap 25 import textwrap
(...skipping 2687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 people = cleanup_list([match.group(2).strip()]) 2713 people = cleanup_list([match.group(2).strip()])
2715 if match.group(1) == 'TBR': 2714 if match.group(1) == 'TBR':
2716 tbr_names.extend(people) 2715 tbr_names.extend(people)
2717 else: 2716 else:
2718 r_names.extend(people) 2717 r_names.extend(people)
2719 for name in r_names: 2718 for name in r_names:
2720 if name not in reviewers: 2719 if name not in reviewers:
2721 reviewers.append(name) 2720 reviewers.append(name)
2722 if add_owners_tbr: 2721 if add_owners_tbr:
2723 owners_db = owners.Database(change.RepositoryRoot(), 2722 owners_db = owners.Database(change.RepositoryRoot(),
2724 fopen=file, os_path=os.path, glob=glob.glob) 2723 fopen=file, os_path=os.path)
2725 all_reviewers = set(tbr_names + reviewers) 2724 all_reviewers = set(tbr_names + reviewers)
2726 missing_files = owners_db.files_not_covered_by(change.LocalPaths(), 2725 missing_files = owners_db.files_not_covered_by(change.LocalPaths(),
2727 all_reviewers) 2726 all_reviewers)
2728 tbr_names.extend(owners_db.reviewers_for(missing_files, 2727 tbr_names.extend(owners_db.reviewers_for(missing_files,
2729 change.author_email)) 2728 change.author_email))
2730 new_r_line = 'R=' + ', '.join(reviewers) if reviewers else None 2729 new_r_line = 'R=' + ', '.join(reviewers) if reviewers else None
2731 new_tbr_line = 'TBR=' + ', '.join(tbr_names) if tbr_names else None 2730 new_tbr_line = 'TBR=' + ', '.join(tbr_names) if tbr_names else None
2732 2731
2733 # Put the new lines in the description where the old first R= line was. 2732 # Put the new lines in the description where the old first R= line was.
2734 line_loc = next((i for i, match in enumerate(matches) if match), -1) 2733 line_loc = next((i for i, match in enumerate(matches) if match), -1)
(...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after
4834 base_branch = args[0] 4833 base_branch = args[0]
4835 else: 4834 else:
4836 # Default to diffing against the common ancestor of the upstream branch. 4835 # Default to diffing against the common ancestor of the upstream branch.
4837 base_branch = cl.GetCommonAncestorWithUpstream() 4836 base_branch = cl.GetCommonAncestorWithUpstream()
4838 4837
4839 change = cl.GetChange(base_branch, None) 4838 change = cl.GetChange(base_branch, None)
4840 return owners_finder.OwnersFinder( 4839 return owners_finder.OwnersFinder(
4841 [f.LocalPath() for f in 4840 [f.LocalPath() for f in
4842 cl.GetChange(base_branch, None).AffectedFiles()], 4841 cl.GetChange(base_branch, None).AffectedFiles()],
4843 change.RepositoryRoot(), author, 4842 change.RepositoryRoot(), author,
4844 fopen=file, os_path=os.path, glob=glob.glob, 4843 fopen=file, os_path=os.path,
4845 disable_color=options.no_color).run() 4844 disable_color=options.no_color).run()
4846 4845
4847 4846
4848 def BuildGitDiffCmd(diff_type, upstream_commit, args): 4847 def BuildGitDiffCmd(diff_type, upstream_commit, args):
4849 """Generates a diff command.""" 4848 """Generates a diff command."""
4850 # Generate diff for the current branch's changes. 4849 # Generate diff for the current branch's changes.
4851 diff_cmd = ['diff', '--no-ext-diff', '--no-prefix', diff_type, 4850 diff_cmd = ['diff', '--no-ext-diff', '--no-prefix', diff_type,
4852 upstream_commit, '--' ] 4851 upstream_commit, '--' ]
4853 4852
4854 if args: 4853 if args:
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
5105 if __name__ == '__main__': 5104 if __name__ == '__main__':
5106 # These affect sys.stdout so do it outside of main() to simplify mocks in 5105 # These affect sys.stdout so do it outside of main() to simplify mocks in
5107 # unit testing. 5106 # unit testing.
5108 fix_encoding.fix_encoding() 5107 fix_encoding.fix_encoding()
5109 setup_color.init() 5108 setup_color.init()
5110 try: 5109 try:
5111 sys.exit(main(sys.argv[1:])) 5110 sys.exit(main(sys.argv[1:]))
5112 except KeyboardInterrupt: 5111 except KeyboardInterrupt:
5113 sys.stderr.write('interrupted\n') 5112 sys.stderr.write('interrupted\n')
5114 sys.exit(1) 5113 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | owners.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698