Rev 5654: Be more tolerant about ``bound_location`` from config files in file:///home/vila/src/bzr/bugs/786980-url-aliases/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Jul 8 15:53:43 UTC 2011


At file:///home/vila/src/bzr/bugs/786980-url-aliases/

------------------------------------------------------------
revno: 5654
revision-id: v.ladeuil+lp at free.fr-20110708155343-mqvck9jn15e4g9tu
parent: pqm at pqm.ubuntu.com-20110616190826-cle8ddundgi92954
fixes bug(s): https://launchpad.net/bugs/786980
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 786980-url-aliases
timestamp: Fri 2011-07-08 17:53:43 +0200
message:
  Be more tolerant about ``bound_location`` from config files
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2011-03-18 06:36:57 +0000
+++ b/bzrlib/branch.py	2011-07-08 15:53:43 +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:
+            # bond_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-08 15:53:43 +0000
@@ -3216,3 +3216,22 @@
         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')
+        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()

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2011-06-15 14:03:58 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2011-07-08 15:53:43 +0000
@@ -33,6 +33,9 @@
 .. Fixes for situations where bzr would previously crash or give incorrect
    or undesirable results.
 
+* Accept some differences for ``bound_location`` fron the config files.
+  (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