blob: 7fb089763cf51ae5bc1ea27099c456bfc3e8587a [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
6import argparse
sammc@chromium.org900a33f2015-09-29 06:57:09 +00007
8
Edward Lesmes1ea23332021-02-01 17:48:56 +00009_HELP_MESSAGE = """\
10git drover has been deprecated in favor of cherry-picking using Gerrit.
11Try it, it's faster!
sammc@chromium.org89901892015-11-03 00:57:48 +000012
Edward Lesmes1ea23332021-02-01 17:48:56 +000013See https://www.chromium.org/developers/how-tos/drover for instructions.
sammc@chromium.org89901892015-11-03 00:57:48 +000014
Edward Lesmes1ea23332021-02-01 17:48:56 +000015If 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.org89901892015-11-03 00:57:48 +000018
Edward Lesmes1ea23332021-02-01 17:48:56 +000019If you have to do a lot of merges, consider using multiple working directories
20in your checkout:
21https://www.chromium.org/developers/how-tos/get-the-code/multiple-working-directories
sammc@chromium.org89901892015-11-03 00:57:48 +000022"""
23
24
sammc@chromium.org900a33f2015-09-29 06:57:09 +000025def main():
Edward Lesmes1ea23332021-02-01 17:48:56 +000026 parser = argparse.ArgumentParser(description=_HELP_MESSAGE)
sammc@chromium.org900a33f2015-09-29 06:57:09 +000027 parser.add_argument(
28 '--branch',
Edward Lesmes1ea23332021-02-01 17:48:56 +000029 default='BRANCH',
30 metavar='BRANCH',
sammc@chromium.org900a33f2015-09-29 06:57:09 +000031 type=str,
sammc@chromium.org900a33f2015-09-29 06:57:09 +000032 help='the name of the branch to which to cherry-pick; e.g. 1234')
Edward Lesmes1ea23332021-02-01 17:48:56 +000033 parser.add_argument(
sammc@chromium.org89901892015-11-03 00:57:48 +000034 '--cherry-pick',
Edward Lesmes1ea23332021-02-01 17:48:56 +000035 default='HASH_OF_THE_COMMIT_TO_CHERRY_PICK',
36 metavar='HASH_OF_THE_COMMIT_TO_CHERRY_PICK',
sammc@chromium.org89901892015-11-03 00:57:48 +000037 type=str,
sammc@chromium.org89901892015-11-03 00:57:48 +000038 help=('the change to cherry-pick; this can be any string '
Edward Lesmes1ea23332021-02-01 17:48:56 +000039 'that unambiguosly refers to a revision not involving HEAD'))
40 options, _ = parser.parse_known_args()
sammc@chromium.org900a33f2015-09-29 06:57:09 +000041
Edward Lesmes1ea23332021-02-01 17:48:56 +000042 print(_HELP_MESSAGE.format(
43 branch=options.branch, cherry_pick=options.cherry_pick))
sammc@chromium.org900a33f2015-09-29 06:57:09 +000044
45if __name__ == '__main__':
46 main()