Josip Sokcevic | 4de5dea | 2022-03-23 21:15:14 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
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 | |
| 6 | import argparse |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 7 | |
| 8 | |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 9 | _HELP_MESSAGE = """\ |
| 10 | git drover has been deprecated in favor of cherry-picking using Gerrit. |
| 11 | Try it, it's faster! |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 12 | |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 13 | See https://www.chromium.org/developers/how-tos/drover for instructions. |
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 | If the Gerrit UI is not sufficient, and you know what you're doing: |
| 16 | git checkout -b branch-name refs/remotes/branch-heads/{branch} |
| 17 | git cherry-pick -x {cherry_pick} |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 18 | |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 19 | If you have to do a lot of merges, consider using multiple working directories |
| 20 | in your checkout: |
| 21 | 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] | 22 | """ |
| 23 | |
| 24 | |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 25 | def main(): |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 26 | parser = argparse.ArgumentParser(description=_HELP_MESSAGE) |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 27 | parser.add_argument( |
| 28 | '--branch', |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 29 | default='BRANCH', |
| 30 | metavar='BRANCH', |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 31 | type=str, |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 32 | 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] | 33 | parser.add_argument( |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 34 | '--cherry-pick', |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 35 | default='HASH_OF_THE_COMMIT_TO_CHERRY_PICK', |
| 36 | metavar='HASH_OF_THE_COMMIT_TO_CHERRY_PICK', |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 37 | type=str, |
sammc@chromium.org | 8990189 | 2015-11-03 00:57:48 +0000 | [diff] [blame] | 38 | help=('the change to cherry-pick; this can be any string ' |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 39 | 'that unambiguosly refers to a revision not involving HEAD')) |
| 40 | options, _ = parser.parse_known_args() |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 41 | |
Edward Lesmes | 1ea2333 | 2021-02-01 17:48:56 +0000 | [diff] [blame] | 42 | print(_HELP_MESSAGE.format( |
| 43 | branch=options.branch, cherry_pick=options.cherry_pick)) |
sammc@chromium.org | 900a33f | 2015-09-29 06:57:09 +0000 | [diff] [blame] | 44 | |
| 45 | if __name__ == '__main__': |
| 46 | main() |