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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 def ask_for_data(prompt): | 88 def ask_for_data(prompt): |
89 try: | 89 try: |
90 return raw_input(prompt) | 90 return raw_input(prompt) |
91 except KeyboardInterrupt: | 91 except KeyboardInterrupt: |
92 # Hide the exception. | 92 # Hide the exception. |
93 sys.exit(1) | 93 sys.exit(1) |
94 | 94 |
95 | 95 |
96 def git_set_branch_value(key, value): | 96 def git_set_branch_value(key, value): |
97 branch = Changelist().GetBranch() | 97 branch = Changelist().GetBranch() |
98 if branch: | 98 if branch: |
M-A Ruel
2013/03/17 19:40:31
I think I'd prefer this form instead;
if not bran
Roger Tawa OOO till Jul 10th
2013/03/18 20:40:28
Done.
| |
99 cmd = ['config'] | |
100 if isinstance(value, int): | |
101 cmd.append('--int') | |
99 git_key = 'branch.%s.%s' % (branch, key) | 102 git_key = 'branch.%s.%s' % (branch, key) |
100 RunGit(['config', '--int', git_key, "%d" % value]) | 103 RunGit(cmd + [git_key, str(value)]) |
101 | 104 |
102 | 105 |
103 def git_get_branch_default(key, default): | 106 def git_get_branch_default(key, default): |
104 branch = Changelist().GetBranch() | 107 branch = Changelist().GetBranch() |
105 if branch: | 108 if branch: |
106 git_key = 'branch.%s.%s' % (branch, key) | 109 git_key = 'branch.%s.%s' % (branch, key) |
107 (_, stdout) = RunGitWithCode(['config', '--int', '--get', git_key]) | 110 (_, stdout) = RunGitWithCode(['config', '--int', '--get', git_key]) |
108 try: | 111 try: |
109 return int(stdout.strip()) | 112 return int(stdout.strip()) |
110 except ValueError: | 113 except ValueError: |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1281 verbose=options.verbose, | 1284 verbose=options.verbose, |
1282 change=change) | 1285 change=change) |
1283 if not hook_results.should_continue(): | 1286 if not hook_results.should_continue(): |
1284 return 1 | 1287 return 1 |
1285 if not options.reviewers and hook_results.reviewers: | 1288 if not options.reviewers and hook_results.reviewers: |
1286 options.reviewers = hook_results.reviewers | 1289 options.reviewers = hook_results.reviewers |
1287 | 1290 |
1288 print_stats(options.similarity, options.find_copies, args) | 1291 print_stats(options.similarity, options.find_copies, args) |
1289 if settings.GetIsGerrit(): | 1292 if settings.GetIsGerrit(): |
1290 return GerritUpload(options, args, cl) | 1293 return GerritUpload(options, args, cl) |
1291 return RietveldUpload(options, args, cl) | 1294 ret = RietveldUpload(options, args, cl) |
1295 if not ret: | |
1296 git_set_branch_value('last-upload-hash', RunGit(['rev-parse', 'HEAD'])) | |
1297 | |
1298 return ret | |
1292 | 1299 |
1293 | 1300 |
1294 def IsSubmoduleMergeCommit(ref): | 1301 def IsSubmoduleMergeCommit(ref): |
1295 # When submodules are added to the repo, we expect there to be a single | 1302 # When submodules are added to the repo, we expect there to be a single |
1296 # non-git-svn merge commit at remote HEAD with a signature comment. | 1303 # non-git-svn merge commit at remote HEAD with a signature comment. |
1297 pattern = '^SVN changes up to revision [0-9]*$' | 1304 pattern = '^SVN changes up to revision [0-9]*$' |
1298 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref] | 1305 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref] |
1299 return RunGit(cmd) != '' | 1306 return RunGit(cmd) != '' |
1300 | 1307 |
1301 | 1308 |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1883 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1890 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1884 | 1891 |
1885 # Not a known command. Default to help. | 1892 # Not a known command. Default to help. |
1886 GenUsage(parser, 'help') | 1893 GenUsage(parser, 'help') |
1887 return CMDhelp(parser, argv) | 1894 return CMDhelp(parser, argv) |
1888 | 1895 |
1889 | 1896 |
1890 if __name__ == '__main__': | 1897 if __name__ == '__main__': |
1891 fix_encoding.fix_encoding() | 1898 fix_encoding.fix_encoding() |
1892 sys.exit(main(sys.argv[1:])) | 1899 sys.exit(main(sys.argv[1:])) |
OLD | NEW |