Chromium Code Reviews| 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 on top of upstream (origin/master). This is different | |
| 8 from 'git branch`, which creates branch on top of current changeset. | |
| 9 """ | |
|
agable
2016/04/12 16:11:17
This description isn't strictly correct. In partic
anatoly techtonik
2016/04/12 20:19:24
Yes, I constantly forgot that `git branch` for rem
agable
2016/04/13 16:41:55
Yeah, I meant the other git-extensions, not gclien
| |
| 10 | |
| 6 import argparse | 11 import argparse |
| 7 import sys | 12 import sys |
| 8 | 13 |
| 9 import subprocess2 | 14 import subprocess2 |
| 10 | 15 |
| 11 from git_common import run, root, set_config, get_or_create_merge_base, tags | 16 from git_common import run, root, set_config, get_or_create_merge_base, tags |
| 12 from git_common import hash_one | 17 from git_common import hash_one |
| 13 | 18 |
| 14 | 19 |
| 15 def main(args): | 20 def main(args): |
| 16 parser = argparse.ArgumentParser( | 21 parser = argparse.ArgumentParser( |
| 17 formatter_class=argparse.ArgumentDefaultsHelpFormatter | 22 formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
| 23 description=__doc__, | |
| 18 ) | 24 ) |
| 19 parser.add_argument('branch_name') | 25 parser.add_argument('branch_name') |
| 20 g = parser.add_mutually_exclusive_group() | 26 g = parser.add_mutually_exclusive_group() |
| 21 g.add_argument('--upstream-current', '--upstream_current', | 27 g.add_argument('--upstream-current', '--upstream_current', |
| 22 action='store_true', | 28 action='store_true', |
| 23 help='set upstream branch to current branch.') | 29 help='set upstream branch to current branch.') |
| 24 g.add_argument('--upstream', metavar='REF', default=root(), | 30 g.add_argument('--upstream', metavar='REF', default=root(), |
| 25 help='upstream branch (or tag) to track.') | 31 help='upstream branch (or tag) to track.') |
| 26 g.add_argument('--lkgr', action='store_const', const='lkgr', dest='upstream', | 32 g.add_argument('--lkgr', action='store_const', const='lkgr', dest='upstream', |
| 27 help='set basis ref for new branch to lkgr.') | 33 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) | 56 sys.stderr.write('Switched to branch %s.\n' % opts.branch_name) |
| 51 return 0 | 57 return 0 |
| 52 | 58 |
| 53 | 59 |
| 54 if __name__ == '__main__': # pragma: no cover | 60 if __name__ == '__main__': # pragma: no cover |
| 55 try: | 61 try: |
| 56 sys.exit(main(sys.argv[1:])) | 62 sys.exit(main(sys.argv[1:])) |
| 57 except KeyboardInterrupt: | 63 except KeyboardInterrupt: |
| 58 sys.stderr.write('interrupted\n') | 64 sys.stderr.write('interrupted\n') |
| 59 sys.exit(1) | 65 sys.exit(1) |
| OLD | NEW |