def checkout(self, url, version='', verbose=False,
                 shallow=False, timeout=None):
        if url is None or url.strip() == '':
            raise ValueError('Invalid empty url : "%s"' % url)
        # make sure that the parent directory exists for #3497
        base_path = os.path.split(self.get_path())[0]
        try:
            os.makedirs(base_path)
        except __HOLE__:
            # OSError thrown if directory already exists this is ok
            pass
        cmd = "hg clone %s %s" % (sanitized(url), self._path)
        value, _, msg = run_shell_command(cmd,
                                          shell=True,
                                          no_filter=True)
        if value != 0:
            if msg:
                sys.logger.error('%s' % msg)
            return False
        if version is not None and version.strip() != '':
            cmd = "hg checkout %s" % sanitized(version)
            value, _, msg = run_shell_command(cmd,
                                              cwd=self._path,
                                              shell=True,
                                              no_filter=True)
            if value != 0:
                if msg:
                    sys.stderr.write('%s\n' % msg)
                return False
        return True
dataset/ETHPy150Open vcstools/vcstools/src/vcstools/hg.py/HgClient.checkout