| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # git-cl -- a git-command for integrating reviews on Rietveld | 2 # git-cl -- a git-command for integrating reviews on Rietveld |
| 3 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 3 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 4 | 4 |
| 5 import getpass | 5 import getpass |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import readline | 9 import readline |
| 10 import subprocess | 10 import subprocess |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 "even without uploading for review") | 776 "even without uploading for review") |
| 777 (options, args) = parser.parse_args(args) | 777 (options, args) = parser.parse_args(args) |
| 778 cl = Changelist() | 778 cl = Changelist() |
| 779 | 779 |
| 780 if not args or cmd == 'push': | 780 if not args or cmd == 'push': |
| 781 # Default to merging against our best guess of the upstream branch. | 781 # Default to merging against our best guess of the upstream branch. |
| 782 args = [cl.GetUpstreamBranch()] | 782 args = [cl.GetUpstreamBranch()] |
| 783 | 783 |
| 784 base_branch = args[0] | 784 base_branch = args[0] |
| 785 | 785 |
| 786 # Make sure index is up-to-date before running diff-index. |
| 787 RunGit(['update-index', '--refresh', '-q'], error_ok=True) |
| 786 if RunGit(['diff-index', 'HEAD']): | 788 if RunGit(['diff-index', 'HEAD']): |
| 787 print 'Cannot %s with a dirty tree. You must commit locally first.' % cmd | 789 print 'Cannot %s with a dirty tree. You must commit locally first.' % cmd |
| 788 return 1 | 790 return 1 |
| 789 | 791 |
| 790 # This rev-list syntax means "show all commits not in my branch that | 792 # This rev-list syntax means "show all commits not in my branch that |
| 791 # are in base_branch". | 793 # are in base_branch". |
| 792 upstream_commits = RunGit(['rev-list', '^' + cl.GetBranchRef(), | 794 upstream_commits = RunGit(['rev-list', '^' + cl.GetBranchRef(), |
| 793 base_branch]).splitlines() | 795 base_branch]).splitlines() |
| 794 if upstream_commits: | 796 if upstream_commits: |
| 795 print ('Base branch "%s" has %d commits ' | 797 print ('Base branch "%s" has %d commits ' |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 # "fix" the usage and the description now that we know the subcommand. | 1091 # "fix" the usage and the description now that we know the subcommand. |
| 1090 GenUsage(parser, argv[0]) | 1092 GenUsage(parser, argv[0]) |
| 1091 return command(parser, argv[1:]) | 1093 return command(parser, argv[1:]) |
| 1092 # Not a known command. Default to help. | 1094 # Not a known command. Default to help. |
| 1093 GenUsage(parser, 'help') | 1095 GenUsage(parser, 'help') |
| 1094 return CMDhelp(parser, argv) | 1096 return CMDhelp(parser, argv) |
| 1095 | 1097 |
| 1096 | 1098 |
| 1097 if __name__ == '__main__': | 1099 if __name__ == '__main__': |
| 1098 sys.exit(main(sys.argv[1:])) | 1100 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |