Edward Lesmes | 98eda3f | 2019-08-12 21:09:53 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 2 | # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 5 | |
Raul Tambre | 80ee78e | 2019-05-06 22:41:05 +0000 | [diff] [blame] | 6 | from __future__ import print_function |
| 7 | |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 8 | import argparse |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 9 | |
| 10 | |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 11 | _HELP_MESSAGE = """\ |
| 12 | git drover has been deprecated in favor of cherry-picking using Gerrit. |
| 13 | Try it, it's faster! |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 14 | |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 15 | See https://www.chromium.org/developers/how-tos/drover for instructions. |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 16 | |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 17 | If the Gerrit UI is not sufficient, and you know what you're doing: |
| 18 | git checkout -b branch-name refs/remotes/branch-heads/{branch} |
| 19 | git cherry-pick -x {cherry_pick} |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 20 | |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 21 | If you have to do a lot of merges, consider using multiple working directories |
| 22 | in your checkout: |
| 23 | https://www.chromium.org/developers/how-tos/get-the-code/multiple-working-directories |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 24 | """ |
| 25 | |
| 26 | |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 27 | def main(): |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 28 | parser = argparse.ArgumentParser(description=_HELP_MESSAGE) |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 29 | parser.add_argument( |
| 30 | '--branch', |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 31 | default='BRANCH', |
| 32 | metavar='BRANCH', |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 33 | type=str, |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 34 | help='the name of the branch to which to cherry-pick; e.g. 1234') |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 35 | parser.add_argument( |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 36 | '--cherry-pick', |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 37 | default='HASH_OF_THE_COMMIT_TO_CHERRY_PICK', |
| 38 | metavar='HASH_OF_THE_COMMIT_TO_CHERRY_PICK', |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 39 | type=str, |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 40 | help=('the change to cherry-pick; this can be any string ' |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 41 | 'that unambiguosly refers to a revision not involving HEAD')) |
| 42 | options, _ = parser.parse_known_args() |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 43 | |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 44 | print(_HELP_MESSAGE.format( |
| 45 | branch=options.branch, cherry_pick=options.cherry_pick)) |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 46 | |
| 47 | if __name__ == '__main__': |
| 48 | main() |