/usr/lib/python2.7/dist-packages/paver/svn.py is in python-paver 1.2.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | """Convenience functions for working with svn.
This module does not include any tasks, only functions.
At this point, these functions do not use any kind of library. They require
the svn binary on the path."""
from paver.easy import sh, Bunch, path
def _format_revision(revision):
if revision:
revision = "-r %s " % (revision)
return revision
def checkout(url, dest, revision=""):
"""Checks out the specified URL to the given destination."""
revision = _format_revision(revision)
sh("svn co %s%s %s" % (revision, url, dest))
def update(path="", revision=""):
"""Run an svn update on the given path."""
revision = _format_revision(revision)
command = "svn up %s" % revision
if path:
command += path
sh(command)
def checkup(url, dest, revision=""):
"""Does a checkout or update, depending on whether the destination
exists and is up to date (if a revision is passed in). Returns
true if a checkout or update was performed. False otherwise."""
dest = path(dest)
if not dest.exists():
checkout(url, dest, revision)
return True
else:
vinfo = info(dest)
if not vinfo or vinfo.revision != revision:
update(dest, revision)
return True
return False
def export(url, dest, revision=""):
"""Exports the specified URL to the given destination."""
revision = _format_revision(revision)
cmd = 'svn export %s%s %s' % (revision, url, dest)
sh(cmd)
def info(path=""):
"""Retrieves the svn info for the path and returns a dictionary of
the values. Names are normalized to lower case with spaces converted
to underscores."""
output = sh("svn info %s" % path, capture=True)
if not output:
return Bunch()
lines = output.splitlines()
data = Bunch()
for line in lines:
colon = line.find(":")
if colon == -1:
continue
key = line[:colon].lower().replace(" ", "_")
value = line[colon+2:]
data[key] = value
return data
|