view treepkg/subversion.py @ 93:73c67372c7f7

Make the prefix used in the debian revision number configurable. This involves a new config file setting documented in demo.cfg, the necessary changes to the packagers and updated and new test cases
author Bernhard Herzog <bh@intevation.de>
date Wed, 07 Nov 2007 10:13:24 +0000
parents 570ac81865be
children 1527c37bd7aa
line wrap: on
line source
# Copyright (C) 2007 by Intevation GmbH
# Authors:
# Bernhard Herzog <bh@intevation.de>
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with the software for details.

"""Collection of subversion utility functions"""

import os

import run
from cmdexpand import cmdexpand
from util import extract_value_for_key


def checkout(url, localdir):
    """Runs svn to checkout the repository at url into the localdir"""
    run.call(cmdexpand("svn checkout -q $url $localdir", **locals()))

def update(localdir, revision=None):
    """Runs svn update on the localdir.
    The parameter revision, if given, is passed to svn as the value of
    the --revision option.
    """
    if revision:
        revision = ["--revision", revision]
    else:
        revision = []
    run.call(cmdexpand("svn update -q @revision $localdir", **locals()))

def export(src, dest):
    """Runs svn export src dest"""
    run.call(cmdexpand("svn export -q $src $dest", **locals()))

def last_changed_revision(svn_working_copy):
    """return the last changed revision of an SVN working copy as an int"""
    # Make sure we run svn under the C locale to avoid localized
    # messages
    env = os.environ.copy()
    env["LANG"] = "C"

    output = run.capture_output(cmdexpand("svn info $svn_working_copy",
                                          **locals()),
                                env=env)
    return int(extract_value_for_key(output.splitlines(),
                                     "Last Changed Rev:"))
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)