Ejemplo n.º 1
0
    def checkout(self, commit_id):
        """Check out the given commit.

        Args:
            commit_id (unicode):
                The ID of the commit to check out.

        Returns:
            unicode:
            The name of a directory with the given checkout.
        """
        workdir = make_tempdir()
        branchname = 'br-%s' % commit_id

        logging.info('Creating temporary branch for clone in repo %s',
                     self.repo_path)
        execute(['git', '--git-dir=%s' % self.repo_path, 'branch', branchname,
                 commit_id])

        logging.info('Creating working tree for commit ID %s in %s', commit_id,
                     workdir)
        execute(['git', 'clone', '--local', '--no-hardlinks', '--depth', '1',
                 '--branch', branchname, self.repo_path, workdir])

        logging.info('Removing temporary branch for clone in repo %s',
                     self.repo_path)
        execute(['git', '--git-dir=%s' % self.repo_path, 'branch', '-d',
                 branchname])

        return workdir
Ejemplo n.º 2
0
    def checkout(self, commit_id):
        """Check out the given commit.

        Args:
            commit_id (unicode):
                The ID of the commit to check out.

        Returns:
            unicode:
            The name of a directory with the given checkout.
        """
        workdir = make_tempdir()

        logging.info('Creating working tree for commit ID %s in %s', commit_id,
                     workdir)
        execute(['hg', '-R', self.repo_path, 'archive', '-r', commit_id,
                 '-t', 'files', workdir])

        return workdir