def check_branches(self):
        """Checks if the branch can be renamed.

        We require that the source branch exists, is not the current branch and
        is actually a review branch. We also require that the target branch does
        not exist.

        If successful, sets state to RENAME, otherwise to FINISHED.
        """
        rietveld_info = None
        if utils.branch_exists(self.__target_branch):
            print 'Target branch %r already exists.' % (self.__target_branch,)
            self.state = self.FINISHED
        elif not utils.branch_exists(self.__source_branch):
            print 'Branch %r doesn\'t exist.' % (self.__source_branch,)
            self.state = self.FINISHED
        elif self.__source_branch == utils.get_current_branch():
            print 'Can\'t rename branch you\'re currently in.'
            self.state = self.FINISHED
        else:
            rietveld_info = utils.RietveldInfo.from_branch(
                    branch_name=self.__source_branch)
            if rietveld_info is None:
                print ('Branch %r has no review in progress.' %
                       (self.__source_branch,))
                print 'Instead, use the git command:'
                print '\tgit branch -m %s %s' % (self.__source_branch,
                                                 self.__target_branch)
                self.state = self.FINISHED
            else:
                self.state = self.RENAME
        self.advance(rietveld_info)
dataset/ETHPy150Open googlearchive/git-rv/mv_branch.py/RenameBranchAction.check_branches/original