Ejemplo n.º 1
0
    def _diff_and_commit(self, commit_msg=''):
        """Show diff and offer commit.

        commit_msg is optional.  If it is not there, we get the
        commit_msg from self.data.  That is the usual mode and is at
        least used in prerelease and postrelease.  If it is not there
        either, we ask.
        """
        if not commit_msg:
            if 'commit_msg' not in self.data:
                # Ask until we get a non-empty commit message.
                while not commit_msg:
                    commit_msg = utils.get_input(
                        "What is the commit message? ")
            else:
                commit_msg = self.data['commit_msg']

        diff_cmd = self.vcs.cmd_diff()
        diff = execute_command(diff_cmd)
        if sys.version.startswith('2.6.2'):
            # python2.6.2 bug... http://bugs.python.org/issue5170 This is the
            # spot it can surface as we show a part of the changelog which can
            # contain every kind of character.  The rest is mostly ascii.
            print("Diff results:")
            print(diff)
        else:
            # Common case
            logger.info("The '%s':\n\n%s\n", diff_cmd, diff)
        if utils.ask("OK to commit this"):
            msg = commit_msg % self.data
            msg = self.update_commit_message(msg)
            commit_cmd = self.vcs.cmd_commit(msg)
            commit = execute_command(commit_cmd)
            logger.info(commit)
Ejemplo n.º 2
0
    def _diff_and_commit(self, commit_msg=''):
        """Show diff and offer commit.

        commit_msg is optional.  If it is not there, we get the
        commit_msg from self.data.  That is the usual mode and is at
        least used in prerelease and postrelease.  If it is not there
        either, we ask.
        """
        if not commit_msg:
            if 'commit_msg' not in self.data:
                # Ask until we get a non-empty commit message.
                while not commit_msg:
                    commit_msg = utils.get_input(
                        "What is the commit message? ")
            else:
                commit_msg = self.data['commit_msg']

        diff_cmd = self.vcs.cmd_diff()
        diff = execute_command(diff_cmd)
        if sys.version.startswith('2.6.2'):
            # python2.6.2 bug... http://bugs.python.org/issue5170 This is the
            # spot it can surface as we show a part of the changelog which can
            # contain every kind of character.  The rest is mostly ascii.
            print("Diff results:")
            print(diff)
        else:
            # Common case
            logger.info("The '%s':\n\n%s\n", diff_cmd, diff)
        if utils.ask("OK to commit this"):
            msg = commit_msg % self.data
            msg = self.update_commit_message(msg)
            commit_cmd = self.vcs.cmd_commit(msg)
            commit = execute_command(commit_cmd)
            logger.info(commit)
Ejemplo n.º 3
0
 def _get_message(self):
     """Get changelog message and commit message."""
     message = self.data['message']
     while not message:
         q = "What is the changelog message? "
         message = utils.get_input(q)
     self.data['message'] = message
     if not self.data['commit_msg']:
         self.data['commit_msg'] = message
Ejemplo n.º 4
0
 def _get_message(self):
     """Get changelog message and commit message."""
     message = self.data['message']
     while not message:
         q = "What is the changelog message? "
         message = utils.get_input(q)
     self.data['message'] = message
     if not self.data['commit_msg']:
         # The commit message does %-replacement, so escape any %'s.
         message = message.replace("%", "%%")
         self.data['commit_msg'] = message
Ejemplo n.º 5
0
 def _grab_version(self):
     """Set the version to a non-development version."""
     original_version = self.vcs.version
     logger.debug("Extracted version: %s", original_version)
     if original_version is None:
         logger.critical('No version found.')
         sys.exit(1)
     suggestion = utils.cleanup_version(original_version)
     q = ("Enter version [%s]: " % suggestion)
     new_version = utils.get_input(q).strip()
     if not new_version:
         new_version = suggestion
     self.data['original_version'] = original_version
     self.data['new_version'] = new_version
Ejemplo n.º 6
0
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        # Try to make sure that the suggestion for next version after
        # 1.1.19 is not 1.1.110, but 1.1.20.
        current_split = current.split('.')
        major = '.'.join(current_split[:-1])
        minor = current_split[-1]
        try:
            minor = int(minor) + 1
            suggestion = '.'.join([major, str(minor)])
        except ValueError:
            # Fall back on simply updating the last character when it is
            # an integer.
            try:
                last = int(current[-1]) + 1
                suggestion = current[:-1] + str(last)
            except ValueError:
                logger.warn("Version does not end with a number, so we can't "
                            "calculate a suggestion for a next version.")
                suggestion = None
        print "Current version is %r" % current
        if suggestion:
            suggestion_string = ' [%s]' % suggestion
        else:
            suggestion_string = ''
        q = ("Enter new development version ('.dev0' will be appended)"
             "%s: " % suggestion_string)
        version = utils.get_input(q).strip()
        if not version:
            version = suggestion
        if not version:
            logger.error("No version entered.")
            sys.exit()

        self.data['new_version'] = version
        dev_version = self.data['dev_version_template'] % self.data
        self.data['dev_version'] = dev_version
        logger.info("New version string is %r",
                    dev_version)