view treepkg/subversion.py @ 79:570ac81865be

Add revision parameter to update so that a checkout can be updated to a specific revision
author Bernhard Herzog <bh@intevation.de>
date Fri, 11 May 2007 12:58:28 +0000
parents 3e610233ccfe
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)