<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def autoinc(self):
 """ Conditionally updates the stack version in the file associated with this config. This handles both official releases (i.e. QA configs), and release candidates. Assumptions about version: - Official release versions are MAJOR.minor, where MAJOR and minor are both non-negative integers. E.g. 2.9 2.10 2.11 3.0 3.1 3.2 - Release candidate versions are MAJOR.minor-rc.N, where MAJOR, minor, and N are all non-negative integers. 3.5-rc.1 3.5-rc.2 """

        if not self.get('autoinc_version'):
            return

        oldver = self['version']
        newver = bump_version_tail(oldver)

        config_path = self.filepath
        temp_fd, temp_name = tempfile.mkstemp(
                dir=os.path.dirname(config_path),
                )
        with open(config_path) as old:
            with os.fdopen(temp_fd, 'w') as new:
                for oldline in old:
                    if oldline.startswith('version:'):
                        new.write("version: '%s'\n" % newver)
                        continue
                    new.write(oldline)

        # no need to backup the old file, it's under version control anyway -
        # right???
        log.info('Incrementing stack version %s -> %s' % (oldver, newver))
        os.rename(temp_name, config_path)