[merge][#261315][1.7] RemoteBranch sets up stacking (more) correctly

John Arbash Meinel john at arbash-meinel.com
Wed Sep 17 03:08:53 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Pool wrote:
> Here's an updated patch that
> 
>  * adds some helpers to test_remote so the tests are easier to read
> and the failures are easier to understand
>  * tests the case of a server that doesn't support this rpc
>  * updates remote tests to expect Branch.get_stacked_on_url to happen
> when the branch is opened
> 
> I thought I sent this last night; I'm not sure why.
> 
> 

- -        self._ensure_real()
- -        return self._real_branch.get_stacked_on_url()
+        try:
+            response = self._client.call('Branch.get_stacked_on_url',
+                self._remote_path())
+            if response[0] != 'ok':
+                raise errors.UnexpectedSmartServerResponse(response)
+            return response[1]
+        except errors.ErrorFromSmartServer, err:
+            # there may not be a repository yet, so we can't call through
+            # its _translate_error
+            _translate_error(err, branch=self)
+        except errors.UnknownSmartMethod, err:
+            self._ensure_real()
+            return self._real_branch.get_stacked_on_url()

^- The "if response[0] != 'ok'" feels like it should be outside the
except clauses.



+    def test_get_stacked_on_real_branch(self):
+        base_branch = self.make_branch('base', format='1.6')
+        stacked_branch = self.make_branch('stacked', format='1.6')
+        stacked_branch.set_stacked_on_url('../base')
+        client = FakeClient(self.get_url())
+        client.add_expected_call(
+            'BzrDir.open_branch', ('stacked/',),
+            'success', ('ok', ''))
+        client.add_expected_call(
+            'BzrDir.find_repositoryV2', ('stacked/',),
+            'success', ('ok', '', 'no', 'no', 'no'))
+        # called twice, once from constructor and then again by us
+        client.add_expected_call(
+            'Branch.get_stacked_on_url', ('stacked/',),
+            'success', ('ok', '../base'))
+        client.add_expected_call(
+            'Branch.get_stacked_on_url', ('stacked/',),
+            'success', ('ok', '../base'))

^- This is a bit of a surprise. I suppose this won't really happen in
code that uses Branch? (As it should generally be unaware whether
something is stacked or not.)


Otherwise looks good to me, even for 1.7. At least, if you fix up the
merge conflicts.

BB:tweak


John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjQZrUACgkQJdeBCYSNAAPiIACgvVkZ8wq3iJnVd0MjKl24+tDC
QCYAnj/vfeVfRYcHalh8X8ROGY4xhEcT
=I/QL
-----END PGP SIGNATURE-----



More information about the bazaar mailing list