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 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2634 cmd.append('--3way') | 2634 cmd.append('--3way') |
2635 try: | 2635 try: |
2636 subprocess2.check_call(cmd, env=GetNoGitPagerEnv(), | 2636 subprocess2.check_call(cmd, env=GetNoGitPagerEnv(), |
2637 stdin=patch_data, stdout=subprocess2.VOID) | 2637 stdin=patch_data, stdout=subprocess2.VOID) |
2638 except subprocess2.CalledProcessError: | 2638 except subprocess2.CalledProcessError: |
2639 print 'Failed to apply the patch' | 2639 print 'Failed to apply the patch' |
2640 return 1 | 2640 return 1 |
2641 | 2641 |
2642 # If we had an issue, commit the current state and register the issue. | 2642 # If we had an issue, commit the current state and register the issue. |
2643 if not nocommit: | 2643 if not nocommit: |
2644 RunGit(['commit', '-m', ('patch from issue %(i)s at patchset ' | 2644 RunGit(['commit', '-m', (cl.GetDescription() + '\n\n' + |
| 2645 'patch from issue %(i)s at patchset ' |
2645 '%(p)s (http://crrev.com/%(i)s#ps%(p)s)' | 2646 '%(p)s (http://crrev.com/%(i)s#ps%(p)s)' |
2646 % {'i': issue, 'p': patchset})]) | 2647 % {'i': issue, 'p': patchset})]) |
2647 cl = Changelist(auth_config=auth_config) | 2648 cl = Changelist(auth_config=auth_config) |
2648 cl.SetIssue(issue) | 2649 cl.SetIssue(issue) |
2649 cl.SetPatchset(patchset) | 2650 cl.SetPatchset(patchset) |
2650 print "Committed patch locally." | 2651 print "Committed patch locally." |
2651 else: | 2652 else: |
2652 print "Patch applied to index." | 2653 print "Patch applied to index." |
2653 return 0 | 2654 return 0 |
2654 | 2655 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3204 if __name__ == '__main__': | 3205 if __name__ == '__main__': |
3205 # These affect sys.stdout so do it outside of main() to simplify mocks in | 3206 # These affect sys.stdout so do it outside of main() to simplify mocks in |
3206 # unit testing. | 3207 # unit testing. |
3207 fix_encoding.fix_encoding() | 3208 fix_encoding.fix_encoding() |
3208 colorama.init() | 3209 colorama.init() |
3209 try: | 3210 try: |
3210 sys.exit(main(sys.argv[1:])) | 3211 sys.exit(main(sys.argv[1:])) |
3211 except KeyboardInterrupt: | 3212 except KeyboardInterrupt: |
3212 sys.stderr.write('interrupted\n') | 3213 sys.stderr.write('interrupted\n') |
3213 sys.exit(1) | 3214 sys.exit(1) |
OLD | NEW |