<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def version_control():
 """Return an object that provides the version control interface based on the detected version control system."""

    curdir_contents = os.listdir('.')
    if '.hg' in curdir_contents:
        return hg.Hg()
    elif '.git' in curdir_contents:
        return git.Git()
    else:
        logger.critical('No version control system detected.')
        sys.exit(1)