Beispiel #1
0
def find_version_number(show_nick=False):
    path = os.path.join(os.path.dirname(__file__), "..")

    # We're using a package
    if path.startswith('/usr'):
        output = subprocess.Popen(["dpkg-query", "-W", "python-launchpad-bugs"], 
                                   stdout=subprocess.PIPE).communicate()[0]
        try:
            return output.split()[1]
        except:
            # not installed as a package
            return "unknown"
    if HAVE_BZR:
        try:
            trace.be_quiet()
            trace.enable_default_logging()
            version = get_version_from_changelog(path)
            if os.path.islink(os.path.dirname(__file__)):
                path = os.path.realpath(os.path.dirname(__file__))
            branch = Branch.open_containing(path)[0]
            bzr_revno = branch.revno()
            if show_nick:
                nick = branch.nick
                return "%sr%s, branch nick: %s" % (version, bzr_revno, nick)
            else:
                return "%sr%s" % (version, bzr_revno)
        except:
            pass
    return "unknown"
Beispiel #2
0
def main(args):
    import optparse
    p = optparse.OptionParser(usage='%prog [options]\n' + __doc__)

    opts, args = p.parse_args(args)

    from bzrlib import ui, trace, repository
    from bzrlib.ui import text
    from bzrlib.repofmt import pack_repo
    ui.ui_factory = text.TextUIFactory()
    trace.enable_default_logging()

    trace.note('processing "."')

    fmt = getattr(pack_repo, 'RepositoryFormatKnitPack6', None)
    if fmt is None:
        trace.note("** Your bzrlib does not have RepositoryFormatPack6 (--1.9)")
        trace.note("   upgrade your bzrlib installation.")
        return

    r = repository.Repository.open('.')
    if isinstance(r._format, (pack_repo.RepositoryFormatKnitPack1, # 0.92
                              pack_repo.RepositoryFormatKnitPack5, # 1.6
                              )):
        fmt = pack_repo.RepositoryFormatKnitPack6
    elif isinstance(r._format, (pack_repo.RepositoryFormatKnitPack4, # rich-root-pack
                                pack_repo.RepositoryFormatKnitPack5RichRoot, # 1.6.1-rich-root
                               )):
        fmt = pack_repo.RepositoryFormatKnitPack6RichRoot
    elif isinstance(r._format, (pack_repo.RepositoryFormatKnitPack6, # 1.9
                                pack_repo.RepositoryFormatKnitPack6RichRoot, # 1.9-rich-root
                               )):
        trace.note("Repository is already upgraded to: %s", r._format)
        return
    else:
        trace.note("** Do not know how to upgrade a repository of format:")
        trace.note("   %s", (r._format,))
        return

    t = r._transport
    t.rename('format', 'format-gi')
    add_revert_step(t.rename, 'format-gi', 'format')
    t.put_bytes('format',
        'Bazaar Repository Upgrade to 1.9 (%s) in progress\n' % (fmt,))
    add_revert_step(t.delete, 'format')
    pb = ui.ui_factory.nested_progress_bar()
    try:
        do_upgrade(r, fmt, pb)
    except:
        do_revert()
        pb.finished()
        raise
    pb.finished()
def main(args):
    parser = optparse.OptionParser("usage: %prog [options] [root [conffile]]")
    parser.add_option(
        '--public-only', action='store_true',
        help='Only fetch/update the public sourcecode branches.')
    parser.add_option(
        '--tip', action='store_true',
        help='Ignore revision constraints for all branches and pull tip')
    parser.add_option(
        '--dry-run', action='store_true',
        help='Do nothing, but report what would have been done.')
    parser.add_option(
        '--quiet', action='store_true',
        help="Don't print informational messages.")
    parser.add_option(
        '--use-http', action='store_true',
        help="Force bzr to use http to get the sourcecode branches "
             "rather than using bzr+ssh.")
    options, args = parser.parse_args(args)
    root = get_launchpad_root()
    if len(args) > 1:
        sourcecode_directory = args[1]
    else:
        sourcecode_directory = os.path.join(root, 'sourcecode')
    if len(args) > 2:
        config_filename = args[2]
    else:
        config_filename = os.path.join(root, 'utilities', 'sourcedeps.conf')
    cache_filename = os.path.join(
        root, 'utilities', 'sourcedeps.cache')
    if len(args) > 3:
        parser.error("Too many arguments.")
    if not options.quiet:
        print 'Sourcecode: %s' % (sourcecode_directory,)
        print 'Config: %s' % (config_filename,)
    enable_default_logging()
    # Tell bzr to use the terminal (if any) to show progress bars
    ui.ui_factory = ui.make_ui_for_terminal(
        sys.stdin, sys.stdout, sys.stderr)
    load_plugins()
    update_sourcecode(
        sourcecode_directory, config_filename, cache_filename,
        options.public_only, options.tip, options.dry_run, options.quiet,
        options.use_http)
    return 0
def main(args):
    parser = optparse.OptionParser("usage: %prog [options] [root [conffile]]")
    parser.add_option('--public-only',
                      action='store_true',
                      help='Only fetch/update the public sourcecode branches.')
    parser.add_option(
        '--tip',
        action='store_true',
        help='Ignore revision constraints for all branches and pull tip')
    parser.add_option('--dry-run',
                      action='store_true',
                      help='Do nothing, but report what would have been done.')
    parser.add_option('--quiet',
                      action='store_true',
                      help="Don't print informational messages.")
    parser.add_option(
        '--use-http',
        action='store_true',
        help="Force bzr to use http to get the sourcecode branches "
        "rather than using bzr+ssh.")
    options, args = parser.parse_args(args)
    root = get_launchpad_root()
    if len(args) > 1:
        sourcecode_directory = args[1]
    else:
        sourcecode_directory = os.path.join(root, 'sourcecode')
    if len(args) > 2:
        config_filename = args[2]
    else:
        config_filename = os.path.join(root, 'utilities', 'sourcedeps.conf')
    cache_filename = os.path.join(root, 'utilities', 'sourcedeps.cache')
    if len(args) > 3:
        parser.error("Too many arguments.")
    if not options.quiet:
        print 'Sourcecode: %s' % (sourcecode_directory, )
        print 'Config: %s' % (config_filename, )
    enable_default_logging()
    # Tell bzr to use the terminal (if any) to show progress bars
    ui.ui_factory = ui.make_ui_for_terminal(sys.stdin, sys.stdout, sys.stderr)
    load_plugins()
    update_sourcecode(sourcecode_directory, config_filename, cache_filename,
                      options.public_only, options.tip, options.dry_run,
                      options.quiet, options.use_http)
    return 0
Beispiel #5
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os
import ConfigParser

from bzrlib import trace
from bzrlib.bzrdir import BzrDir
from bzrlib.branch import Branch
from bzrlib.plugin import load_plugins
from bzrlib.repository import Repository

load_plugins()
trace.enable_default_logging()  # Provide better error handling


class Mr:
    def __init__(self, directory=None, config=None, mr_compat=True):
        self.directory = directory or os.getcwd()
        self.control_dir = os.path.join(self.directory, '.bzr')
        self.config_file = config or os.path.join(self.directory, '.mrconfig')
        self.mr_compat = mr_compat

        if mr_compat:
            if self.__is_repository():
                self.config = self.__read_cfg()
                self.bzr_dir = Repository.open(self.directory)
            else:
                self.config = ConfigParser.RawConfigParser()
Beispiel #6
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os
import ConfigParser

from bzrlib import trace
from bzrlib.bzrdir import BzrDir
from bzrlib.branch import Branch
from bzrlib.plugin import load_plugins
from bzrlib.repository import Repository

load_plugins()
trace.enable_default_logging()  # Provide better error handling


class Mr:
    def __init__(self, directory=None, config=None, mr_compat=True):
        self.directory = directory or os.getcwd()
        self.control_dir = os.path.join(self.directory, '.bzr')
        self.config_file = config or os.path.join(self.directory, '.mrconfig')
        self.mr_compat = mr_compat

        if mr_compat:
            if self.__is_repository():
                self.config = self.__read_cfg()
                self.bzr_dir = Repository.open(self.directory)
            else:
                self.config = ConfigParser.RawConfigParser()
Beispiel #7
0
    commands,
    graph,
    ui,
    trace,
    _known_graph_py,
    _known_graph_pyx,
    )
from bzrlib.ui import text

p = optparse.OptionParser()
p.add_option('--quick', default=False, action='store_true')
p.add_option('--max-combinations', default=500, type=int)
p.add_option('--lsprof', default=None, type=str)
opts, args = p.parse_args(sys.argv[1:])

trace.enable_default_logging()
ui.ui_factory = text.TextUIFactory()

begin = time.clock()
if len(args) >= 1:
    b = branch.Branch.open(args[0])
else:
    b = branch.Branch.open('.')
b.lock_read()
try:
    g = b.repository.get_graph()
    parent_map = dict(p for p in g.iter_ancestry([b.last_revision()])
                         if p[1] is not None)
finally:
    b.unlock()
end = time.clock()
Beispiel #8
0
#! /usr/bin/env python

# Copyright (C) 2005 Canonical Ltd
"""Print to stdout a description of the current directory, 
formatted as a Python data structure.

This can be useful in tests that need to recreate directory
contents."""

import sys
import os

from bzrlib.trace import enable_default_logging
enable_default_logging()
from bzrlib.selftest.treeshape import capture_tree_contents


def main(argv):
    # a lame reimplementation of pformat that splits multi-line
    # strings into concatenated string literals.
    print '['
    for tt in capture_tree_contents('.'):
        assert isinstance(tt, tuple)
        print '    (', repr(tt[0]) + ',',
        if len(tt) == 1:
            print '),'
        else:
            assert len(tt) == 2
            val = tt[1]
            print
            if val == '':
Beispiel #9
0
    else:
        import platform
        if platform.uname()[0] == 'Darwin':
            for x in os.listdir('/Library/Python'):
                path = '/Library/Python/' + x + '/site-packages'
                if os.path.isdir(path + '/bzrlib'):
                    sys.path.insert(0, path)
                    break
    import bzrlib
from bzrlib.errors import DivergedBranches,BzrCommandError
from bzrlib.bzrdir import BzrDir
from bzrlib.trace import be_quiet
from bzrlib.builtins import *
from bzrlib.trace import enable_default_logging, be_quiet
try:
    enable_default_logging()
except:
    pass

bzrlib.initialize()

if os.name == 'nt':
    PRIVATE_VCS_FOLDER = os.path.join(os.getenv("HOMEDRIVE"), os.getenv("HOMEPATH"), 'APPDATA', 'Roaming', 'bazaar', '2.0')
else:
    PRIVATE_VCS_FOLDER = os.path.join(os.path.abspath(os.getenv("HOME")), '.bazaar')
VCS_CONF_FILE = 'ps-vcs-conf.txt'
VCS_CONF_PATH = os.path.join(PRIVATE_VCS_FOLDER, VCS_CONF_FILE)
SETTINGS_SECTION = 'settings'
MASTER_REPO_ROOT_KEY = 'master repo root'
SITE_REPO_ROOT_KEY = 'site repo root'
LOCAL_REPO_ROOT_KEY = 'local repo root'
Beispiel #10
0
    commands,
    graph,
    ui,
    trace,
    _known_graph_py,
    _known_graph_pyx,
)
from bzrlib.ui import text

p = optparse.OptionParser()
p.add_option('--quick', default=False, action='store_true')
p.add_option('--max-combinations', default=500, type=int)
p.add_option('--lsprof', default=None, type=str)
opts, args = p.parse_args(sys.argv[1:])

trace.enable_default_logging()
ui.ui_factory = text.TextUIFactory()

begin = time.clock()
if len(args) >= 1:
    b = branch.Branch.open(args[0])
else:
    b = branch.Branch.open('.')
b.lock_read()
try:
    g = b.repository.get_graph()
    parent_map = dict(p for p in g.iter_ancestry([b.last_revision()])
                      if p[1] is not None)
finally:
    b.unlock()
end = time.clock()
Beispiel #11
0
    def run(self, cmd, to_buffer=True, progress_updates=False):

        if type(cmd) is str:
            argv = shlex.split(cmd)
        else:
            argv = cmd

        if to_buffer:
            output = Output(progress_updates,
                            vim.current.buffer,
                            vim.current.window)
        else:
            output = StringIO()

        olddir = os.getcwd()
        os.chdir(self.root)

        try:
            sys.stdout = output
            sys.stderr = output

            trace.enable_default_logging()
            ui.ui_factory = UI(output)

            # Is this a final release version? If so, we should suppress warnings
            if version_info[3] == 'final':
                from bzrlib import symbol_versioning
                symbol_versioning.suppress_deprecation_warnings(override=False)

            new_argv = []
            try:
                # ensure all arguments are unicode strings
                for arg in argv:
                    if isinstance(arg, unicode):
                        new_argv.append(arg)
                    else:
                        new_argv.append(arg.decode(user_encoding))
            except UnicodeDecodeError:
                raise BzrError("argv should be list of unicode strings.")
            argv = new_argv

            try:
                ret = commands.run_bzr_catch_errors(argv)
            except:
                print >>vim_stderr, StringIO(traceback.format_exc())
                ret = -1

            ui.ui_factory.finish()

            if not to_buffer:
                return output.getvalue()

            output.flush(redraw=False, final=True)

            vim.command("let b:bzrstatus_fileformat = '%s'" %
                        (output.fileformat))

            return ret

        finally:

            for handler in trace._bzr_logger.handlers:
                handler.close()
            if trace._trace_file is not None:
                trace._trace_file.close()
                trace._trace_file = None

            os.chdir(olddir)

            sys.stdout = vim_stdout
            sys.stderr = vim_stderr