code: def save_version_and_update_files(cfg, version_file, version_to_save):
      
      with vcs.VCS(cfg.vcs_engine) as vcs_handler:
          if cfg.commit:
              vcs_handler.raise_if_cant_commit()
  
          version_file.write(version_to_save)
  
          quant = update_project_files(cfg, version_to_save)
  
          if cfg.commit:
              files = {str(file.file) for file in cfg.files}
              files.add(str(cfg.version_file))
              vcs_handler.add_to_stage(files)
              vcs_handler.create_commit(cfg.vcs_commit_message % {'version': version_to_save})
  
      return quant
docs: Save version to version_file and commit changes if required
  
      :param cfg:
      :param version_file:
      :param version_to_save:
      :return: