Rev 5655: (vila) Relax the URL comparison a bit when checking the master branch URL. in file:///home/pqm/archives/thelove/bzr/2.3/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jul 14 13:11:12 UTC 2011


At file:///home/pqm/archives/thelove/bzr/2.3/

------------------------------------------------------------
revno: 5655 [merge]
revision-id: pqm at pqm.ubuntu.com-20110714131108-0oitiz2v9yzpp5sm
parent: pqm at pqm.ubuntu.com-20110705151251-60kw6nvqe5mkqmli
parent: v.ladeuil+lp at free.fr-20110714120730-m7oq4xgricxpxjkx
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.3
timestamp: Thu 2011-07-14 13:11:08 +0000
message:
  (vila) Relax the URL comparison a bit when checking the master branch URL.
   (Vincent Ladeuil)
modified:
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
  doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2011-03-18 06:36:57 +0000
+++ b/bzrlib/branch.py	2011-07-12 16:48:25 +0000
@@ -3466,7 +3466,16 @@
         if local and not bound_location:
             raise errors.LocalRequiresBoundBranch()
         master_branch = None
-        source_is_master = (self.source.user_url == bound_location)
+        source_is_master = False
+        if bound_location:
+            # bound_location comes from a config file, some care has to be
+            # taken to relate it to source.user_url
+            normalized = urlutils.normalize_url(bound_location)
+            try:
+                relpath = self.source.user_transport.relpath(normalized)
+                source_is_master = (relpath == '')
+            except (errors.PathNotChild, errors.InvalidURL):
+                source_is_master = False
         if not local and bound_location and not source_is_master:
             # not pulling from master, so we need to update master.
             master_branch = self.target.get_master_branch(possible_transports)

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2011-03-01 07:15:38 +0000
+++ b/bzrlib/tests/test_remote.py	2011-07-14 12:07:30 +0000
@@ -3216,3 +3216,23 @@
         self.hpss_calls = []
         remote_branch.copy_content_into(local)
         self.assertFalse('Branch.revision_history' in self.hpss_calls)
+
+
+class TestUpdateBoundBranch(tests.TestCaseWithTransport):
+
+    def test_bug_786980(self):
+        self.transport_server = test_server.SmartTCPServer_for_testing
+        wt = self.make_branch_and_tree('master')
+        checkout = wt.branch.create_checkout('checkout')
+        wt.commit('add stuff')
+        last_revid = wt.commit('even more stuff')
+        bound_location = checkout.branch.get_bound_location()
+        # For unclear reasons some users have a bound_location without a final
+        # '/', simulate that by forcing such a value
+        self.assertEndsWith(bound_location, '/')
+        new_location = bound_location.rstrip('/')
+        checkout.branch.set_bound_location(new_location)
+        # bug 786980 was raising ReadOnlyError: A write attempt was made in a
+        # read only transaction during the update()
+        checkout.update()
+        self.assertEquals(last_revid, checkout.last_revision())

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2011-07-05 11:54:54 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2011-07-14 13:11:08 +0000
@@ -33,6 +33,10 @@
 .. Fixes for situations where bzr would previously crash or give incorrect
    or undesirable results.
 
+* Accept some differences for ``bound_location`` from the config files that
+  were leading to a 'ReadOnlyError: A write attempt was made in a read only
+  transaction' error.  (Vincent Ladeuil, #786980)
+
 * Don't fail with traceback if `bzr serve` is running as a service on Windows,
   and there is no USERNAME, nor BZR_EMAIL or other whoami-related environment
   variables set. (Alexander Belchenko, Bug #660174)




More information about the bazaar-commits mailing list