Print error and exit if the current branch is not of a given type.

    Args:
        branch_type (str):
            The branch type. This assumes the branch is in the '<type>/<title>`
            format.
517348
def assert_branch_type(branch_type):
    # type: (str) -> None
    
    branch = git.current_branch(refresh=True)

    if branch.type != branch_type:
        if context.get('pretend', False):
            log.info("Would assert that you're on a <33>{}/*<32> branch",
                     branch_type)
        else:
            log.err("Not on a <33>{}<31> branch!", branch_type)
            fmt = ("The branch must follow <33>{required_type}/<name><31>"
                   "format and your branch is called <33>{name}<31>.")
            log.err(fmt, required_type=branch_type, name=branch.name)
            sys.exit(1)
30443
def check_type(self, value):
    

    if self.null and value is None:
      return
    if self.type is not None and not isinstance(value, self.type):
      msg = '{0!r} expected type {1}'
      raise TypeError(msg.format(self.full_name, self.type.__name__))
138815
def _handle_exception(ignore_callback_errors, print_callback_errors, obj,
                      cb_event=None, node=None):
    
    if not hasattr(obj, '_vispy_err_registry'):
        obj._vispy_err_registry = {}
    registry = obj._vispy_err_registry

    if cb_event is not None:
        cb, event = cb_event
        exp_type = 'callback'
    else:
        exp_type = 'node'
    type_, value, tb = sys.exc_info()
    tb = tb.tb_next  # Skip *this* frame
    sys.last_type = type_
    sys.last_value = value
    sys.last_traceback = tb
    del tb  # Get rid of it in this namespace
    # Handle
    if not ignore_callback_errors:
        raise
    if print_callback_errors != "never":
        this_print = 'full'
        if print_callback_errors in ('first', 'reminders'):
            # need to check to see if we've hit this yet
            if exp_type == 'callback':
                key = repr(cb) + repr(event)
            else:
                key = repr(node)
            if key in registry:
                registry[key] += 1
                if print_callback_errors == 'first':
                    this_print = None
                else:  # reminders
                    ii = registry[key]
                    # Use logarithmic selection
                    # (1, 2, ..., 10, 20, ..., 100, 200, ...)
                    if ii == (2 ** int(np.log2(ii))):
                        this_print = ii
                    else:
                        this_print = None
            else:
                registry[key] = 1
        if this_print == 'full':
            logger.log_exception()
            if exp_type == 'callback':
                logger.error("Invoking %s for %s" % (cb, event))
            else:  # == 'node':
                logger.error("Drawing node %s" % node)
        elif this_print is not None:
            if exp_type == 'callback':
                logger.error("Invoking %s repeat %s"
                             % (cb, this_print))
            else:  # == 'node':
                logger.error("Drawing node %s repeat %s"
                             % (node, this_print))
3399
def error(self, message):
        
        self.print_usage(_sys.stderr)
        self.exit(2, _('%s: error: %s\n') % (self.prog, message))
188636
def coerce_feature_branch(value):
    
    # Repository objects pass through untouched.
    if isinstance(value, FeatureBranchSpec):
        return value
    # We expect a string with a name or URL.
    if not isinstance(value, string_types):
        msg = "Expected string or FeatureBranchSpec object as argument, got %s instead!"
        raise ValueError(msg % type(value))
    return FeatureBranchSpec(expression=value)
148185
def _check_type(name, obj, expected_type):
    
    if not isinstance(obj, expected_type):
        raise TypeError(
            '"%s" must be an a %s' % (name, expected_type.__name__)
        )
1113494
def is_type_II_branch(u, v, dfs_data):
    """"""
    if u != a(v, dfs_data):
        return False
    if u < L2(v, dfs_data):
        return True
    return False
239880
def print_traceback(self):
        
        traceback.print_exception(self.etype, self.value, self.traceback)
1145584
def rmtree (self, errors='warn'):
        
        import shutil

        if errors == 'ignore':
            ignore_errors = True
            onerror = None
        elif errors == 'warn':
            ignore_errors = False
            from .cli import warn

            def onerror (func, path, exc_info):
                warn ('couldn\'t rmtree %s: in %s of %s: %s', self, func.__name__,
                      path, exc_info[1])
        else:
            raise ValueError ('unexpected "errors" keyword %r' % (errors,))

        shutil.rmtree (text_type (self), ignore_errors=ignore_errors, onerror=onerror)
        return self
1333889
def pyError(self, type, value, traceback):
        '''
        '''
        sys.stderr.write("Exception thrown during EWrapper method dispatch:\n")
        print_exception(type, value, traceback)
190133
def _check_branch(self, revision, branch):
        '''
        
        '''

        # Get a changelog
        clog_url = self.hg_url / branch / 'json-log' / revision
        try:
            Log.note("Searching through changelog {{url}}", url=clog_url)
            clog_obj = http.get_json(clog_url, retry=RETRY)
            if isinstance(clog_obj, (text_type, str)):
                Log.note(
                    "Revision {{cset}} does not exist in the {{branch}} branch",
                    cset=revision, branch=branch
                )
                return False
        except Exception as e:
            Log.note("Unexpected error getting changset-log for {{url}}: {{error}}", url=clog_url, error=e)
            return False
        return True
1061690
def exit_with_error(format_, message):
    
    if format_ == "text" or format_ == "markdown":
        log.error(message)
    elif format_ == "json":
        result = {"success": False, "error": str(message), "issues": []}
        print(json.dumps(result))
    else:
        result = [
            {
                "issues": [],
                "sourceType": "",
                "sourceFormat": "",
                "sourceList": [],
                "meta": {
                    "logs": [{"level": "error", "hidden": "true", "msg": message}]
                },
            }
        ]
        print(json.dumps(result))
    sys.exit()
597007
def is_branch?(branch)
      branch_names = self.branches.map {|b| b.name}
      branch_names.include?(branch)
    end
930541
protected function assertBranchMatchesUpstream($current_branch) {
    $branch_matches_upstream = $this->_exec("git diff $current_branch upstream/$current_branch --quiet")->wasSuccessful();
    if (!$branch_matches_upstream) {
      $this->logger->warning("$current_branch does not match upstream/$current_branch.");
      $this->logger->warning("Continuing will cause you to lose all local changes!");
      $continue = $this->confirm("Continue?");
      if (!$continue) {
        throw new BltException("Release terminated by user.");
      }
    }
  }
1017687
def git_branch_delete(branch_name):
    # type: (str) -> None
    
    if branch_name not in git.protected_branches():
        log.info("Deleting branch <33>{}", branch_name)
        shell.run('git branch -d {}'.format(branch_name))
1201542
def _print_sql_with_error(self, sql, error_line):
        
        if os.linesep in sql:
            lines = sql.split(os.linesep)
            digits = math.ceil(math.log(len(lines) + 1, 10))
            i = 1
            for line in lines:
                if i == error_line:
                    self._io.text('<error>{0:{width}} {1}</error>'.format(i, line, width=digits, ))
                else:
                    self._io.text('{0:{width}} {1}'.format(i, line, width=digits, ))
                i += 1
        else:
            self._io.text(sql)
90569
def _exception(etype, eval_, etrace):
        
        if hasattr(sys, 'ps1') or not sys.stderr.isatty():
            # we are in interactive mode or we don't have a tty-like
            # device, so we call the default hook
            sys.__excepthook__(etype, eval_, etrace)
        else:
            # we are NOT in interactive mode, print the exception...
            traceback.print_exception(etype, eval_, etrace, limit=2,
                                      file=sys.stdout)
            six.print_()
            # ...then start the debugger in post-mortem mode.
            pdb.pm()