def __init__(self, repository): from os.path import split from bzrlib import version_info, IGNORE_FILENAME if version_info > (0,9): from bzrlib.ignores import add_runtime_ignores, parse_ignore_file else: from bzrlib import DEFAULT_IGNORE WorkingDir.__init__(self, repository) # TODO: check if there is a "repository" in the configuration, # and use it as a bzr repository self.ignored = [] self._working_tree = None # The bzr repository may have some plugins that needs to be activated load_plugins() try: bzrdir = BzrDir.open(self.repository.basedir) wt = self._working_tree = bzrdir.open_workingtree() # read .bzrignore for _addSubtree() if wt.has_filename(IGNORE_FILENAME): f = wt.get_file_byname(IGNORE_FILENAME) if version_info > (0,9): self.ignored.extend(parse_ignore_file(f)) else: self.ignored.extend([ line.rstrip("\n\r") for line in f.readlines() ]) f.close() except errors.NotBranchError, errors.NoWorkingTree: pass
def __init__(self, local_path, remote_url, branch=None, shallow=False): self = RepositoryBase.__init__(self, local_path, remote_url, branch=branch, shallow=shallow) load_plugins()
def _load_bzr_plugins(self): from bzrlib.plugin import load_plugins load_plugins() import bzrlib.plugins if getattr(bzrlib.plugins, "loom", None) is None: log.error("Loom plugin loading failed.")
def test_loading_from___init__only(self): # We rename the existing __init__.py file to ensure that we don't load # a random file init = 'non-standard-dir/__init__.py' random = 'non-standard-dir/setup.py' os.rename(init, random) self.addCleanup(os.rename, random, init) self.overrideEnv('BZR_PLUGINS_AT', 'test_foo@non-standard-dir') plugin.load_plugins(['standard']) self.assertPluginUnknown('test_foo')
def __init__(self, local_path, remote_url, branch=None, shallow=False): if without_svn: raise RuntimeError( "You need install PySVN to use SVN capabilities.") self = RepositoryBase.__init__(self, local_path, remote_url, branch=branch, shallow=shallow) load_plugins()
def bzr_version_summary(path): try: import bzrlib except ImportError: return ("BZR-UNKNOWN", {}) import bzrlib.ui bzrlib.ui.ui_factory = bzrlib.ui.make_ui_for_terminal( sys.stdin, sys.stdout, sys.stderr) from bzrlib import branch, osutils, workingtree from bzrlib.plugin import load_plugins load_plugins() b = branch.Branch.open(path) (revno, revid) = b.last_revision_info() rev = b.repository.get_revision(revid) fields = { "BZR_REVISION_ID": revid, "BZR_REVNO": revno, "COMMIT_DATE": osutils.format_date_with_offset_in_original_timezone( rev.timestamp, rev.timezone or 0), "COMMIT_TIME": int(rev.timestamp), "BZR_BRANCH": rev.properties.get("branch-nick", ""), } # If possible, retrieve the git sha try: from bzrlib.plugins.git.object_store import get_object_store except ImportError: # No git plugin ret = "BZR-%d" % revno else: store = get_object_store(b.repository) store.lock_read() try: full_rev = store._lookup_revision_sha1(revid) finally: store.unlock() fields["GIT_COMMIT_ABBREV"] = full_rev[:7] fields["GIT_COMMIT_FULLREV"] = full_rev ret = "GIT-" + fields["GIT_COMMIT_ABBREV"] if workingtree.WorkingTree.open(path).has_changes(): fields["COMMIT_IS_CLEAN"] = 0 ret += "+" else: fields["COMMIT_IS_CLEAN"] = 1 return (ret, fields)
def run(self): from bzrlib.plugin import load_plugins; load_plugins() from bzrlib.branch import Branch from bzrlib.plugins.stats.cmds import find_credits import pickle branch = Branch.open(self.url) credits = find_credits(branch.repository, branch.last_revision()) pickle.dump(credits, file("credits.pickle", 'w')) return True
def branch(self, source, dest): url_parts = self.parse_url(source) # If we use lp:branchname scheme we need to load plugins if not self.can_handle(source): raise UnhandledSource("Cannot handle {}".format(source)) if url_parts.scheme == "lp": from bzrlib.plugin import load_plugins load_plugins() try: remote_branch = Branch.open(source) remote_branch.bzrdir.sprout(dest).open_branch() except Exception as e: raise e
def test_not_loaded(self): self.warnings = [] def captured_warning(*args, **kwargs): self.warnings.append((args, kwargs)) self.overrideAttr(trace, 'warning', captured_warning) # Reset the flag that protect against double loading self.overrideAttr(plugin, '_loaded', False) self.overrideEnv('BZR_DISABLE_PLUGINS', 'test_foo') plugin.load_plugins(['.']) self.assertPluginUnknown('test_foo') # Make sure we don't warn about the plugin ImportError since this has # been *requested* by the user. self.assertLength(0, self.warnings)
def test_loading_from_specific_file(self): plugin_dir = 'non-standard-dir' plugin_file_name = 'iamtestfoo.py' plugin_path = osutils.pathjoin(plugin_dir, plugin_file_name) source = '''\ """This is the doc for %s""" dir_source = '%s' ''' % ('test_foo', plugin_path) self.create_plugin('test_foo', source=source, dir=plugin_dir, file_name=plugin_file_name) self.overrideEnv('BZR_PLUGINS_AT', 'test_foo@%s' % plugin_path) plugin.load_plugins(['standard']) self.assertTestFooLoadedFrom(plugin_path)
def bzr_initialize(): _logger.debug('Importing and initializing bzrlib') from bzrlib.branch import Branch from bzrlib.trace import set_verbosity_level from bzrlib.plugin import load_plugins from bzrlib import initialize library_state = initialize() library_state.__enter__() set_verbosity_level(1000) import odootools.lib.logger odootools.lib.logger.set_levels() load_plugins()
def bzr_version_summary(path): try: import bzrlib except ImportError: return ("BZR-UNKNOWN", {}) import bzrlib.ui bzrlib.ui.ui_factory = bzrlib.ui.make_ui_for_terminal( sys.stdin, sys.stdout, sys.stderr) from bzrlib import branch, osutils, workingtree from bzrlib.plugin import load_plugins load_plugins() b = branch.Branch.open(path) (revno, revid) = b.last_revision_info() rev = b.repository.get_revision(revid) fields = { "BZR_REVISION_ID": revid, "BZR_REVNO": revno, "COMMIT_DATE": osutils.format_date_with_offset_in_original_timezone(rev.timestamp, rev.timezone or 0), "COMMIT_TIME": int(rev.timestamp), "BZR_BRANCH": rev.properties.get("branch-nick", ""), } # If possible, retrieve the git sha try: from bzrlib.plugins.git.object_store import get_object_store except ImportError: # No git plugin ret = "BZR-%d" % revno else: store = get_object_store(b.repository) store.lock_read() try: full_rev = store._lookup_revision_sha1(revid) finally: store.unlock() fields["GIT_COMMIT_ABBREV"] = full_rev[:7] fields["GIT_COMMIT_FULLREV"] = full_rev ret = "GIT-" + fields["GIT_COMMIT_ABBREV"] if workingtree.WorkingTree.open(path).has_changes(): fields["COMMIT_IS_CLEAN"] = 0 ret += "+" else: fields["COMMIT_IS_CLEAN"] = 1 return (ret, fields)
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 test_compiled_loaded(self): self.overrideEnv('BZR_PLUGINS_AT', 'test_foo@non-standard-dir') plugin.load_plugins(['standard']) self.assertTestFooLoadedFrom('non-standard-dir') self.assertIsSameRealPath('non-standard-dir/__init__.py', bzrlib.plugins.test_foo.__file__) # Try importing again now that the source has been compiled self._unregister_plugin('test_foo') plugin._loaded = False plugin.load_plugins(['standard']) self.assertTestFooLoadedFrom('non-standard-dir') if __debug__: suffix = 'pyc' else: suffix = 'pyo' self.assertIsSameRealPath('non-standard-dir/__init__.%s' % suffix, bzrlib.plugins.test_foo.__file__)
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 branch(self, source, dest): url_parts = self.parse_url(source) # If we use lp:branchname scheme we need to load plugins if not self.can_handle(source): raise UnhandledSource("Cannot handle {}".format(source)) if url_parts.scheme == "lp": from bzrlib.plugin import load_plugins load_plugins() try: local_branch = bzrdir.BzrDir.create_branch_convenience(dest) except errors.AlreadyControlDirError: local_branch = Branch.open(dest) try: remote_branch = Branch.open(source) remote_branch.push(local_branch) tree = workingtree.WorkingTree.open(dest) tree.update() except Exception as e: raise e
def make_app(root, prefix, path_var='REQUEST_URI', readonly=True, load_plugins=True, enable_logging=True): """Convenience function to construct a WSGI bzr smart server. :param root: a local path that requests will be relative to. :param prefix: See RelpathSetter. :param path_var: See RelpathSetter. """ local_url = local_path_to_url(root) if readonly: base_transport = get_transport('readonly+' + local_url) else: base_transport = get_transport(local_url) if load_plugins: from bzrlib.plugin import load_plugins load_plugins() if enable_logging: import bzrlib.trace bzrlib.trace.enable_default_logging() app = SmartWSGIApp(base_transport, prefix) app = RelpathSetter(app, '', path_var) return app
def test_load_plugins(self): plugin.load_plugins(['.']) self.assertEqual(bzrlib.plugins.__path__, ['.']) # subsequent loads are no-ops plugin.load_plugins(['foo']) self.assertEqual(bzrlib.plugins.__path__, ['.'])
else: values.append(value) parser = optparse.OptionParser(usage="%prog [-f NAME] [-o]") parser.add_option("--function-name", "-f", metavar="NAME", help="Name of the generated function (default: _bzr)") parser.add_option("--function-only", "-o", action="store_true", help="Generate only the shell function, don't enable it") parser.add_option("--debug", action="store_true", help=optparse.SUPPRESS_HELP) parser.add_option("--no-plugins", action="store_true", help="Don't load any bzr plugins") parser.add_option("--plugin", metavar="NAME", type="string", dest="selected_plugins", default=[], action="callback", callback=plugin_callback, help="Enable completions for the selected plugin" + " (default: all plugins)") (opts, args) = parser.parse_args() if args: parser.error("script does not take positional arguments") kwargs = dict() for name, value in opts.__dict__.iteritems(): if value is not None: kwargs[name] = value locale.setlocale(locale.LC_ALL, '') if not kwargs.get('no_plugins', False): plugin.load_plugins() commands.install_bzr_command_hooks() bash_completion_function(sys.stdout, **kwargs)
def test_load_plugins_default(self): plugin.load_plugins() path = plugin.get_standard_plugins_path() self.assertEqual(path, bzrlib.plugins.__path__)
def __init__(self, local_path, remote_url, branch=None): self = RepositoryBase.__init__(self, local_path, remote_url, branch=branch) load_plugins()
def test_regular_load(self): self.overrideAttr(plugin, '_loaded', False) plugin.load_plugins(['.']) self.assertPluginKnown('test_foo') self.assertDocstring("This is the doc for test_foo", bzrlib.plugins.test_foo)
def run_bzr(argv, load_plugins=load_plugins, disable_plugins=disable_plugins): """Execute a command. :param argv: The command-line arguments, without the program name from argv[0] These should already be decoded. All library/test code calling run_bzr should be passing valid strings (don't need decoding). :param load_plugins: What function to call when triggering plugin loading. This function should take no arguments and cause all plugins to be loaded. :param disable_plugins: What function to call when disabling plugin loading. This function should take no arguments and cause all plugin loading to be prohibited (so that code paths in your application that know about some plugins possibly being present will fail to import those plugins even if they are installed.) :return: Returns a command exit code or raises an exception. Special master options: these must come before the command because they control how the command is interpreted. --no-plugins Do not load plugin modules at all --no-aliases Do not allow aliases --builtin Only use builtin commands. (Plugins are still allowed to change other behaviour.) --profile Run under the Python hotshot profiler. --lsprof Run under the Python lsprof profiler. --coverage Generate line coverage report in the specified directory. --concurrency Specify the number of processes that can be run concurrently (selftest). """ trace.mutter("bazaar version: " + bzrlib.__version__) argv = _specified_or_unicode_argv(argv) trace.mutter("bzr arguments: %r", argv) opt_lsprof = opt_profile = opt_no_plugins = opt_builtin = \ opt_no_l10n = opt_no_aliases = False opt_lsprof_file = opt_coverage_dir = None # --no-plugins is handled specially at a very early stage. We need # to load plugins before doing other command parsing so that they # can override commands, but this needs to happen first. argv_copy = [] i = 0 override_config = [] while i < len(argv): a = argv[i] if a == '--profile': opt_profile = True elif a == '--lsprof': opt_lsprof = True elif a == '--lsprof-file': opt_lsprof = True opt_lsprof_file = argv[i + 1] i += 1 elif a == '--no-plugins': opt_no_plugins = True elif a == '--no-aliases': opt_no_aliases = True elif a == '--no-l10n': opt_no_l10n = True elif a == '--builtin': opt_builtin = True elif a == '--concurrency': os.environ['BZR_CONCURRENCY'] = argv[i + 1] i += 1 elif a == '--coverage': opt_coverage_dir = argv[i + 1] i += 1 elif a == '--profile-imports': pass # already handled in startup script Bug #588277 elif a.startswith('-D'): debug.debug_flags.add(a[2:]) elif a.startswith('-O'): override_config.append(a[2:]) else: argv_copy.append(a) i += 1 if bzrlib.global_state is None: # FIXME: Workaround for users that imported bzrlib but didn't call # bzrlib.initialize -- vila 2012-01-19 cmdline_overrides = config.CommandLineStore() else: cmdline_overrides = bzrlib.global_state.cmdline_overrides cmdline_overrides._from_cmdline(override_config) debug.set_debug_flags_from_config() if not opt_no_plugins: load_plugins() else: disable_plugins() argv = argv_copy if (not argv): get_cmd_object('help').run_argv_aliases([]) return 0 if argv[0] == '--version': get_cmd_object('version').run_argv_aliases([]) return 0 alias_argv = None if not opt_no_aliases: alias_argv = get_alias(argv[0]) if alias_argv: argv[0] = alias_argv.pop(0) cmd = argv.pop(0) cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin) if opt_no_l10n: cmd.l10n = False run = cmd_obj.run_argv_aliases run_argv = [argv, alias_argv] try: # We can be called recursively (tests for example), but we don't want # the verbosity level to propagate. saved_verbosity_level = option._verbosity_level option._verbosity_level = 0 if opt_lsprof: if opt_coverage_dir: trace.warning( '--coverage ignored, because --lsprof is in use.') ret = apply_lsprofiled(opt_lsprof_file, run, *run_argv) elif opt_profile: if opt_coverage_dir: trace.warning( '--coverage ignored, because --profile is in use.') ret = apply_profiled(run, *run_argv) elif opt_coverage_dir: ret = apply_coveraged(opt_coverage_dir, run, *run_argv) else: ret = run(*run_argv) return ret or 0 finally: # reset, in case we may do other commands later within the same # process. Commands that want to execute sub-commands must propagate # --verbose in their own way. if 'memory' in debug.debug_flags: trace.debug_memory('Process status after command:', short=False) option._verbosity_level = saved_verbosity_level # Reset the overrides cmdline_overrides._reset()
def test_regular_load(self): plugin.load_plugins(['standard']) self.assertTestFooLoadedFrom('standard/test_foo')
def test_loading(self): self.overrideEnv('BZR_PLUGINS_AT', 'test_foo@non-standard-dir') plugin.load_plugins(['standard']) self.assertTestFooLoadedFrom('non-standard-dir')
def run_bzr(argv): """Execute a command. This is similar to main(), but without all the trappings for logging and error handling. argv The command-line arguments, without the program name from argv[0] These should already be decoded. All library/test code calling run_bzr should be passing valid strings (don't need decoding). Returns a command status or raises an exception. Special master options: these must come before the command because they control how the command is interpreted. --no-plugins Do not load plugin modules at all --no-aliases Do not allow aliases --builtin Only use builtin commands. (Plugins are still allowed to change other behaviour.) --profile Run under the Python hotshot profiler. --lsprof Run under the Python lsprof profiler. --coverage Generate line coverage report in the specified directory. """ argv = list(argv) trace.mutter("bzr arguments: %r", argv) opt_lsprof = opt_profile = opt_no_plugins = opt_builtin = \ opt_no_aliases = False opt_lsprof_file = opt_coverage_dir = None # --no-plugins is handled specially at a very early stage. We need # to load plugins before doing other command parsing so that they # can override commands, but this needs to happen first. argv_copy = [] i = 0 while i < len(argv): a = argv[i] if a == '--profile': opt_profile = True elif a == '--lsprof': opt_lsprof = True elif a == '--lsprof-file': opt_lsprof = True opt_lsprof_file = argv[i + 1] i += 1 elif a == '--no-plugins': opt_no_plugins = True elif a == '--no-aliases': opt_no_aliases = True elif a == '--builtin': opt_builtin = True elif a == '--coverage': opt_coverage_dir = argv[i + 1] i += 1 elif a.startswith('-D'): debug.debug_flags.add(a[2:]) else: argv_copy.append(a) i += 1 argv = argv_copy if (not argv): from bzrlib.builtins import cmd_help cmd_help().run_argv_aliases([]) return 0 if argv[0] == '--version': from bzrlib.builtins import cmd_version cmd_version().run_argv_aliases([]) return 0 if not opt_no_plugins: from bzrlib.plugin import load_plugins load_plugins() else: from bzrlib.plugin import disable_plugins disable_plugins() alias_argv = None if not opt_no_aliases: alias_argv = get_alias(argv[0]) if alias_argv: alias_argv = [a.decode(bzrlib.user_encoding) for a in alias_argv] argv[0] = alias_argv.pop(0) cmd = argv.pop(0) # We want only 'ascii' command names, but the user may have typed # in a Unicode name. In that case, they should just get a # 'command not found' error later. cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin) run = cmd_obj.run_argv_aliases run_argv = [argv, alias_argv] try: if opt_lsprof: if opt_coverage_dir: trace.warning( '--coverage ignored, because --lsprof is in use.') ret = apply_lsprofiled(opt_lsprof_file, run, *run_argv) elif opt_profile: if opt_coverage_dir: trace.warning( '--coverage ignored, because --profile is in use.') ret = apply_profiled(run, *run_argv) elif opt_coverage_dir: ret = apply_coveraged(opt_coverage_dir, run, *run_argv) else: ret = run(*run_argv) if 'memory' in debug.debug_flags: try: status_file = file('/proc/%s/status' % os.getpid(), 'rb') except IOError: pass else: status = status_file.read() status_file.close() trace.note("Process status after command:") for line in status.splitlines(): trace.note(line) return ret or 0 finally: # reset, in case we may do other commands later within the same process option._verbosity_level = 0
def enable_branch_deployment(buildout): load_plugins() branch_cache_dir = buildout._buildout_path('branch-cache') if not os.path.exists(branch_cache_dir): buildout._logger.info("Creating branch cache directory") os.mkdir(branch_cache_dir) # Do a couple of quick checks. allow_picked_versions = buildout['buildout'].get_bool( 'allow-picked-versions') versions = buildout['buildout'].get('versions') if versions: versions = buildout[versions] else: versions = {} for egg_name, branch_loc in buildout['branches'].items(): rev = buildout.get('revisions', {}).get(egg_name) if rev is None and not allow_picked_versions: raise zc.buildout.UserError('No revision specified for %s' % (egg_name, )) if egg_name in versions: raise zc.buildout.UserError( '%s is sourced from a branch and cannot also have a required ' 'version' % (egg_name, )) # XXX There are some potential races if more than one instance is running # at once. for egg_name, branch_loc in buildout['branches'].items(): rev = buildout.get('revisions', {}).get(egg_name) if rev is not None: buildout._logger.info('using %s at revision %s of %s', egg_name, rev, branch_loc) else: buildout._logger.info('using %s at tip of %s', egg_name, branch_loc) repo = os.path.join(branch_cache_dir, egg_name) if not os.path.exists(repo): branch_bzrdir = BzrDir.create(repo) branch_bzrdir.create_repository(shared=True) os.mkdir(os.path.join(repo, 'source-branches')) os.mkdir(os.path.join(repo, 'checkouts')) source_branch_dir = os.path.join(repo, 'source-branches', urllib.quote(branch_loc, '')) remote_branch = None if not os.path.exists(source_branch_dir): remote_branch = BzrBranch.open(branch_loc) bzr_branch = remote_branch.create_clone_on_transport( get_transport(source_branch_dir), no_tree=True) created = True else: created = False bzr_branch = BzrBranch.open(source_branch_dir) if rev is not None: try: revno, revid = revision_info(bzr_branch, rev) except BzrError: # If the specified revision was not in the branch, try pulling # again. if remote_branch is None: remote_branch = BzrBranch.open(branch_loc) bzr_branch.pull(remote_branch, overwrite=True) try: revno, revid = revision_info(bzr_branch, rev) except BzrError, e: raise zc.buildout.UserError( 'Finding revid for revision %s of %s failed:\n%s' % (rev, branch_loc, e)) else: if buildout['buildout'].get_bool('newest') and not created: remote_branch = BzrBranch.open(branch_loc) bzr_branch.pull(remote_branch, overwrite=True) revno, revid = revision_info(bzr_branch, '-1') checkout_dir = os.path.join(repo, 'checkouts', '%s-%s' % (revno, revid)) if not os.path.exists(checkout_dir): rev_branch = bzr_branch.create_clone_on_transport( get_transport(checkout_dir), revision_id=revid, no_tree=False) if not rev_branch.bzrdir.has_workingtree(): rev_branch.bzrdir.create_workingtree() zc.buildout.easy_install.develop( buildout._buildout_path(checkout_dir), buildout['buildout']['develop-eggs-directory'])
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 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:
def __init__(self, local_path, remote_url): if without_svn: raise RuntimeError("You need install PySVN to use SVN capabilities.") self = RepositoryBase.__init__(self, local_path, remote_url) load_plugins()
def __init__(self, local_path, remote_url): self = RepositoryBase.__init__(self, local_path, remote_url) load_plugins()
# Copyright (C) 2006 Wouter van Heyst # Copyright (C) 2006-2008 Jelmer Vernooij <*****@*****.**> # # Published under the GNU GPL import gtk import nautilus import bzrlib from bzrlib.branch import Branch from bzrlib.bzrdir import BzrDir from bzrlib.errors import NotBranchError, NoWorkingTree, UnsupportedProtocol from bzrlib.workingtree import WorkingTree from bzrlib.config import GlobalConfig from bzrlib.plugin import load_plugins load_plugins() from bzrlib.plugins.gtk.commands import cmd_gannotate, start_viz_window print "Bazaar nautilus module initialized" class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider): def __init__(self): pass def add_cb(self, menu, vfs_file): # We can only cope with local files if vfs_file.get_uri_scheme() != 'file': return
action="store_true", help="Generate only the shell function, don't enable it") parser.add_option("--debug", action="store_true", help=optparse.SUPPRESS_HELP) parser.add_option("--no-plugins", action="store_true", help="Don't load any bzr plugins") parser.add_option("--plugin", metavar="NAME", type="string", dest="selected_plugins", default=[], action="callback", callback=plugin_callback, help="Enable completions for the selected plugin" + " (default: all plugins)") (opts, args) = parser.parse_args() if args: parser.error("script does not take positional arguments") kwargs = dict() for name, value in opts.__dict__.iteritems(): if value is not None: kwargs[name] = value locale.setlocale(locale.LC_ALL, '') if not kwargs.get('no_plugins', False): plugin.load_plugins() commands.install_bzr_command_hooks() bash_completion_function(sys.stdout, **kwargs)
def clone_bzr_repo(url, local_path): load_plugins() bzr_repo = Branch.open(url) bzr_repo.bzrdir.sprout(local_path).open_branch()
def get_BZR_PLUGIN_PATH_for_subprocess(): """Calculate the appropriate value for the BZR_PLUGIN_PATH environment. The '-site' token tells bzrlib not to include the 'site specific plugins directory' (which is usually something like /usr/lib/pythonX.Y/dist-packages/bzrlib/plugins/) in the plugin search path, which would be inappropriate for Launchpad, which may be using a bzr egg of an incompatible version. """ return ":".join((_get_bzr_plugins_path(), "-site")) os.environ['BZR_PLUGIN_PATH'] = get_BZR_PLUGIN_PATH_for_subprocess() # We want to have full access to Launchpad's Bazaar plugins throughout the # codehosting package. load_plugins([_get_bzr_plugins_path()]) def load_bundled_plugin(plugin_name): """Load a plugin bundled with Bazaar.""" from bzrlib.plugin import get_core_plugin_path from bzrlib import plugins if get_core_plugin_path() not in plugins.__path__: plugins.__path__.append(get_core_plugin_path()) __import__("bzrlib.plugins.%s" % plugin_name) load_bundled_plugin("weave_fmt")