def migrate(opts):
try:<EOL><INDENT>version = int(opts['<STR_LIT>'])<EOL><DEDENT>except:<EOL><INDENT>raise DatacatsError('<STR_LIT>')<EOL><DEDENT>always_yes = opts['<STR_LIT>']<EOL>if '<STR_LIT>' not in opts or not opts['<STR_LIT>']:<EOL><INDENT>cwd = getcwd()<EOL>opts['<STR_LIT>'] = split(cwd if cwd[-<NUM_LIT:1>] != '<STR_LIT:/>' else cwd[:-<NUM_LIT:1>])[<NUM_LIT:1>]<EOL><DEDENT>datadir = expanduser('<STR_LIT>' + opts['<STR_LIT>'])<EOL>if needs_format_conversion(datadir, version):<EOL><INDENT>convert_environment(datadir, version, always_yes)<EOL>print('<STR_LIT>'.format(datadir, version))<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>'.format(datadir, version))<EOL><DEDENT>
Migrate an environment to a given revision of the datadir format.

Usage:
  datacats migrate [-y] [-r VERSION] [ENVIRONMENT_DIR]

Options:
  -r --revision=VERSION  The version of the datadir format you want
                         to convert to [default: 2]
  -y --yes               Answer yes to all questions.

Defaults to '.' if ENVIRONMENT_DIR isn't specified.