/usr/lib/python2.7/dist-packages/paver/bzr.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 | """Convenience functions for working with bzr.
This module does not include any tasks, only functions."""
import sys
if sys.version_info[0] == 3:
raise ImportError("Bazaar-NG is not available for Python 3")
from paver.options import Bunch
from bzrlib.builtins import cmd_branch, cmd_checkout, cmd_update, cmd_pull, cmd_version_info
from StringIO import StringIO
__all__ = ["checkout", "update", "branch", "pull", "info"]
def do_bzr_cmd(cmd_class, output=True, **kwarg):
if output:
import bzrlib.ui
from bzrlib.ui.text import TextUIFactory
bzrlib.ui.ui_factory = TextUIFactory()
cmd = cmd_class()
if output:
cmd._setup_outf()
else:
cmd.outf = StringIO()
cmd.run(**kwarg)
return cmd.outf
def checkout(url, dest, revision=None):
"""Checkout from the URL to the destination."""
do_bzr_cmd(cmd_checkout, branch_location=url, to_location=dest, revision=revision)
def update(path='.'):
"""Update the given path."""
do_bzr_cmd(cmd_update, dir=path)
def branch(url, dest, revision=None):
"""Branch from the given URL to the destination."""
do_bzr_cmd(cmd_branch, from_location=url, to_location=dest, revision=revision)
def pull(url, revision=None):
"""Pull from the given URL at the optional revision."""
do_bzr_cmd(cmd_pull, location=url, revision=revision)
def info(location=None):
"""Retrieve the info at location."""
data = Bunch()
sio = do_bzr_cmd(cmd_version_info, False, location=location)
sio.seek(0)
for line in sio.readlines():
if not ":" in line:
continue
key, value = line.split(":", 1)
key = key.lower().replace(" ", "_").replace("-", "_")
data[key] = value.strip()
return data
|