copyCapsule :: String -- ^ Old name
              -> String -- ^ New name
              -> FilePath -- ^ Repository location
              -> IO FilePath
  copyCapsule oldname newname repobase =
    debugM "hgc" ("Copying " ++ oldname ++ " to " ++ newname ++ " in repository " ++ repobase) >>
    cp oldloc newloc >>= \cpStatus ->
    case cpStatus of
      ExitSuccess -> return newloc
      ExitFailure r -> ioError . userError $ "Failed to copy capsule (exit code " ++ show r ++ ")."
    where
      oldloc = repobase </> oldname
      newloc = repobase </> newname
  
  -- Update the config to a temporary location.
copyCapsule :: String -- ^ Old name
              -> String -- ^ New name
              -> FilePath -- ^ Repository location
              -> IO FilePath
copyCapsule oldname newname repobase =
    debugM "hgc" ("Copying " ++ oldname ++ " to " ++ newname ++ " in repository " ++ repobase) >>
    cp oldloc newloc >>= \cpStatus ->
    case cpStatus of
      ExitSuccess -> return newloc
      ExitFailure r -> ioError . userError $ "Failed to copy capsule (exit code " ++ show r ++ ")."
    where
      oldloc = repobase </> oldname
      newloc = repobase </> newname
  
  -- Update the config to a temporary location.
copyCapsule oldname newname repobase =
    debugM "hgc" ("Copying " ++ oldname ++ " to " ++ newname ++ " in repository " ++ repobase) >>
    cp oldloc newloc >>= \cpStatus ->
    case cpStatus of
      ExitSuccess -> return newloc
      ExitFailure r -> ioError . userError $ "Failed to copy capsule (exit code " ++ show r ++ ")."
    where
      oldloc = repobase </> oldname
      newloc = repobase </> newname
  
  -- Update the config to a temporary location.