Rev 2484: Merge the 0.16 release fixes back into bzr.dev in http://bzr.arbash-meinel.com/branches/bzr/jam-integration

John Arbash Meinel john at arbash-meinel.com
Tue May 8 21:01:28 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/jam-integration

------------------------------------------------------------
revno: 2484
revision-id: john at arbash-meinel.com-20070508200050-4imwmtzep8fx5v7w
parent: pqm at pqm.ubuntu.com-20070507175017-mvwcdqzq0w4z36lr
parent: mbp at sourcefrog.net-20070507131140-iajs5she7cy0pbst
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Tue 2007-05-08 15:00:50 -0500
message:
  Merge the 0.16 release fixes back into bzr.dev
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  README                         README-20050309040720-8f368abf9f346b9d
  bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/blackbox/test_selftest.py test_selftest.py-20060123024542-01c5f1bbcb596d78
  bzrlib/tests/branch_implementations/test_pull.py test_pull.py-20060410103942-83c35b26657414fc
  bzrlib/tests/branch_implementations/test_push.py test_push.py-20070130153159-fhfap8uoifevg30j-1
  bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
  bzrlib/tests/test_transport.py testtransport.py-20050718175618-e5cdb99f4555ddce
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
    ------------------------------------------------------------
    revno: 2477.1.13
    merged: mbp at sourcefrog.net-20070507131140-iajs5she7cy0pbst
    parent: mbp at sourcefrog.net-20070507131058-7yoc6xajos30hjt0
    parent: andrew.bennetts at canonical.com-20070430064224-hagj8m0855p1sxn7
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: 0.16-release
    timestamp: Mon 2007-05-07 23:11:40 +1000
    message:
      merge hpss compatibility fix
    ------------------------------------------------------------
    revno: 2477.1.12
    merged: mbp at sourcefrog.net-20070507131058-7yoc6xajos30hjt0
    parent: mbp at sourcefrog.net-20070507122424-floh4b3kgzg5vgo3
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: 0.16-release
    timestamp: Mon 2007-05-07 23:10:58 +1000
    message:
      Preparing 0.16 release
    ------------------------------------------------------------
    revno: 2477.1.11
    merged: mbp at sourcefrog.net-20070507122424-floh4b3kgzg5vgo3
    parent: mbp at sourcefrog.net-20070507120459-ihx998ls87g6qqon
    parent: pqm at pqm.ubuntu.com-20070430073311-say1rwtz3bk8a3rt
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Mon 2007-05-07 22:24:24 +1000
    message:
      Resolve NEWS against 0.16 branch
        ------------------------------------------------------------
        revno: 2463.1.2
        merged: pqm at pqm.ubuntu.com-20070430073311-say1rwtz3bk8a3rt
        parent: mbp at sourcefrog.net-20070426105838-f54z8279m88bl6ea
        parent: robertc at robertcollins.net-20070430065822-v91uqhvvn071teqo
        committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
        branch nick: 0.16
        timestamp: Mon 2007-04-30 08:33:11 +0100
        message:
          (robertc) bzr 0.16rc: incorporate the relatively trivial fixes from bzr.dev.
            ------------------------------------------------------------
            revno: 2463.1.1.1.1
            merged: robertc at robertcollins.net-20070430065822-v91uqhvvn071teqo
            parent: mbp at sourcefrog.net-20070426105838-f54z8279m88bl6ea
            parent: pqm at pqm.ubuntu.com-20070430054416-kl8x12cim7g45lap
            committer: Robert Collins <robertc at robertcollins.net>
            branch nick: 0.16
            timestamp: Mon 2007-04-30 16:58:22 +1000
            message:
              Merge incremental improvements from bzr.dev to create bzr 0.16rc2
        ------------------------------------------------------------
        revno: 2463.1.1
        merged: mbp at sourcefrog.net-20070426105838-f54z8279m88bl6ea
        parent: pqm at pqm.ubuntu.com-20070426104148-4l5wq2zemlzv0shg
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: 0.16-release
        timestamp: Thu 2007-04-26 20:58:38 +1000
        message:
          Prepare 0.16rc1
    ------------------------------------------------------------
    revno: 2477.1.10
    merged: mbp at sourcefrog.net-20070507120459-ihx998ls87g6qqon
    parent: mbp at sourcefrog.net-20070507120314-a2h78bjezemwyl17
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Mon 2007-05-07 22:04:59 +1000
    message:
      Note about fixing bug 111968
    ------------------------------------------------------------
    revno: 2477.1.9
    merged: mbp at sourcefrog.net-20070507120314-a2h78bjezemwyl17
    parent: mbp at sourcefrog.net-20070504105649-fv0fqgrnq5ojvjdl
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Mon 2007-05-07 22:03:14 +1000
    message:
      Review cleanups from John, mostly docs
    ------------------------------------------------------------
    revno: 2477.1.8
    merged: mbp at sourcefrog.net-20070504105649-fv0fqgrnq5ojvjdl
    parent: mbp at sourcefrog.net-20070504104131-9zq53xhbxtri3jl3
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Fri 2007-05-04 20:56:49 +1000
    message:
      Remove dead parameter
    ------------------------------------------------------------
    revno: 2477.1.7
    merged: mbp at sourcefrog.net-20070504104131-9zq53xhbxtri3jl3
    parent: mbp at sourcefrog.net-20070504101317-n1h3roy8lv7e06ng
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Fri 2007-05-04 20:41:31 +1000
    message:
      test_transport must provide get_test_permutations
    ------------------------------------------------------------
    revno: 2477.1.6
    merged: mbp at sourcefrog.net-20070504101317-n1h3roy8lv7e06ng
    parent: mbp at sourcefrog.net-20070504100117-p3bksdrvjjnoz6qi
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Fri 2007-05-04 20:13:17 +1000
    message:
      doc
    ------------------------------------------------------------
    revno: 2477.1.5
    merged: mbp at sourcefrog.net-20070504100117-p3bksdrvjjnoz6qi
    parent: mbp at sourcefrog.net-20070504095119-sxlhgb1tmxjflj09
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Fri 2007-05-04 20:01:17 +1000
    message:
      More cleanups of Branch.push to get the right behaviour with RemoteBranches
      
      Pass in an _override_hook_source_branch
    ------------------------------------------------------------
    revno: 2477.1.4
    merged: mbp at sourcefrog.net-20070504095119-sxlhgb1tmxjflj09
    parent: mbp at sourcefrog.net-20070504093112-f1z86tjzulf1lz95
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Fri 2007-05-04 19:51:19 +1000
    message:
      fix up indenting in pformat of inequalities displayed by test suite
    ------------------------------------------------------------
    revno: 2477.1.3
    merged: mbp at sourcefrog.net-20070504093112-f1z86tjzulf1lz95
    parent: mbp at sourcefrog.net-20070504084639-8v8mzetmr1y74xer
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Fri 2007-05-04 19:31:12 +1000
    message:
      More refactoring of Branch.push into smaller bits
    ------------------------------------------------------------
    revno: 2477.1.2
    merged: mbp at sourcefrog.net-20070504084639-8v8mzetmr1y74xer
    parent: mbp at sourcefrog.net-20070503080000-joirold1vv0dndgs
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Fri 2007-05-04 18:46:39 +1000
    message:
      Rename push/pull back to 'run_hooks' (jameinel)
      
      Reorganize Branch.push into some template methods: public push,
      _push_with_bound_branches, and _basic_push.  This fixes the case 
      where the destination of push is bound, but the source branch
      format doesn't support binding.
      
      Run push and pull hook tests with a local branch that does support binding,
      rather than skipping if the branch can't be bound to another of the same
      format.
      
      (broken) because the hooks are given the wrong parameters when 
      pushing into something bound to a remote branch.
    ------------------------------------------------------------
    revno: 2477.1.1
    merged: mbp at sourcefrog.net-20070503080000-joirold1vv0dndgs
    parent: pqm at pqm.ubuntu.com-20070503064943-wh3ls1tw3q2awye0
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: run-hooks
    timestamp: Thu 2007-05-03 18:00:00 +1000
    message:
      Add RemoteBranch repr
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2007-05-01 22:41:41 +0000
+++ b/NEWS	2007-05-08 20:00:50 +0000
@@ -1,4 +1,15 @@
 IN DEVELOPMENT
+
+  BUGFIXES:
+
+    * ``bzr push`` should only connect to the remote location one time.
+      We have been connecting 3 times because we forget to pass around
+      the Transport object. This adds ``BzrDir.clone_on_transport()``, so
+      that we can pass in the Transport that we already have.
+      (John Arbash Meinel, #75721)
+
+
+bzr 0.16  2007-05-07
   
   BUGFIXES:
 
@@ -12,11 +23,8 @@
       Previously we would report the first file as missing, but not show
       the new unknown file. (John Arbash Meinel, #111288)
 
-    * ``bzr push`` should only connect to the remote location one time.
-      We have been connecting 3 times because we forget to pass around
-      the Transport object. This adds ``BzrDir.clone_on_transport()``, so
-      that we can pass in the Transport that we already have.
-      (John Arbash Meinel, #75721)
+    * Avoid error when running hooks after pulling into or pushing from
+      a branch bound to a smartserver branch.  (Martin Pool, #111968)
 
 bzr 0.16rc2  2007-04-30
 

=== modified file 'README'
--- a/README	2007-03-21 04:28:02 +0000
+++ b/README	2007-04-30 06:58:22 +0000
@@ -1,6 +1,6 @@
-=====================================
-README for Bazaar DEVELOPMENT VERSION
-=====================================
+=========================
+README for Bazaar 0.16rc2
+=========================
 
 Bazaar is a decentralized revision control system, designed to be easy
 for developers and end users alike.

=== modified file 'bzrlib/__init__.py'
--- a/bzrlib/__init__.py	2007-04-01 06:19:16 +0000
+++ b/bzrlib/__init__.py	2007-05-07 13:10:58 +0000
@@ -35,7 +35,7 @@
 # Python version 2.0 is (2, 0, 0, 'final', 0)."  Additionally we use a
 # releaselevel of 'dev' for unreleased under-development code.
 
-version_info = (0, 16, 0, 'dev', 0)
+version_info = (0, 16, 0, 'final', 0)
 
 if version_info[3] == 'final':
     version_string = '%d.%d.%d' % version_info[:3]

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2007-05-02 14:54:20 +0000
+++ b/bzrlib/branch.py	2007-05-08 20:00:50 +0000
@@ -997,7 +997,7 @@
         # (push_result)
         # containing the members
         # (source, local, master, old_revno, old_revid, new_revno, new_revid)
-        # where local is the local branch or None, master is the target 
+        # where local is the local target branch or None, master is the target 
         # master branch, and the rest should be self explanatory. The source
         # is read locked and the target branches write locked. Source will
         # be the local low-latency branch.
@@ -1473,13 +1473,14 @@
 
     @needs_write_lock
     def pull(self, source, overwrite=False, stop_revision=None,
-        _hook_master=None, _run_hooks=True):
+             _hook_master=None, run_hooks=True):
         """See Branch.pull.
 
         :param _hook_master: Private parameter - set the branch to 
             be supplied as the master to push hooks.
-        :param _run_hooks: Private parameter - allow disabling of
-            hooks, used when pushing to a master branch.
+        :param run_hooks: Private parameter - if false, this branch
+            is being called because it's the master of the primary branch,
+            so it should not run its hooks.
         """
         result = PullResult()
         result.source_branch = source
@@ -1504,7 +1505,7 @@
             else:
                 result.master_branch = self
                 result.local_branch = None
-            if _run_hooks:
+            if run_hooks:
                 for hook in Branch.hooks['post_pull']:
                     hook(result)
         finally:
@@ -1522,40 +1523,91 @@
 
     @needs_read_lock
     def push(self, target, overwrite=False, stop_revision=None,
-        _hook_master=None, _run_hooks=True):
+             _override_hook_source_branch=None):
         """See Branch.push.
+
+        This is the basic concrete implementation of push()
+
+        :param _override_hook_source_branch: If specified, run
+        the hooks passing this Branch as the source, rather than self.  
+        This is for use of RemoteBranch, where push is delegated to the
+        underlying vfs-based Branch. 
+        """
+        # TODO: Public option to disable running hooks - should be trivial but
+        # needs tests.
+        target.lock_write()
+        try:
+            result = self._push_with_bound_branches(target, overwrite,
+                    stop_revision,
+                    _override_hook_source_branch=_override_hook_source_branch)
+            return result
+        finally:
+            target.unlock()
+
+    def _push_with_bound_branches(self, target, overwrite,
+            stop_revision,
+            _override_hook_source_branch=None):
+        """Push from self into target, and into target's master if any.
         
-        :param _hook_master: Private parameter - set the branch to 
-            be supplied as the master to push hooks.
-        :param _run_hooks: Private parameter - allow disabling of
-            hooks, used when pushing to a master branch.
+        This is on the base BzrBranch class even though it doesn't support 
+        bound branches because the *target* might be bound.
+        """
+        def _run_hooks():
+            if _override_hook_source_branch:
+                result.source_branch = _override_hook_source_branch
+            for hook in Branch.hooks['post_push']:
+                hook(result)
+
+        bound_location = target.get_bound_location()
+        if bound_location and target.base != bound_location:
+            # there is a master branch.
+            #
+            # XXX: Why the second check?  Is it even supported for a branch to
+            # be bound to itself? -- mbp 20070507
+            master_branch = target.get_master_branch()
+            master_branch.lock_write()
+            try:
+                # push into the master from this branch.
+                self._basic_push(master_branch, overwrite, stop_revision)
+                # and push into the target branch from this. Note that we push from
+                # this branch again, because its considered the highest bandwidth
+                # repository.
+                result = self._basic_push(target, overwrite, stop_revision)
+                result.master_branch = master_branch
+                result.local_branch = target
+                _run_hooks()
+                return result
+            finally:
+                master_branch.unlock()
+        else:
+            # no master branch
+            result = self._basic_push(target, overwrite, stop_revision)
+            # TODO: Why set master_branch and local_branch if there's no
+            # binding?  Maybe cleaner to just leave them unset? -- mbp
+            # 20070504
+            result.master_branch = target
+            result.local_branch = None
+            _run_hooks()
+            return result
+
+    def _basic_push(self, target, overwrite, stop_revision):
+        """Basic implementation of push without bound branches or hooks.
+
+        Must be called with self read locked and target write locked.
         """
         result = PushResult()
         result.source_branch = self
         result.target_branch = target
-        target.lock_write()
+        result.old_revno, result.old_revid = target.last_revision_info()
         try:
-            result.old_revno, result.old_revid = target.last_revision_info()
-            try:
-                target.update_revisions(self, stop_revision)
-            except DivergedBranches:
-                if not overwrite:
-                    raise
-            if overwrite:
-                target.set_revision_history(self.revision_history())
-            result.tag_conflicts = self.tags.merge_to(target.tags)
-            result.new_revno, result.new_revid = target.last_revision_info()
-            if _hook_master:
-                result.master_branch = _hook_master
-                result.local_branch = target
-            else:
-                result.master_branch = target
-                result.local_branch = None
-            if _run_hooks:
-                for hook in Branch.hooks['post_push']:
-                    hook(result)
-        finally:
-            target.unlock()
+            target.update_revisions(self, stop_revision)
+        except DivergedBranches:
+            if not overwrite:
+                raise
+        if overwrite:
+            target.set_revision_history(self.revision_history())
+        result.tag_conflicts = self.tags.merge_to(target.tags)
+        result.new_revno, result.new_revid = target.last_revision_info()
         return result
 
     def get_parent(self):
@@ -1631,11 +1683,12 @@
         
     @needs_write_lock
     def pull(self, source, overwrite=False, stop_revision=None,
-        _run_hooks=True):
-        """Extends branch.pull to be bound branch aware.
+             run_hooks=True):
+        """Pull from source into self, updating my master if any.
         
-        :param _run_hooks: Private parameter used to force hook running
-            off during bound branch double-pushing.
+        :param run_hooks: Private parameter - if false, this branch
+            is being called because it's the master of the primary branch,
+            so it should not run its hooks.
         """
         bound_location = self.get_bound_location()
         master_branch = None
@@ -1647,33 +1700,10 @@
             if master_branch:
                 # pull from source into master.
                 master_branch.pull(source, overwrite, stop_revision,
-                    _run_hooks=False)
+                    run_hooks=False)
             return super(BzrBranch5, self).pull(source, overwrite,
                 stop_revision, _hook_master=master_branch,
-                _run_hooks=_run_hooks)
-        finally:
-            if master_branch:
-                master_branch.unlock()
-
-    @needs_read_lock
-    def push(self, target, overwrite=False, stop_revision=None):
-        """Updates branch.push to be bound branch aware."""
-        bound_location = target.get_bound_location()
-        master_branch = None
-        if bound_location and target.base != bound_location:
-            # not pushing to master, so we need to update master.
-            master_branch = target.get_master_branch()
-            master_branch.lock_write()
-        try:
-            if master_branch:
-                # push into the master from this branch.
-                super(BzrBranch5, self).push(master_branch, overwrite,
-                    stop_revision, _run_hooks=False)
-            # and push into the target branch from this. Note that we push from
-            # this branch again, because its considered the highest bandwidth
-            # repository.
-            return super(BzrBranch5, self).push(target, overwrite,
-                stop_revision, _hook_master=master_branch)
+                run_hooks=run_hooks)
         finally:
             if master_branch:
                 master_branch.unlock()

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2007-04-26 09:07:38 +0000
+++ b/bzrlib/remote.py	2007-05-07 12:03:14 +0000
@@ -20,7 +20,7 @@
 from cStringIO import StringIO
 
 from bzrlib import branch, errors, lockdir, repository
-from bzrlib.branch import BranchReferenceFormat
+from bzrlib.branch import Branch, BranchReferenceFormat
 from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
 from bzrlib.config import BranchConfig, TreeConfig
 from bzrlib.decorators import needs_read_lock, needs_write_lock
@@ -764,6 +764,11 @@
         self._lock_count = 0
         self._leave_lock = False
 
+    def __str__(self):
+        return "%s(%s)" % (self.__class__.__name__, self.base)
+
+    __repr__ = __str__
+
     def _ensure_real(self):
         """Ensure that there is a _real_branch set.
 
@@ -991,16 +996,24 @@
         return self._real_branch.append_revision(*revision_ids)
 
     @needs_write_lock
-    def pull(self, source, overwrite=False, stop_revision=None):
+    def pull(self, source, overwrite=False, stop_revision=None,
+             **kwargs):
+        # FIXME: This asks the real branch to run the hooks, which means
+        # they're called with the wrong target branch parameter. 
+        # The test suite specifically allows this at present but it should be
+        # fixed.  It should get a _override_hook_target branch,
+        # as push does.  -- mbp 20070405
         self._ensure_real()
         self._real_branch.pull(
-            source, overwrite=overwrite, stop_revision=stop_revision)
+            source, overwrite=overwrite, stop_revision=stop_revision,
+            **kwargs)
 
     @needs_read_lock
     def push(self, target, overwrite=False, stop_revision=None):
         self._ensure_real()
         return self._real_branch.push(
-            target, overwrite=overwrite, stop_revision=stop_revision)
+            target, overwrite=overwrite, stop_revision=stop_revision,
+            _override_hook_source_branch=self)
 
     def is_locked(self):
         return self._lock_count >= 1

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2007-05-03 19:22:18 +0000
+++ b/bzrlib/tests/__init__.py	2007-05-08 20:00:50 +0000
@@ -823,7 +823,7 @@
             message += '\n'
         raise AssertionError("%snot equal:\na = %s\nb = %s\n"
             % (message,
-               pformat(a, indent=4), pformat(b, indent=4)))
+               pformat(a), pformat(b)))
 
     assertEquals = assertEqual
 

=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py	2007-04-25 06:50:22 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py	2007-05-04 10:13:17 +0000
@@ -559,6 +559,10 @@
         out_all,err_all = self.run_bzr_captured(['selftest', '--list-only',
             'selftest'])
         tests_all = self._parse_test_list(out_all.splitlines())[1]
+        # XXX: It looks like there are some orders for generating tests that
+        # fail as of 20070504 - maybe because of import order dependencies.
+        # So unfortunately this will rarely intermittently fail at the moment.
+        # -- mbp 20070504
         out_rand,err_rand = self.run_bzr_captured(['selftest', '--list-only',
             'selftest', '--randomize', 'now'])
         (header_rand,tests_rand,dummy) = self._parse_test_list(

=== modified file 'bzrlib/tests/branch_implementations/test_pull.py'
--- a/bzrlib/tests/branch_implementations/test_pull.py	2007-03-01 07:15:55 +0000
+++ b/bzrlib/tests/branch_implementations/test_pull.py	2007-05-04 08:46:39 +0000
@@ -18,10 +18,12 @@
 
 import os
 
-from bzrlib.branch import Branch
+from bzrlib.branch import Branch, BzrBranchFormat5
+from bzrlib.bzrdir import BzrDir
 from bzrlib import errors
 from bzrlib.memorytree import MemoryTree
 from bzrlib.revision import NULL_REVISION
+from bzrlib.tests import TestSkipped
 from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch
 
 
@@ -142,8 +144,13 @@
         try:
             local.bind(target)
         except errors.UpgradeRequired:
-            # cant bind this format, the test is irrelevant.
-            return
+            # We can't bind this format to itself- typically it is the local
+            # branch that doesn't support binding.  As of May 2007
+            # remotebranches can't be bound.  Let's instead make a new local
+            # branch of the default type, which does allow binding.
+            # See https://bugs.launchpad.net/bzr/+bug/112020
+            local = BzrDir.create_branch_convenience('local2')
+            local.bind(target)
         source = self.make_branch('source')
         Branch.hooks.install_hook('post_pull', self.capture_post_pull_hook)
         local.pull(source)

=== modified file 'bzrlib/tests/branch_implementations/test_push.py'
--- a/bzrlib/tests/branch_implementations/test_push.py	2007-03-29 07:39:49 +0000
+++ b/bzrlib/tests/branch_implementations/test_push.py	2007-05-07 12:03:14 +0000
@@ -17,12 +17,14 @@
 """Tests for branch.push behaviour."""
 
 import os
-
+ 
 from bzrlib import bzrdir, errors
 from bzrlib.branch import Branch
+from bzrlib.bzrdir import BzrDir
 from bzrlib.memorytree import MemoryTree
 from bzrlib.remote import RemoteBranch
 from bzrlib.revision import NULL_REVISION
+from bzrlib.tests import TestSkipped
 from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch
 from bzrlib.transport.local import LocalURLServer
 
@@ -185,12 +187,6 @@
         source.push(target)
         # with nothing there we should still get a notification, and
         # have both branches locked at the notification time.
-        if isinstance(source, RemoteBranch):
-            # XXX: at the moment, push on remote branches is just delegated to
-            # the file-level branch object, so we adjust the expected result
-            # accordingly.  In the future, when RemoteBranch implements push
-            # directly, this should be unnecessary.
-            source = source._real_branch
         self.assertEqual([
             ('post_push', source, None, target.base, 0, NULL_REVISION,
              0, NULL_REVISION, True, None, True)
@@ -207,8 +203,13 @@
         try:
             local.bind(target)
         except errors.UpgradeRequired:
-            # cant bind this format, the test is irrelevant.
-            return
+            # We can't bind this format to itself- typically it is the local
+            # branch that doesn't support binding.  As of May 2007
+            # remotebranches can't be bound.  Let's instead make a new local
+            # branch of the default type, which does allow binding.
+            # See https://bugs.launchpad.net/bzr/+bug/112020
+            local = BzrDir.create_branch_convenience('local2')
+            local.bind(target)
         source = self.make_branch('source')
         Branch.hooks.install_hook('post_push', self.capture_post_push_hook)
         source.push(local)

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2007-04-30 06:42:24 +0000
+++ b/bzrlib/tests/test_remote.py	2007-05-07 13:11:40 +0000
@@ -98,6 +98,10 @@
         d = fmt.open(self.transport)
         self.assertIsInstance(d, BzrDir)
 
+    def test_remote_branch_repr(self):
+        b = BzrDir.open_from_transport(self.transport).open_branch()
+        self.assertStartsWith(str(b), 'RemoteBranch(')
+
 
 class FakeProtocol(object):
     """Lookalike SmartClientRequestProtocolOne allowing body reading tests."""

=== modified file 'bzrlib/tests/test_transport.py'
--- a/bzrlib/tests/test_transport.py	2007-04-26 09:07:38 +0000
+++ b/bzrlib/tests/test_transport.py	2007-05-04 10:41:31 +0000
@@ -592,3 +592,13 @@
         # make sure we reach the root
         t = t.clone('..')
         self.assertEquals(t.base, 'file://HOST/')
+
+
+def get_test_permutations():
+    """Return transport permutations to be used in testing.
+
+    This module registers some transports, but they're only for testing
+    registration.  We don't really want to run all the transport tests against
+    them.
+    """
+    return []

=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2007-05-02 14:36:55 +0000
+++ b/bzrlib/transport/__init__.py	2007-05-08 20:00:50 +0000
@@ -1201,8 +1201,10 @@
     def get_transport_test_permutations(self, module):
         """Get the permutations module wants to have tested."""
         if getattr(module, 'get_test_permutations', None) is None:
-            warning("transport module %s doesn't provide get_test_permutations()"
+            raise AssertionError("transport module %s doesn't provide get_test_permutations()"
                     % module.__name__)
+            ##warning("transport module %s doesn't provide get_test_permutations()"
+            ##       % module.__name__)
             return []
         return module.get_test_permutations()
 



More information about the bazaar-commits mailing list