mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
Add a family of git-commands to assist with the management of multiple CLs/branches.
git-rebase-update - ensure all branches are up to date git-new-branch - create branches git-rename-branch - rename a branch while preserving parentage relationships git-reparent-branch - change the parent of a branch, including rebasing it correctly onto that new parent. git-squash-branch - collapse a branch into a single commit git-upstream-diff - show the diff between the current branch and it's upstream branch git-mark-merge-base - explicitly set what you want the above tools to consider the merge-base for the current branch. R=agable@chromium.org, hinoka@chromium.org, stip@chromium.org, szager@chromium.org BUG=261738 Review URL: https://codereview.chromium.org/184253003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@259520 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
68
git_mark_merge_base.py
Executable file
68
git_mark_merge_base.py
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""
|
||||
Explicitly set/remove/print the merge-base for the current branch.
|
||||
|
||||
This manually set merge base will be a stand-in for `git merge-base` for the
|
||||
purposes of the chromium depot_tools git extensions. Passing no arguments will
|
||||
just print the effective merge base for the current branch.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from subprocess2 import CalledProcessError
|
||||
|
||||
from git_common import remove_merge_base, manual_merge_base, current_branch
|
||||
from git_common import get_or_create_merge_base, hash_one
|
||||
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser(
|
||||
description=__doc__.strip().splitlines()[0],
|
||||
epilog=' '.join(__doc__.strip().splitlines()[1:]))
|
||||
g = parser.add_mutually_exclusive_group()
|
||||
g.add_argument(
|
||||
'merge_base', nargs='?',
|
||||
help='The new hash to use as the merge base for the current branch'
|
||||
)
|
||||
g.add_argument('--delete', '-d', action='store_true',
|
||||
help='Remove the set mark.')
|
||||
opts = parser.parse_args(argv)
|
||||
|
||||
cur = current_branch()
|
||||
|
||||
if opts.delete:
|
||||
try:
|
||||
remove_merge_base(cur)
|
||||
except CalledProcessError:
|
||||
print "No merge base currently exists for %s." % cur
|
||||
return 0
|
||||
|
||||
if opts.merge_base:
|
||||
try:
|
||||
opts.merge_base = hash_one(opts.merge_base)
|
||||
except CalledProcessError:
|
||||
print >> sys.stderr, (
|
||||
'fatal: could not resolve %s as a commit' % (opts.merge_base)
|
||||
)
|
||||
return 1
|
||||
|
||||
manual_merge_base(cur, opts.merge_base)
|
||||
|
||||
ret = 0
|
||||
actual = get_or_create_merge_base(cur)
|
||||
if opts.merge_base and opts.merge_base != actual:
|
||||
ret = 1
|
||||
print "Invalid merge_base %s" % opts.merge_base
|
||||
|
||||
print "merge_base(%s): %s" % (cur, actual)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
Reference in New Issue
Block a user