| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """ |
| 7 Create new branch tracking origin/master by default. |
| 8 """ |
| 9 |
| 6 import argparse | 10 import argparse |
| 7 import sys | 11 import sys |
| 8 | 12 |
| 9 import subprocess2 | 13 import subprocess2 |
| 10 | 14 |
| 11 from git_common import run, root, set_config, get_or_create_merge_base, tags | 15 from git_common import run, root, set_config, get_or_create_merge_base, tags |
| 12 from git_common import hash_one | 16 from git_common import hash_one |
| 13 | 17 |
| 14 | 18 |
| 15 def main(args): | 19 def main(args): |
| 16 parser = argparse.ArgumentParser( | 20 parser = argparse.ArgumentParser( |
| 17 formatter_class=argparse.ArgumentDefaultsHelpFormatter | 21 formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
| 22 description=__doc__, |
| 18 ) | 23 ) |
| 19 parser.add_argument('branch_name') | 24 parser.add_argument('branch_name') |
| 20 g = parser.add_mutually_exclusive_group() | 25 g = parser.add_mutually_exclusive_group() |
| 21 g.add_argument('--upstream-current', '--upstream_current', | 26 g.add_argument('--upstream-current', '--upstream_current', |
| 22 action='store_true', | 27 action='store_true', |
| 23 help='set upstream branch to current branch.') | 28 help='set upstream branch to current branch.') |
| 24 g.add_argument('--upstream', metavar='REF', default=root(), | 29 g.add_argument('--upstream', metavar='REF', default=root(), |
| 25 help='upstream branch (or tag) to track.') | 30 help='upstream branch (or tag) to track.') |
| 26 g.add_argument('--lkgr', action='store_const', const='lkgr', dest='upstream', | 31 g.add_argument('--lkgr', action='store_const', const='lkgr', dest='upstream', |
| 27 help='set basis ref for new branch to lkgr.') | 32 help='set basis ref for new branch to lkgr.') |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 sys.stderr.write('Switched to branch %s.\n' % opts.branch_name) | 55 sys.stderr.write('Switched to branch %s.\n' % opts.branch_name) |
| 51 return 0 | 56 return 0 |
| 52 | 57 |
| 53 | 58 |
| 54 if __name__ == '__main__': # pragma: no cover | 59 if __name__ == '__main__': # pragma: no cover |
| 55 try: | 60 try: |
| 56 sys.exit(main(sys.argv[1:])) | 61 sys.exit(main(sys.argv[1:])) |
| 57 except KeyboardInterrupt: | 62 except KeyboardInterrupt: |
| 58 sys.stderr.write('interrupted\n') | 63 sys.stderr.write('interrupted\n') |
| 59 sys.exit(1) | 64 sys.exit(1) |
| OLD | NEW |