view treepkg/subversion.py @ 45:3e610233ccfe

use cmdexpand when calling subprocesses
author Bernhard Herzog <bh@intevation.de>
date Tue, 20 Mar 2007 17:27:46 +0100
parents f78a02e79c84
children 570ac81865be
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):
    """Runs svn update on the localdir"""
    run.call(cmdexpand("svn update -q $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)