예제 #1
0
def RevertStableEBuild(dirname, rev):
    """Revert the stable ebuilds for a package back to a particular revision.

  Also add/remove the files in git.

  Args:
    dirname: Path to the ebuild directory.
    rev: Revision to revert back to.

  Returns:
    The name of the ebuild reverted to.
  """
    package = os.path.basename(dirname.rstrip(os.sep))
    pattern = '%s-*.ebuild' % package

    # Get rid of existing stable ebuilds.
    ebuilds = glob.glob(os.path.join(dirname, pattern))
    for ebuild in ebuilds:
        parts = SplitPVPath(ebuild)
        if parts.version != '9999':
            git.RmPath(ebuild)

    # Bring back the old stable ebuild.
    names = git.GetObjectAtRev(dirname, './', rev).split()
    names = fnmatch.filter(names, pattern)
    names = [
        name for name in names
        if SplitPVPath(os.path.join(dirname, name)).version != '9999'
    ]
    if not names:
        return None
    assert len(names) == 1
    name = names[0]
    git.RevertPath(dirname, name, rev)

    # Update the manifest.
    UpdateManifest(os.path.join(dirname, name))
    manifest_path = os.path.join(dirname, 'Manifest')
    if os.path.exists(manifest_path):
        git.AddPath(manifest_path)
    return os.path.join(dirname, name)
 def testGetObjectAtRev(self):
     git.GetObjectAtRev(self.fake_git_dir, '.', '1234')
     self.assertCommandContains(['show'])