lib/python/util/svn.py
author Sylvestre Ledru <sylvestre@debian.org>
Thu, 25 Sep 2014 11:54:38 +0200
changeset 5249 839656c805b05b1ceba6b459f9e83be6a2903994
child 5251 6b0be5cdead36d49dc714782451e1be56adb19b5
permissions -rw-r--r--
[PATCH] Bug 1053814 - Update the product details and mozilla.com from From 3bfeb411a0d5af04ec2eb04cc0cf096528f840c9 Mon Sep 17 00:00:00 2001 stage-tasks.py --- lib/python/release/product_details_update.py | 193 +++++++++++++++++++++++++++ lib/python/util/svn.py | 70 ++++++++++ scripts/release/stage-tasks.py | 31 +++++ 3 files changed, 294 insertions(+) create mode 100644 lib/python/release/product_details_update.py create mode 100644 lib/python/util/svn.py

from util.retry import retry
from util.commands import run_cmd, get_output
import os
import logging
log = logging.getLogger(__name__)


def checkoutSVN(targetSVNDirectory, svnURL):
    """
    Checkout the product details SVN
    """
    if not os.path.isdir(targetSVNDirectory):
        cmd = ["svn", "co", svnURL, targetSVNDirectory]
        run_cmd(cmd)

    # Sanity check
    svnStatus = get_output(["svn", "status", targetSVNDirectory])
    if len(svnStatus) != 0:
        raise Exception("Uncommited changes: " + svnStatus)


def exportJSON(targetSVNDirectory):
    """
    Export the PHP product details to json
    """
    retval = os.getcwd()
    os.chdir(targetSVNDirectory)
    run_cmd(["php", "export_json.php"])
    os.chdir(retval)


def doCommitSVN(commitMSG):
    """
    Actually do the commit (called with retry)
    """
    log.info("svn commit -m " + commitMSG)
    run_cmd(["svn", "commit", "-m", commitMSG])


def getSVNrev(targetSVNDirectory):
    """
    Return the svn revision
    """
    retval = os.getcwd()
    os.chdir(targetSVNDirectory)
    rev = get_output(["svnversion"])
    os.chdir(retval)
    return rev


def commitSVN(targetSVNDirectory, product, version, fakeCommit=False):
    """
    Commit the change in the svn
    """
    retval = os.getcwd()
    os.chdir(targetSVNDirectory)
    try:
        if not os.path.isdir(".svn"):
            raise Exception("Could not find the svn directory")
        commitMSG = "'" + product + " version " + version + "'"
        if not fakeCommit:
            retry(doCommitSVN, args=(commitMSG), attempts=3, sleeptime=0)
    finally:
        os.chdir(retval)


def updateRev(targetSVNDirectory, newRev):
    run_cmd(["svn", "propset", "svn:externals", "'product-details -r" + newRev, "http://svn.mozilla.org/libs/product-details", "tags/stage/includes'"])
    run_cmd(["svn", "propset", "svn:externals", "'product-details -r" + newRev, "http://svn.mozilla.org/libs/product-details", "tags/productions/includes'"])
    run_cmd(["svn", "up"])