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 and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
9 | 9 |
10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
(...skipping 3686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3697 patch_data = cl._codereview_impl.GetPatchSetDiff(issue, patchset) | 3697 patch_data = cl._codereview_impl.GetPatchSetDiff(issue, patchset) |
3698 else: | 3698 else: |
3699 # Assume it's a URL to the patch. Default to https. | 3699 # Assume it's a URL to the patch. Default to https. |
3700 issue_url = gclient_utils.UpgradeToHttps(issue_arg) | 3700 issue_url = gclient_utils.UpgradeToHttps(issue_arg) |
3701 match = re.match(r'(.*?)/download/issue(\d+)_(\d+).diff', issue_url) | 3701 match = re.match(r'(.*?)/download/issue(\d+)_(\d+).diff', issue_url) |
3702 if not match: | 3702 if not match: |
3703 DieWithError('Must pass an issue ID or full URL for ' | 3703 DieWithError('Must pass an issue ID or full URL for ' |
3704 '\'Download raw patch set\'') | 3704 '\'Download raw patch set\'') |
3705 issue = int(match.group(2)) | 3705 issue = int(match.group(2)) |
3706 cl = Changelist(issue=issue, codereview='rietveld', | 3706 cl = Changelist(issue=issue, codereview='rietveld', |
3707 rietvled_server=match.group(1), auth_config=auth_config) | 3707 rietveld_server=match.group(1), auth_config=auth_config) |
3708 patchset = int(match.group(3)) | 3708 patchset = int(match.group(3)) |
3709 patch_data = urllib2.urlopen(issue_arg).read() | 3709 patch_data = urllib2.urlopen(issue_arg).read() |
3710 | 3710 |
3711 # Switch up to the top-level directory, if necessary, in preparation for | 3711 # Switch up to the top-level directory, if necessary, in preparation for |
3712 # applying the patch. | 3712 # applying the patch. |
3713 top = settings.GetRelativeRoot() | 3713 top = settings.GetRelativeRoot() |
3714 if top: | 3714 if top: |
3715 os.chdir(top) | 3715 os.chdir(top) |
3716 | 3716 |
3717 # Git patches have a/ at the beginning of source paths. We strip that out | 3717 # Git patches have a/ at the beginning of source paths. We strip that out |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4477 if __name__ == '__main__': | 4477 if __name__ == '__main__': |
4478 # These affect sys.stdout so do it outside of main() to simplify mocks in | 4478 # These affect sys.stdout so do it outside of main() to simplify mocks in |
4479 # unit testing. | 4479 # unit testing. |
4480 fix_encoding.fix_encoding() | 4480 fix_encoding.fix_encoding() |
4481 colorama.init() | 4481 colorama.init() |
4482 try: | 4482 try: |
4483 sys.exit(main(sys.argv[1:])) | 4483 sys.exit(main(sys.argv[1:])) |
4484 except KeyboardInterrupt: | 4484 except KeyboardInterrupt: |
4485 sys.stderr.write('interrupted\n') | 4485 sys.stderr.write('interrupted\n') |
4486 sys.exit(1) | 4486 sys.exit(1) |
OLD | NEW |