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

Side by Side Diff: git_cl.py

Issue 10795003: Fix stats output to be always the same and coherent with what is committed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 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 | tests/git_cl_test.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.""" 8 """A git-command for integrating reviews on Rietveld."""
9 9
10 import json 10 import json
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 # Parse specs like "trunk/src:refs/remotes/origin/trunk". 128 # Parse specs like "trunk/src:refs/remotes/origin/trunk".
129 if fetch_suburl: 129 if fetch_suburl:
130 full_url = base_url + '/' + fetch_suburl 130 full_url = base_url + '/' + fetch_suburl
131 else: 131 else:
132 full_url = base_url 132 full_url = base_url
133 if full_url == url: 133 if full_url == url:
134 return as_ref 134 return as_ref
135 return None 135 return None
136 136
137 137
138 def print_stats(args):
139 """Prints statistics about the change to the user."""
140 # --no-ext-diff is broken in some versions of Git, so try to work around
141 # this by overriding the environment (but there is still a problem if the
142 # git config key "diff.external" is used).
143 env = os.environ.copy()
144 if 'GIT_EXTERNAL_DIFF' in env:
145 del env['GIT_EXTERNAL_DIFF']
146 return subprocess2.call(
147 ['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder'] + args,
148 env=env)
149
150
138 class Settings(object): 151 class Settings(object):
139 def __init__(self): 152 def __init__(self):
140 self.default_server = None 153 self.default_server = None
141 self.cc = None 154 self.cc = None
142 self.root = None 155 self.root = None
143 self.is_git_svn = None 156 self.is_git_svn = None
144 self.svn_branch = None 157 self.svn_branch = None
145 self.tree_status_url = None 158 self.tree_status_url = None
146 self.viewvc_url = None 159 self.viewvc_url = None
147 self.updated = False 160 self.updated = False
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 if not options.bypass_hooks: 1132 if not options.bypass_hooks:
1120 hook_results = cl.RunHook(committing=False, upstream_branch=base_branch, 1133 hook_results = cl.RunHook(committing=False, upstream_branch=base_branch,
1121 may_prompt=not options.force, 1134 may_prompt=not options.force,
1122 verbose=options.verbose, 1135 verbose=options.verbose,
1123 author=None) 1136 author=None)
1124 if not hook_results.should_continue(): 1137 if not hook_results.should_continue():
1125 return 1 1138 return 1
1126 if not options.reviewers and hook_results.reviewers: 1139 if not options.reviewers and hook_results.reviewers:
1127 options.reviewers = hook_results.reviewers 1140 options.reviewers = hook_results.reviewers
1128 1141
1129 # --no-ext-diff is broken in some versions of Git, so try to work around 1142 print_stats(args)
1130 # this by overriding the environment (but there is still a problem if the
1131 # git config key "diff.external" is used).
1132 env = os.environ.copy()
1133 if 'GIT_EXTERNAL_DIFF' in env:
1134 del env['GIT_EXTERNAL_DIFF']
1135 subprocess2.call(
1136 ['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder'] + args,
1137 env=env)
1138
1139 if settings.GetIsGerrit(): 1143 if settings.GetIsGerrit():
1140 return GerritUpload(options, args, cl) 1144 return GerritUpload(options, args, cl)
1141 return RietveldUpload(options, args, cl) 1145 return RietveldUpload(options, args, cl)
1142 1146
1143 1147
1144 def IsSubmoduleMergeCommit(ref): 1148 def IsSubmoduleMergeCommit(ref):
1145 # When submodules are added to the repo, we expect there to be a single 1149 # When submodules are added to the repo, we expect there to be a single
1146 # non-git-svn merge commit at remote HEAD with a signature comment. 1150 # non-git-svn merge commit at remote HEAD with a signature comment.
1147 pattern = '^SVN changes up to revision [0-9]*$' 1151 pattern = '^SVN changes up to revision [0-9]*$'
1148 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref] 1152 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref]
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 1262
1259 if cl.GetIssue(): 1263 if cl.GetIssue():
1260 description += "\n\nReview URL: %s" % cl.GetIssueURL() 1264 description += "\n\nReview URL: %s" % cl.GetIssueURL()
1261 1265
1262 if options.contributor: 1266 if options.contributor:
1263 description += "\nPatch from %s." % options.contributor 1267 description += "\nPatch from %s." % options.contributor
1264 print 'Description:', repr(description) 1268 print 'Description:', repr(description)
1265 1269
1266 branches = [base_branch, cl.GetBranchRef()] 1270 branches = [base_branch, cl.GetBranchRef()]
1267 if not options.force: 1271 if not options.force:
1268 subprocess2.call(['git', 'diff', '--stat'] + branches) 1272 print_stats(branches)
1269 ask_for_data('About to commit; enter to confirm.') 1273 ask_for_data('About to commit; enter to confirm.')
1270 1274
1271 # We want to squash all this branch's commits into one commit with the proper 1275 # We want to squash all this branch's commits into one commit with the proper
1272 # description. We do this by doing a "reset --soft" to the base branch (which 1276 # description. We do this by doing a "reset --soft" to the base branch (which
1273 # keeps the working copy the same), then dcommitting that. If origin/master 1277 # keeps the working copy the same), then dcommitting that. If origin/master
1274 # has a submodule merge commit, we'll also need to cherry-pick the squashed 1278 # has a submodule merge commit, we'll also need to cherry-pick the squashed
1275 # commit onto a branch based on the git-svn head. 1279 # commit onto a branch based on the git-svn head.
1276 MERGE_BRANCH = 'git-cl-commit' 1280 MERGE_BRANCH = 'git-cl-commit'
1277 CHERRY_PICK_BRANCH = 'git-cl-cherry-pick' 1281 CHERRY_PICK_BRANCH = 'git-cl-cherry-pick'
1278 # Delete the branches if they exist. 1282 # Delete the branches if they exist.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 1604 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
1601 1605
1602 # Not a known command. Default to help. 1606 # Not a known command. Default to help.
1603 GenUsage(parser, 'help') 1607 GenUsage(parser, 'help')
1604 return CMDhelp(parser, argv) 1608 return CMDhelp(parser, argv)
1605 1609
1606 1610
1607 if __name__ == '__main__': 1611 if __name__ == '__main__':
1608 fix_encoding.fix_encoding() 1612 fix_encoding.fix_encoding()
1609 sys.exit(main(sys.argv[1:])) 1613 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698