@task
def code_activate(requirements_revision=None):
  """Make the code at revision active (latest if None)."""
  assert not is_old_code(), 'Active code is old-style (directory, not symlink). Manual intervention required!'
  req_rev = requirements_revision or hg_revision()
  assert code_verify(req_rev), 'Desired code revision %s invalid, cannot be made active' % req_rev
  # Note: -T forces the target to be treated as a normal file. Without it, the link will be:
  # ~/viewfinder/viewfinder.<rev> -> ~/viewfinder.<rev> instead of being in the home directory.
  run('ln -T -s -f ~/viewfinder.%s ~/viewfinder' % req_rev)
  fprint('Code at revision %s marked active.' % req_rev)
dataset/ETHPy150Open viewfinderco/viewfinder/fabfile.py/code_activate/original