Sha256: a2d99c9ed0bcb6c998ac12ffeb444a09ac74f1843908d3ba43ee17db91cc4c58

Contents?: true

Size: 1.97 KB

Versions: 50

Compression:

Stored size: 1.97 KB

Contents

#!/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, upstream


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, upstream(cur))

  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__':
  try:
    sys.exit(main(sys.argv[1:]))
  except KeyboardInterrupt:
    sys.stderr.write('interrupted\n')
    sys.exit(1)

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
libv8-7.8.279.23.0beta1 vendor/depot_tools/git_mark_merge_base.py
libv8-7.3.492.27.3beta1 vendor/depot_tools/git_mark_merge_base.py
libv8-7.3.492.27.1 vendor/depot_tools/git_mark_merge_base.py
libv8-7.3.492.27.0 vendor/depot_tools/git_mark_merge_base.py
libv8-7.3.492.27.0beta1 vendor/depot_tools/git_mark_merge_base.py
libv8-6.7.288.46.1 vendor/depot_tools/git_mark_merge_base.py
libv8-6.7.288.46.0 vendor/depot_tools/git_mark_merge_base.py
libv8-6.7.288.46.1beta0 vendor/depot_tools/git_mark_merge_base.py
libv8-6.3.292.48.1 vendor/depot_tools/git_mark_merge_base.py
libv8-6.3.292.48.0 vendor/depot_tools/git_mark_merge_base.py
libv8-6.3.292.48.0beta2 vendor/depot_tools/git_mark_merge_base.py
libv8-6.3.292.48.0beta1 vendor/depot_tools/git_mark_merge_base.py
libv8-6.2.414.42.1 vendor/depot_tools/git_mark_merge_base.py
libv8-6.2.414.42.0 vendor/depot_tools/git_mark_merge_base.py
libv8-6.2.414.42.0beta1 vendor/depot_tools/git_mark_merge_base.py
libv8-6.0.286.54.3 vendor/depot_tools/git_mark_merge_base.py
libv8-6.0.286.54.2 vendor/depot_tools/git_mark_merge_base.py
libv8-6.0.286.54.1 vendor/depot_tools/git_mark_merge_base.py
libv8-6.0.286.54.0 vendor/depot_tools/git_mark_merge_base.py
libv8-6.0.286.54.0beta2 vendor/depot_tools/git_mark_merge_base.py