blob: 524d967b70e1abbab36400c50849f8a66cd490ae [file] [log] [blame]
Josip Sokcevic4de5dea2022-03-23 21:15:14 +00001#!/usr/bin/env python3
sammc@chromium.org900a33f2015-09-29 06:57:09 +00002# 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.org900a33f2015-09-29 06:57:09 +00005
Raul Tambre80ee78e2019-05-06 22:41:05 +00006from __future__ import print_function
7
sammc@chromium.org900a33f2015-09-29 06:57:09 +00008import argparse
sammc@chromium.org900a33f2015-09-29 06:57:09 +00009
10
Edward Lesmes1ea23332021-02-01 17:48:56 +000011_HELP_MESSAGE = """\
12git drover has been deprecated in favor of cherry-picking using Gerrit.
13Try it, it's faster!
sammc@chromium.org89901892015-11-03 00:57:48 +000014
Edward Lesmes1ea23332021-02-01 17:48:56 +000015See https://www.chromium.org/developers/how-tos/drover for instructions.
sammc@chromium.org89901892015-11-03 00:57:48 +000016
Edward Lesmes1ea23332021-02-01 17:48:56 +000017If 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.org89901892015-11-03 00:57:48 +000020
Edward Lesmes1ea23332021-02-01 17:48:56 +000021If you have to do a lot of merges, consider using multiple working directories
22in your checkout:
23https://www.chromium.org/developers/how-tos/get-the-code/multiple-working-directories
sammc@chromium.org89901892015-11-03 00:57:48 +000024"""
25
26
sammc@chromium.org900a33f2015-09-29 06:57:09 +000027def main():
Edward Lesmes1ea23332021-02-01 17:48:56 +000028 parser = argparse.ArgumentParser(description=_HELP_MESSAGE)
sammc@chromium.org900a33f2015-09-29 06:57:09 +000029 parser.add_argument(
30 '--branch',
Edward Lesmes1ea23332021-02-01 17:48:56 +000031 default='BRANCH',
32 metavar='BRANCH',
sammc@chromium.org900a33f2015-09-29 06:57:09 +000033 type=str,
sammc@chromium.org900a33f2015-09-29 06:57:09 +000034 help='the name of the branch to which to cherry-pick; e.g. 1234')
Edward Lesmes1ea23332021-02-01 17:48:56 +000035 parser.add_argument(
sammc@chromium.org89901892015-11-03 00:57:48 +000036 '--cherry-pick',
Edward Lesmes1ea23332021-02-01 17:48:56 +000037 default='HASH_OF_THE_COMMIT_TO_CHERRY_PICK',
38 metavar='HASH_OF_THE_COMMIT_TO_CHERRY_PICK',
sammc@chromium.org89901892015-11-03 00:57:48 +000039 type=str,
sammc@chromium.org89901892015-11-03 00:57:48 +000040 help=('the change to cherry-pick; this can be any string '
Edward Lesmes1ea23332021-02-01 17:48:56 +000041 'that unambiguosly refers to a revision not involving HEAD'))
42 options, _ = parser.parse_known_args()
sammc@chromium.org900a33f2015-09-29 06:57:09 +000043
Edward Lesmes1ea23332021-02-01 17:48:56 +000044 print(_HELP_MESSAGE.format(
45 branch=options.branch, cherry_pick=options.cherry_pick))
sammc@chromium.org900a33f2015-09-29 06:57:09 +000046
47if __name__ == '__main__':
48 main()