Chromium Code Reviews| 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 datetime | 10 import datetime |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 if 'GERRIT_HOST' in keyvals: | 1067 if 'GERRIT_HOST' in keyvals: |
| 1068 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) | 1068 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) |
| 1069 | 1069 |
| 1070 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: | 1070 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: |
| 1071 #should be of the form | 1071 #should be of the form |
| 1072 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof | 1072 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof |
| 1073 #ORIGIN_URL_CONFIG: http://src.chromium.org/git | 1073 #ORIGIN_URL_CONFIG: http://src.chromium.org/git |
| 1074 RunGit(['config', keyvals['PUSH_URL_CONFIG'], | 1074 RunGit(['config', keyvals['PUSH_URL_CONFIG'], |
| 1075 keyvals['ORIGIN_URL_CONFIG']]) | 1075 keyvals['ORIGIN_URL_CONFIG']]) |
| 1076 | 1076 |
| 1077 if 'PROJECT' in keyvals: | |
| 1078 branchref = RunGit(['symbolic-ref', 'HEAD']).strip() | |
|
iannucci
2014/05/27 18:00:33
What happens when the user has a detached HEAD?
sheyang
2014/06/02 22:56:48
Discussed offline. This will be saved into .git/co
| |
| 1079 branch = ShortBranchName(branchref) | |
|
iannucci
2014/05/27 18:00:33
what does shortbranchname do? Is this the same as
sheyang
2014/06/02 22:56:48
It converts the name like 'refs/heads/foo' to 'foo
| |
| 1080 RunGit(['config', 'branch.%s.project' % branch, keyvals['PROJECT']], | |
|
agable
2014/05/30 14:24:07
a) Why are you saving the PROJECT value in .git/co
sheyang
2014/06/02 22:56:48
1. Yep it's not ideal... Just to make it consisten
| |
| 1081 error_ok=False) | |
| 1082 | |
| 1077 | 1083 |
| 1078 def urlretrieve(source, destination): | 1084 def urlretrieve(source, destination): |
| 1079 """urllib is broken for SSL connections via a proxy therefore we | 1085 """urllib is broken for SSL connections via a proxy therefore we |
| 1080 can't use urllib.urlretrieve().""" | 1086 can't use urllib.urlretrieve().""" |
| 1081 with open(destination, 'w') as f: | 1087 with open(destination, 'w') as f: |
| 1082 f.write(urllib2.urlopen(source).read()) | 1088 f.write(urllib2.urlopen(source).read()) |
| 1083 | 1089 |
| 1084 | 1090 |
| 1085 def hasSheBang(fname): | 1091 def hasSheBang(fname): |
| 1086 """Checks fname is a #! script.""" | 1092 """Checks fname is a #! script.""" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1605 keys = dict(line.split(': ', 1) for line in data.splitlines() | 1611 keys = dict(line.split(': ', 1) for line in data.splitlines() |
| 1606 if ': ' in line) | 1612 if ': ' in line) |
| 1607 remote_url = keys.get('URL', None) | 1613 remote_url = keys.get('URL', None) |
| 1608 else: | 1614 else: |
| 1609 if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch(): | 1615 if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch(): |
| 1610 remote_url = (cl.GetRemoteUrl() + '@' | 1616 remote_url = (cl.GetRemoteUrl() + '@' |
| 1611 + cl.GetUpstreamBranch().split('/')[-1]) | 1617 + cl.GetUpstreamBranch().split('/')[-1]) |
| 1612 if remote_url: | 1618 if remote_url: |
| 1613 upload_args.extend(['--base_url', remote_url]) | 1619 upload_args.extend(['--base_url', remote_url]) |
| 1614 | 1620 |
| 1621 project = RunGit(['config', 'branch.%s.project' % cl.GetBranch()], | |
| 1622 error_ok=True).strip() | |
| 1623 if project: | |
| 1624 upload_args.extend(['--project', project]) | |
| 1625 | |
| 1615 try: | 1626 try: |
| 1616 upload_args = ['upload'] + upload_args + args | 1627 upload_args = ['upload'] + upload_args + args |
| 1617 logging.info('upload.RealMain(%s)', upload_args) | 1628 logging.info('upload.RealMain(%s)', upload_args) |
| 1618 issue, patchset = upload.RealMain(upload_args) | 1629 issue, patchset = upload.RealMain(upload_args) |
| 1619 issue = int(issue) | 1630 issue = int(issue) |
| 1620 patchset = int(patchset) | 1631 patchset = int(patchset) |
| 1621 except KeyboardInterrupt: | 1632 except KeyboardInterrupt: |
| 1622 sys.exit(1) | 1633 sys.exit(1) |
| 1623 except: | 1634 except: |
| 1624 # If we got an exception after the user typed a description for their | 1635 # If we got an exception after the user typed a description for their |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2600 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2611 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2601 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2612 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2602 | 2613 |
| 2603 | 2614 |
| 2604 if __name__ == '__main__': | 2615 if __name__ == '__main__': |
| 2605 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2616 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2606 # unit testing. | 2617 # unit testing. |
| 2607 fix_encoding.fix_encoding() | 2618 fix_encoding.fix_encoding() |
| 2608 colorama.init() | 2619 colorama.init() |
| 2609 sys.exit(main(sys.argv[1:])) | 2620 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |