diff -Nru bzr-loom-2.1+bzr139/branch.py bzr-loom-2.2.0/branch.py --- bzr-loom-2.1+bzr139/branch.py 2011-06-23 19:06:47.000000000 +0000 +++ bzr-loom-2.2.0/branch.py 2012-02-26 16:47:05.000000000 +0000 @@ -24,32 +24,34 @@ loom branch. """ +from __future__ import absolute_import + from StringIO import StringIO import bzrlib.branch -from bzrlib import bzrdir +from bzrlib import ( + bzrdir, + errors, + fetch as _mod_fetch, + remote, + symbol_versioning, + trace, + tree as _mod_tree, + ui, + urlutils, + ) from bzrlib.decorators import needs_read_lock, needs_write_lock -import bzrlib.errors -import bzrlib.fetch -import bzrlib.graph -import bzrlib.osutils -from bzrlib import remote, symbol_versioning -import bzrlib.trace -import bzrlib.ui from bzrlib.revision import is_null, NULL_REVISION -import bzrlib.tree -import bzrlib.urlutils -import formats -import loom_io -import loom_state +from bzrlib.plugins.loom import ( + formats, + loom_io, + loom_state, + ) EMPTY_REVISION = 'empty:' -# Required for compatibility with bzr < 2.4b2 -InventoryTree = getattr(bzrlib.tree, "InventoryTree", bzrlib.tree.Tree) - def create_thread(loom, thread_name): """Create a thread in the branch loom called thread.""" @@ -62,12 +64,12 @@ loom.unlock() -class AlreadyLoom(bzrlib.errors.BzrError): +class AlreadyLoom(errors.BzrError): _fmt = """Loom %(loom)s is already a loom.""" def __init__(self, loom): - bzrlib.errors.BzrError.__init__(self) + errors.BzrError.__init__(self) self.loom = loom @@ -101,26 +103,26 @@ NotALoom = formats.NotALoom -class LoomThreadError(bzrlib.errors.BzrError): +class LoomThreadError(errors.BzrError): """Base class for Loom-Thread errors.""" def __init__(self, branch, thread): - bzrlib.errors.BzrError.__init__(self) + errors.BzrError.__init__(self) self.branch = branch self.thread = thread -class UnrecordedRevision(bzrlib.errors.BzrError): +class UnrecordedRevision(errors.BzrError): _fmt = """The revision %(revision_id)s is not recorded in the loom %(branch)s.""" def __init__(self, branch, revision_id): - bzrlib.errors.BzrError.__init__(self) + errors.BzrError.__init__(self) self.branch = branch self.revision_id = revision_id -class UnsupportedBranchFormat(bzrlib.errors.BzrError): +class UnsupportedBranchFormat(errors.BzrError): _fmt = """The branch format %(format)s is not supported by loomify.""" @@ -143,7 +145,7 @@ _fmt = """No such thread '%(thread)s'.""" -class NoLowerThread(bzrlib.errors.BzrError): +class NoLowerThread(errors.BzrError): _fmt = """No lower thread exists.""" @@ -153,7 +155,7 @@ _fmt = """Cannot combine threads on the bottom thread.""" -class LoomMetaTree(InventoryTree): +class LoomMetaTree(_mod_tree.InventoryTree): """A 'tree' object that is used to commit the loom meta branch.""" def __init__(self, loom_meta_ie, loom_stream, loom_sha1): @@ -242,7 +244,7 @@ :type other: Branch """ # Looms are not currently bindable. - raise bzrlib.errors.UpgradeRequired(self.base) + raise errors.UpgradeRequired(self.base) @needs_read_lock def clone(self, to_bzrdir, revision_id=None, repository_policy=None, name=None): @@ -267,7 +269,7 @@ revision_id=revision_id) return result - def _get_checkout_format(self): + def _get_checkout_format(self, lightweight=False): """Checking out a Loom gets a regular branch for now. This is a short term measure to get to an all-tests passing status. @@ -287,7 +289,7 @@ def get_old_bound_location(self): """Return the URL of the branch we used to be bound to.""" # No binding for looms yet. - raise bzrlib.errors.UpgradeRequired(self.base) + raise errors.UpgradeRequired(self.base) def get_threads(self, rev_id): """Return the threads from a loom revision. @@ -313,14 +315,14 @@ threads = self.get_loom_state().get_threads() for thread_name, thread_revision, _parents in threads: thread_transport = root_transport.clone(thread_name) - user_location = bzrlib.urlutils.unescape_for_display( + user_location = urlutils.unescape_for_display( thread_transport.base, 'utf-8') try: control_dir = bzrdir.BzrDir.open(thread_transport.base, possible_transports=[thread_transport]) tree, branch = control_dir._get_tree_branch() - except bzrlib.errors.NotBranchError: - bzrlib.trace.note('Creating branch at %s' % user_location) + except errors.NotBranchError: + trace.note('Creating branch at %s' % user_location) branch = bzrdir.BzrDir.create_branch_convenience( thread_transport.base, possible_transports=[thread_transport]) @@ -328,11 +330,11 @@ thread_transport.base) else: if thread_revision == branch.last_revision(): - bzrlib.trace.note('Skipping up-to-date branch at %s' + trace.note('Skipping up-to-date branch at %s' % user_location) continue else: - bzrlib.trace.note('Updating branch at %s' % user_location) + trace.note('Updating branch at %s' % user_location) if tree is not None: tree.pull(self, stop_revision=thread_revision) else: @@ -435,7 +437,7 @@ return super(LoomSupport, self).push(target, overwrite, stop_revision, lossy=lossy, _override_hook_source_branch=None) if lossy: - raise bzrlib.errors.LossyPushToSameVCS(self, target) + raise errors.LossyPushToSameVCS(self, target) return _Pusher(self, target).transfer(overwrite, stop_revision, run_hooks=True) @@ -451,7 +453,7 @@ threads = state.get_threads() # check the semantic value, not the serialised value for equality. if old_threads == threads: - raise bzrlib.errors.PointlessCommit + raise errors.PointlessCommit builder = self.get_commit_builder(parents) loom_ie = bzrlib.inventory.make_entry( 'file', 'loom', bzrlib.inventory.ROOT_ID, 'loom_meta_tree') @@ -467,7 +469,7 @@ builder.record_entry_contents(root_ie, [], '', loom_tree, ('directory', None, None, None)) builder.record_entry_contents( - loom_ie, parents, 'loom', loom_tree, + loom_ie, list(self.repository.iter_inventories(parents)), 'loom', loom_tree, # a fake contents so that the file is determined as changed. ('file', 0, False, None)) builder.finish_inventory() @@ -641,27 +643,31 @@ fetch_spec=fetch_spec) self.target.generate_revision_history(new_rev, self.target.last_revision(), self.source) - result.tag_conflicts = self.source.tags.merge_to(self.target.tags) + tag_ret = self.source.tags.merge_to(self.target.tags) + if isinstance(tag_ret, tuple): + result.tag_updates, result.tag_conflicts = tag_ret + else: + result.tag_conflicts = tag_ret # get the final result object details self.do_hooks(result, run_hooks) return result def build_fetch_spec(self, stop_revision): - factory = bzrlib.fetch.FetchSpecFactory() + factory = _mod_fetch.FetchSpecFactory() factory.source_branch = self.source factory.source_repo = self.source.repository factory.source_branch_stop_revision_id = stop_revision factory.target_repo = self.target.repository - factory.target_repo_kind = bzrlib.fetch.TargetRepoKinds.PREEXISTING + factory.target_repo_kind = _mod_fetch.TargetRepoKinds.PREEXISTING return factory.make_fetch_spec() def transfer(self, overwrite, stop_revision, run_hooks=True, possible_transports=None, _override_hook_target=None, local=False): """Implementation of push and pull""" if local: - raise bzrlib.errors.LocalRequiresBoundBranch() + raise errors.LocalRequiresBoundBranch() # pull the loom, and position our - pb = bzrlib.ui.ui_factory.nested_progress_bar() + pb = ui.ui_factory.nested_progress_bar() try: result = self.prepare_result(_override_hook_target) self.target.lock_write() @@ -682,7 +688,7 @@ graph = self.source.repository.get_graph() if not graph.is_ancestor(my_state.get_parents()[0], source_loom_rev): - raise bzrlib.errors.DivergedBranches( + raise errors.DivergedBranches( self.target, self.source) # fetch the loom content self.target.repository.fetch(self.source.repository, @@ -713,7 +719,11 @@ new_rev = bzrlib.revision.NULL_REVISION self.target.generate_revision_history(new_rev) # merge tags - result.tag_conflicts = self.source.tags.merge_to(self.target.tags) + tag_ret = self.source.tags.merge_to(self.target.tags) + if isinstance(tag_ret, tuple): + result.tag_updates, tag_conflicts = tag_ret + else: + result.tag_conflicts = tag_ret self.do_hooks(result, run_hooks) return result finally: @@ -764,17 +774,13 @@ # A mixin is not ideal because it is tricky to test, but it seems to be the # best solution for now. - def initialize(self, a_bzrdir, name=None, repository=None): + def initialize(self, a_bzrdir, name=None, repository=None, + append_revisions_only=None): """Create a branch of this format in a_bzrdir.""" - if name is not None: - raise bzrlib.errors.NoColocatedBranchSupport(self) - if repository is None: - super(LoomFormatMixin, self).initialize(a_bzrdir, name=None) - else: - # The 'repository' optional keyword arg is new in bzr 2.3, so don't - # pass it unless it was passed in. - super(LoomFormatMixin, self).initialize(a_bzrdir, name=None, - repository=repository) + super(LoomFormatMixin, self).initialize(a_bzrdir, name=name, + repository=repository, + append_revisions_only=append_revisions_only) + branch_transport = a_bzrdir.get_branch_transport(self) files = [] state = loom_state.LoomState() @@ -787,29 +793,27 @@ branch_transport, 'lock', bzrlib.lockdir.LockDir) control_files.lock_write() try: - for name, stream in files: - branch_transport.put_file(name, stream) + for filename, stream in files: + branch_transport.put_file(filename, stream) finally: control_files.unlock() - return self.open(a_bzrdir, _found=True, ) + return self.open(a_bzrdir, _found=True, name=name) def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False, - found_repository=None): + found_repository=None, possible_transports=None): """Return the branch object for a_bzrdir _found is a private parameter, do not use it. It is used to indicate if format probing has already be done. :param name: The 'colocated branches' name for the branch to open. - in future, Loom may use that to return a Thread, but for now - it is unused. """ + if name is None: + name = a_bzrdir._get_selected_branch() if not _found: - format = bzrlib.branch.BranchFormat.find_format(a_bzrdir) + format = bzrlib.branch.BranchFormat.find_format(a_bzrdir, name=name) assert format.__class__ == self.__class__ - if name is not None: - raise bzrlib.errors.NoColocatedBranchSupport(self) - transport = a_bzrdir.get_branch_transport(None) + transport = a_bzrdir.get_branch_transport(None, name=name) control_files = bzrlib.lockable_files.LockableFiles( transport, 'lock', bzrlib.lockdir.LockDir) if found_repository is None: @@ -818,7 +822,8 @@ _control_files=control_files, a_bzrdir=a_bzrdir, _repository=found_repository, - ignore_fallbacks=ignore_fallbacks) + ignore_fallbacks=ignore_fallbacks, + name=name) def take_over(self, branch): """Take an existing bzrlib branch over into Loom format. @@ -856,7 +861,8 @@ _parent_classs = bzrlib.branch.BzrBranchFormat5 - def get_format_string(self): + @classmethod + def get_format_string(cls): """See BranchFormat.get_format_string().""" return "Bazaar-NG Loom branch format 1\n" @@ -885,7 +891,8 @@ _parent_classs = bzrlib.branch.BzrBranchFormat6 - def get_format_string(self): + @classmethod + def get_format_string(cls): """See BranchFormat.get_format_string().""" return "Bazaar-NG Loom branch format 6\n" @@ -914,7 +921,8 @@ _parent_classs = bzrlib.branch.BzrBranchFormat7 - def get_format_string(self): + @classmethod + def get_format_string(cls): """See BranchFormat.get_format_string().""" return "Bazaar-NG Loom branch format 7\n" @@ -932,12 +940,7 @@ @classmethod def _get_branch_formats_to_test(klass): - try: - format_registry = getattr(bzrlib.branch, "format_registry") - except AttributeError: # bzr < 2.4 - default_format = bzrlib.branch.BranchFormat._default_format - else: - default_format = format_registry.get_default() + default_format = bzrlib.branch.format_registry.get_default() return [ (default_format, BzrBranchLoomFormat7()), (BzrBranchLoomFormat7(), default_format), @@ -999,7 +1002,7 @@ # pull in the warp, which was skipped during the initial pull # because the front end does not know what to pull. # nb: this is mega huge hacky. THINK. RBC 2006062 - nested = bzrlib.ui.ui_factory.nested_progress_bar() + nested = ui.ui_factory.nested_progress_bar() try: if parents: self.target.repository.fetch(self.source.repository, @@ -1032,8 +1035,8 @@ self.source._synchronize_history(self.target, revision_id) try: parent = self.source.get_parent() - except bzrlib.errors.InaccessibleParent, e: - bzrlib.trace.mutter('parent was not accessible to copy: %s', e) + except errors.InaccessibleParent, e: + trace.mutter('parent was not accessible to copy: %s', e) else: if parent: self.target.set_parent(parent) diff -Nru bzr-loom-2.1+bzr139/commands.py bzr-loom-2.2.0/commands.py --- bzr-loom-2.1+bzr139/commands.py 2011-03-31 15:15:33.000000000 +0000 +++ bzr-loom-2.2.0/commands.py 2012-02-26 16:47:05.000000000 +0000 @@ -17,6 +17,8 @@ """Loom commands.""" +from __future__ import absolute_import + from bzrlib import bzrdir, directory_service, workingtree import bzrlib.commands import bzrlib.branch @@ -26,11 +28,11 @@ import bzrlib.trace import bzrlib.transport -import formats +from bzrlib.plugins.loom import formats lazy_import(globals(), """ -import branch -from tree import LoomTreeDecorator +from bzrlib.plugins.loom import branch +from bzrlib.plugins.loom.tree import LoomTreeDecorator """) @@ -177,34 +179,6 @@ loom.unlock() -class cmd_status(bzrlib.builtins.cmd_status): - """Show status of a loom.""" - - _original_command = None - - def run(self, show_ids=False, file_list=None, revision=None, short=False, - versioned=False, no_pending=False, verbose=None): - if file_list is None: - path = '.' - else: - path = file_list[0] - (loom, _) = bzrlib.branch.Branch.open_containing(path) - formats.require_loom_branch(loom) - loom.lock_read() - try: - print 'Current thread: %s' % loom.nick - finally: - loom.unlock() - - def run_argv_aliases(self, argv, alias_argv=None): - """Decorate bzr's cmd_status to show status for looms as well.""" - self._original_command().run_argv_aliases(argv, alias_argv) - try: - super(cmd_status, self).run_argv_aliases(list(argv), alias_argv) - except formats.NotALoom: - pass - - class cmd_switch(bzrlib.builtins.cmd_switch): """Set the branch of a checkout and update. diff -Nru bzr-loom-2.1+bzr139/debian/bzr-builddeb.conf bzr-loom-2.2.0/debian/bzr-builddeb.conf --- bzr-loom-2.1+bzr139/debian/bzr-builddeb.conf 1970-01-01 00:00:00.000000000 +0000 +++ bzr-loom-2.2.0/debian/bzr-builddeb.conf 2012-02-26 16:30:10.000000000 +0000 @@ -0,0 +1,6 @@ +[BUILDDEB] +export-upstream-revision = tag:bzr-loom-$UPSTREAM_VERSION +upstream-branch = lp:bzr-loom + +[HOOKS] +merge-upstream = ./debian/update-deps.py diff -Nru bzr-loom-2.1+bzr139/debian/changelog bzr-loom-2.2.0/debian/changelog --- bzr-loom-2.1+bzr139/debian/changelog 2011-07-23 21:49:21.000000000 +0000 +++ bzr-loom-2.2.0/debian/changelog 2012-03-11 01:10:35.000000000 +0000 @@ -1,8 +1,41 @@ -bzr-loom (2.1+bzr139-1~bazaar1~lucid1) lucid; urgency=low +bzr-loom (2.2.0-1~bazaar1~lucid1) lucid; urgency=low * Rebuild in PPA. - -- Max Bowsher <_@maxb.eu> Sat, 23 Jul 2011 22:49:21 +0100 + -- Max Bowsher <_@maxb.eu> Sun, 11 Mar 2012 01:10:35 +0000 + +bzr-loom (2.2.0-1) unstable; urgency=low + + * Add script for automatically updating dependencies on merge. + * New upstream release. + + Fixes compatibility with newer versions of bzr. LP: #924521 + + -- Jelmer Vernooij Sun, 26 Feb 2012 17:51:52 +0100 + +bzr-loom (2.1+bzr151-1) unstable; urgency=low + + * New upstream snapshot. + * Add autopkgtest tests. + + -- Jelmer Vernooij Sun, 26 Feb 2012 17:09:55 +0100 + +bzr-loom (2.1+bzr150-1) unstable; urgency=low + + * New upstream snapshot. + + -- Jelmer Vernooij Wed, 08 Feb 2012 12:13:10 +0100 + +bzr-loom (2.1+bzr148-1) unstable; urgency=low + + [ Max Bowsher ] + * New upstream snapshot. + * Drop 01_fix_record_entry_contents, merged upstream. + + [ Jelmer Vernooij ] + * New upstream snapshot. + + Fixes compatibility with newer versions of bzr. Closes: #652776 + + -- Jelmer Vernooij Tue, 20 Dec 2011 16:26:03 +0100 bzr-loom (2.1+bzr139-1) unstable; urgency=low diff -Nru bzr-loom-2.1+bzr139/debian/control bzr-loom-2.2.0/debian/control --- bzr-loom-2.1+bzr139/debian/control 2011-05-06 01:30:15.000000000 +0000 +++ bzr-loom-2.2.0/debian/control 2012-02-26 16:51:52.000000000 +0000 @@ -5,9 +5,8 @@ Uploaders: Andrew Starr-Bochicchio , Jelmer Vernooij Homepage: https://launchpad.net/bzr-loom -Build-Depends: debhelper (>= 7.0.50~), - python (>= 2.6.6-3) -Build-Depends-Indep: bzr (>= 1.6), +Build-Depends: debhelper (>= 7.0.50~), python (>= 2.6.6-3), python-bzrlib (>= 2.4~) +Build-Depends-Indep: bzr, python-subunit, python-testtools, python-bzrlib.tests | bzr (<< 2.4.0~beta1-2) @@ -18,9 +17,8 @@ Package: bzr-loom Architecture: all -Depends: bzr (>= 1.6), - ${misc:Depends}, - ${python:Depends} +Depends: ${misc:Depends}, ${python:Depends}, python-bzrlib (>= 2.4~) +Recommends: bzr Enhances: bzr Description: Focused patch plugin support for Bazaar Loom is a Bazaar plugin to assist in developing focused patches. It adds a diff -Nru bzr-loom-2.1+bzr139/debian/patches/01_fix_record_entry_contents bzr-loom-2.2.0/debian/patches/01_fix_record_entry_contents --- bzr-loom-2.1+bzr139/debian/patches/01_fix_record_entry_contents 2011-07-19 16:52:27.000000000 +0000 +++ bzr-loom-2.2.0/debian/patches/01_fix_record_entry_contents 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -Description: Properly pass inventories to record_entry_contents rather than the list of parent revision ids. -Origin: commit, revision id: jelmer@samba.org-20110719163953-04actftfkon1ukzx -Author: Jelmer Vernooij -Last-Update: 2011-07-19 -Applied-Upstream: no -X-Bzr-Revision-Id: jelmer@samba.org-20110719163953-04actftfkon1ukzx - -=== modified file 'branch.py' ---- old/branch.py 2011-06-23 19:06:47 +0000 -+++ new/branch.py 2011-07-19 16:39:53 +0000 -@@ -467,7 +467,7 @@ - builder.record_entry_contents(root_ie, [], '', loom_tree, - ('directory', None, None, None)) - builder.record_entry_contents( -- loom_ie, parents, 'loom', loom_tree, -+ loom_ie, list(self.repository.iter_inventories(parents)), 'loom', loom_tree, - # a fake contents so that the file is determined as changed. - ('file', 0, False, None)) - builder.finish_inventory() - diff -Nru bzr-loom-2.1+bzr139/debian/patches/series bzr-loom-2.2.0/debian/patches/series --- bzr-loom-2.1+bzr139/debian/patches/series 2011-07-19 16:52:35.000000000 +0000 +++ bzr-loom-2.2.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -01_fix_record_entry_contents diff -Nru bzr-loom-2.1+bzr139/debian/tests/control bzr-loom-2.2.0/debian/tests/control --- bzr-loom-2.1+bzr139/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ bzr-loom-2.2.0/debian/tests/control 2012-02-24 16:30:12.000000000 +0000 @@ -0,0 +1,3 @@ +Tests: testsuite +Depends: bzr, python-bzrlib.tests +Features: no-build-needed diff -Nru bzr-loom-2.1+bzr139/debian/tests/testsuite bzr-loom-2.2.0/debian/tests/testsuite --- bzr-loom-2.1+bzr139/debian/tests/testsuite 1970-01-01 00:00:00.000000000 +0000 +++ bzr-loom-2.2.0/debian/tests/testsuite 2012-02-26 16:09:15.000000000 +0000 @@ -0,0 +1,4 @@ +#!/bin/sh +# Note that since the installed version of the package has to be tested, +# there is no mucking about with BZR_PLUGINS_AT. +bzr selftest -s bp.loom -v --parallel=fork diff -Nru bzr-loom-2.1+bzr139/debian/update-deps.py bzr-loom-2.2.0/debian/update-deps.py --- bzr-loom-2.1+bzr139/debian/update-deps.py 1970-01-01 00:00:00.000000000 +0000 +++ bzr-loom-2.2.0/debian/update-deps.py 2012-02-26 16:29:15.000000000 +0000 @@ -0,0 +1,47 @@ +#!/usr/bin/python +# Update dependencies based on version.py +# Copyright (C) 2012 Jelmer Vernooij +# Licensed under the GNU GPL, version 2 or later. + +from debian.deb822 import Deb822, PkgRelation +import os, sys +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) + +from version import bzr_minimum_version, bzr_maximum_version + +def update_relation(l, pkg, kind, version): + found = False + for pr in l: + if len(pr) != 1: # only update simple build deps + continue + e = pr[0] + if e["name"] == pkg and e["version"] and e["version"][0] == kind: + e["version"] = (kind, version) + found = True + if not found: + l.append([{"version": (kind, version), "name": pkg, "arch": None}]) + +f = open('debian/control', 'r') + +source = Deb822(f) + +def update_deps(control, field): + bdi = PkgRelation.parse_relations(control[field]) + update_relation(bdi, "python-bzrlib", ">=", "%d.%d~" % bzr_minimum_version[:2]) + if bzr_maximum_version is not None: + update_relation(bdi, "python-bzrlib", "<<", "%d.%d.0" % (bzr_maximum_version[0], bzr_maximum_version[1]+1)) + control[field] = PkgRelation.str(bdi) + +update_deps(source, "Build-Depends") + +binary = Deb822(f) + +update_deps(binary, "Depends") + +f = open("debian/control", "w+") +try: + source.dump(f) + f.write("\n") + binary.dump(f) +finally: + f.close() diff -Nru bzr-loom-2.1+bzr139/debian/watch bzr-loom-2.2.0/debian/watch --- bzr-loom-2.1+bzr139/debian/watch 2010-08-02 19:53:40.000000000 +0000 +++ bzr-loom-2.2.0/debian/watch 2012-02-26 16:50:39.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -https://launchpad.net/bzr-loom/+download http://launchpad.net/bzr-loom/.*/bzr-loom-(.*)\.tar\.gz +https://launchpad.net/bzr-loom/+download https://launchpad.net/bzr-loom/.*/bzr-loom-(.*)\.tar\.gz diff -Nru bzr-loom-2.1+bzr139/formats.py bzr-loom-2.2.0/formats.py --- bzr-loom-2.1+bzr139/formats.py 2011-02-23 15:54:34.000000000 +0000 +++ bzr-loom-2.2.0/formats.py 2012-02-26 16:47:05.000000000 +0000 @@ -15,6 +15,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import absolute_import + """Format information about formats for Loom. This is split out from the implementation of the formats to permit lazy @@ -42,25 +44,11 @@ } def register_formats(): - if getattr(_mod_branch, 'MetaDirBranchFormatFactory', None): - branch_formats = [_mod_branch.MetaDirBranchFormatFactory(format_string, - "bzrlib.plugins.loom.branch", format_class) for - (format_string, format_class) in _LOOM_FORMATS.iteritems()] - else: - # Compat for folk not running bleeding edge. Like me as I commit this. - import branch - branch_formats = [ - branch.BzrBranchLoomFormat1(), - branch.BzrBranchLoomFormat6(), - branch.BzrBranchLoomFormat7(), - ] - try: - format_registry = getattr(_mod_branch, 'format_registry') - register = format_registry.register - except AttributeError: # bzr < 2.4 - register = _mod_branch.BranchFormat.register_format - - map(register, branch_formats) + branch_formats = [_mod_branch.MetaDirBranchFormatFactory(format_string, + "bzrlib.plugins.loom.branch", format_class) for + (format_string, format_class) in _LOOM_FORMATS.iteritems()] + format_registry = getattr(_mod_branch, 'format_registry') + map(format_registry.register, branch_formats) def require_loom_branch(branch): diff -Nru bzr-loom-2.1+bzr139/__init__.py bzr-loom-2.2.0/__init__.py --- bzr-loom-2.1+bzr139/__init__.py 2010-07-01 04:18:08.000000000 +0000 +++ bzr-loom-2.2.0/__init__.py 2012-02-26 16:47:05.000000000 +0000 @@ -15,6 +15,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +from __future__ import absolute_import + """Loom is a bzr plugin which adds new commands to manage a loom of patches. Loom adds the following new commands: @@ -55,14 +57,23 @@ revision specifiers. """ -from version import bzr_plugin_version as version_info +from bzrlib.plugins.loom.version import ( + bzr_plugin_version as version_info, + bzr_minimum_version, + ) + +import bzrlib +import bzrlib.api + +bzrlib.api.require_api(bzrlib, bzr_minimum_version) import bzrlib.builtins import bzrlib.commands -import bzrlib.revisionspec -import commands -import formats +from bzrlib.plugins.loom import ( + commands, + formats, + ) for command in [ @@ -79,7 +90,7 @@ bzrlib.commands.plugin_cmds.register_lazy('cmd_' + command, [], 'bzrlib.plugins.loom.commands') -# XXX: bzr fix needed: for status and switch, we have to register directly, not +# XXX: bzr fix needed: for switch, we have to register directly, not # lazily, because register_lazy does not stack in the same way register_command # does. if not hasattr(bzrlib.builtins, "cmd_switch"): @@ -89,19 +100,26 @@ commands.cmd_switch._original_command = bzrlib.commands.register_command( getattr(commands, 'cmd_switch'), True) -commands.cmd_status._original_command = bzrlib.commands.register_command( - commands.cmd_status, True) - -revspec_registry = getattr(bzrlib.revisionspec, 'revspec_registry', None) -if revspec_registry is not None: - revspec_registry.register_lazy('thread:', 'bzrlib.plugins.loom.revspec', - 'RevisionSpecThread') - revspec_registry.register_lazy('below:', 'bzrlib.plugins.loom.revspec', - 'RevisionSpecBelow') -else: - import revspec - bzrlib.revisionspec.SPEC_TYPES.append(revspec.RevisionSpecThread) - bzrlib.revisionspec.SPEC_TYPES.append(revspec.RevisionSpecBelow) +from bzrlib.hooks import install_lazy_named_hook +def show_loom_summary(params): + branch = getattr(params.new_tree, "branch", None) + if branch is None: + # Not a working tree, ignore + return + try: + formats.require_loom_branch(branch) + except formats.NotALoom: + return + params.to_file.write('Current thread: %s\n' % branch.nick) + +install_lazy_named_hook('bzrlib.status', 'hooks', 'post_status', + show_loom_summary, 'loom status') + +from bzrlib.revisionspec import revspec_registry +revspec_registry.register_lazy('thread:', 'bzrlib.plugins.loom.revspec', + 'RevisionSpecThread') +revspec_registry.register_lazy('below:', 'bzrlib.plugins.loom.revspec', + 'RevisionSpecBelow') #register loom formats formats.register_formats() diff -Nru bzr-loom-2.1+bzr139/NEWS bzr-loom-2.2.0/NEWS --- bzr-loom-2.1+bzr139/NEWS 2010-12-16 01:32:05.000000000 +0000 +++ bzr-loom-2.2.0/NEWS 2012-02-26 16:47:05.000000000 +0000 @@ -4,15 +4,14 @@ .. contents:: -IN DEVELOPMENT -============== +2.2 +=== NOTES WHEN UPGRADING -------------------- -* bzr-loom requires bzr 2.2.0 (or very recent 2.2b releases) due to an API - change in bzr needed to fix branching and pulling of looms. On older versions - of bzr bzr-loom will still work for most operations but will fail when making +* bzr-loom requires bzr 2.4.0 due to API changes in bzr. On older versions of + bzr bzr-loom will still work for most operations but will fail when making new branches as part of a push or branch operation. (Robert Collins, #201613) CHANGES @@ -39,6 +38,12 @@ complete degree), reducing the overhead of having it installed. (Robert Collins) +* Loom now registers a ``bzr status`` hook rather than overriding the + ``bzr status`` command. (Jelmer Vernooij) + +* Loom now checks that a compatible version of bzr is being used. + (Jelmer Vernooij, #338214) + BUGFIXES -------- @@ -60,6 +65,9 @@ * The ``thread:`` revision specifier will no longer throw an attribute error when used on a normal branch. (Robert Collins, #231283) +* The ``bzr status`` hook for looms will no longer crash on non-workingtree + trees. (Jelmer Vernooij, #904095) + API BREAKS ---------- diff -Nru bzr-loom-2.1+bzr139/.testr.conf bzr-loom-2.2.0/.testr.conf --- bzr-loom-2.1+bzr139/.testr.conf 2010-04-20 07:48:35.000000000 +0000 +++ bzr-loom-2.2.0/.testr.conf 2012-02-26 16:47:05.000000000 +0000 @@ -1,4 +1,4 @@ [DEFAULT] -# not quite idea, because 'all tests' is too many, and 'just loom' is too few. -test_command=bzr selftest --subunit $IDOPTION +test_command=bzr selftest --subunit $IDOPTION $LISTOPT bzrlib.plugins.loom Loom test_id_option=--load-list $IDFILE +test_list_option=--list diff -Nru bzr-loom-2.1+bzr139/tests/blackbox.py bzr-loom-2.2.0/tests/blackbox.py --- bzr-loom-2.1+bzr139/tests/blackbox.py 2010-07-02 04:27:17.000000000 +0000 +++ bzr-loom-2.2.0/tests/blackbox.py 2012-02-26 16:47:05.000000000 +0000 @@ -52,7 +52,7 @@ tree.commit('first release') self.run_bzr(['loomify', path]) return tree.bzrdir.open_workingtree() - + def assert_exception_raised_on_non_loom_branch(self, args): """Helper to check UserError gets raised when commands are run in a non-loomed branch.""" tree = self.make_branch_and_tree('.') @@ -104,7 +104,7 @@ class TestCreate(TestsWithLooms): - + def test_create_no_changes(self): tree = self.get_vendor_loom() out, err = self.run_bzr(['create-thread', 'debian']) @@ -140,7 +140,7 @@ class TestShow(TestsWithLooms): - + def test_show_loom(self): """Show the threads in the loom.""" tree = self.get_vendor_loom() @@ -184,6 +184,19 @@ class TestStatus(TestsWithLooms): + def setUp(self): + super(TestStatus, self).setUp() + # The test suite resets after each run, so manually register + # the loom status hook. + try: + from bzrlib.hooks import install_lazy_named_hook + except ImportError: + pass + else: + from bzrlib.plugins.loom import show_loom_summary + install_lazy_named_hook('bzrlib.status', 'hooks', 'post_status', + show_loom_summary, 'loom status') + def test_status_shows_current_thread(self): # 'bzr status' shows the current thread. tree = self.get_vendor_loom() @@ -227,7 +240,7 @@ class TestSwitch(TestsWithLooms): - + def test_switch_thread_up_does_not_merge(self): tree = self.get_vendor_loom() self._add_patch(tree, 'thread1') @@ -596,7 +609,9 @@ tree.branch.record_loom('commit loom.') out, err = self.run_bzr(['branch', 'source', 'target']) self.assertEqual('', out) - self.assertEqual('Branched 1 revision(s).\n', err) + self.assertTrue( + err == 'Branched 1 revision(s).\n' or + err == 'Branched 1 revision.\n') # lower level tests check behaviours, just check show-loom as a smoke # test. out, err = self.run_bzr(['show-loom', 'target']) diff -Nru bzr-loom-2.1+bzr139/tests/test_branch.py bzr-loom-2.2.0/tests/test_branch.py --- bzr-loom-2.1+bzr139/tests/test_branch.py 2010-07-16 08:30:13.000000000 +0000 +++ bzr-loom-2.2.0/tests/test_branch.py 2012-02-26 16:47:05.000000000 +0000 @@ -338,11 +338,8 @@ if source_threads: source_tree.branch.generate_revision_history(source_threads[-1][1]) self.assertEqual( - source_tree.branch.revision_history(), - target_tree.branch.revision_history()) - self.assertEqual( - source_tree.branch.last_revision(), - target_tree.last_revision()) + source_tree.branch.last_revision_info(), + target_tree.branch.last_revision_info()) def test_pull_loom_at_bottom(self): """Pulling from a loom when in the bottom warp pulls all warps.""" diff -Nru bzr-loom-2.1+bzr139/tests/test_tree.py bzr-loom-2.2.0/tests/test_tree.py --- bzr-loom-2.1+bzr139/tests/test_tree.py 2010-07-02 04:27:17.000000000 +0000 +++ bzr-loom-2.2.0/tests/test_tree.py 2012-02-26 16:47:05.000000000 +0000 @@ -97,9 +97,14 @@ tree_loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree) tree_loom_tree.down_thread() # check the test will be valid - self.assertEqual([None, bottom_rev1, top_rev1], - tree.branch.repository.get_ancestry(top_rev1)) - self.assertEqual([bottom_rev1], tree.get_parent_ids()) + tree.lock_read() + try: + graph = tree.branch.repository.get_graph() + self.assertEqual([top_rev1, bottom_rev1, NULL_REVISION], + [r for (r, ps) in graph.iter_ancestry([top_rev1])]) + self.assertEqual([bottom_rev1], tree.get_parent_ids()) + finally: + tree.unlock() tree_loom_tree.up_thread() self.assertEqual('top', tree.branch.nick) self.assertEqual([top_rev1], tree.get_parent_ids()) @@ -116,9 +121,14 @@ tree_loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree) tree_loom_tree.down_thread() # check the test will be valid - self.assertEqual([None, bottom_rev1, top_rev1], - tree.branch.repository.get_ancestry(top_rev1)) - self.assertEqual([bottom_rev1], tree.get_parent_ids()) + tree.lock_read() + try: + graph = tree.branch.repository.get_graph() + self.assertEqual([top_rev1, bottom_rev1, NULL_REVISION], + [r for (r, ps) in graph.iter_ancestry([top_rev1])]) + self.assertEqual([bottom_rev1], tree.get_parent_ids()) + finally: + tree.unlock() bottom_rev2 = tree.commit('bottom_two', allow_pointless=True) tree_loom_tree.up_thread() self.assertEqual('top', tree.branch.nick) diff -Nru bzr-loom-2.1+bzr139/version.py bzr-loom-2.2.0/version.py --- bzr-loom-2.1+bzr139/version.py 2010-06-30 01:56:11.000000000 +0000 +++ bzr-loom-2.2.0/version.py 2012-02-26 16:47:05.000000000 +0000 @@ -23,6 +23,6 @@ 'bzr_maximum_version', ] -bzr_plugin_version = (2, 2, 1, 'dev', 0) -bzr_minimum_version = (2, 2, 0) +bzr_plugin_version = (2, 2, 0, 'final', 0) +bzr_minimum_version = (2, 4, 0) bzr_maximum_version = None