Rev 3574: (robertc) Support relative paths in stacking policies (Michael Hudson) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jul 23 23:07:55 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3574
revision-id:pqm at pqm.ubuntu.com-20080723220742-a8lvchadnsga1wxy
parent: pqm at pqm.ubuntu.com-20080723094000-gxsppck6d857txr1
parent: michael.hudson at canonical.com-20080723211109-o0u76jlxr7yqr79j
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-07-23 23:07:42 +0100
message:
  (robertc) Support relative paths in stacking policies (Michael Hudson)
modified:
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
    ------------------------------------------------------------
    revno: 3567.3.7
    revision-id:michael.hudson at canonical.com-20080723211109-o0u76jlxr7yqr79j
    parent: michael.hudson at canonical.com-20080723205513-o4otck9lsnenivha
    committer: Michael Hudson <michael.hudson at canonical.com>
    branch nick: bzrdir.clone-pass-on-stacking-base-bug-250418
    timestamp: Thu 2008-07-24 09:11:09 +1200
    message:
      better docstring
    modified:
      bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
    ------------------------------------------------------------
    revno: 3567.3.6
    revision-id:michael.hudson at canonical.com-20080723205513-o4otck9lsnenivha
    parent: michael.hudson at canonical.com-20080723203553-bsidcosj9ln1l2a8
    committer: Michael Hudson <michael.hudson at canonical.com>
    branch nick: bzrdir.clone-pass-on-stacking-base-bug-250418
    timestamp: Thu 2008-07-24 08:55:13 +1200
    message:
      oops
    modified:
      bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
    ------------------------------------------------------------
    revno: 3567.3.5
    revision-id:michael.hudson at canonical.com-20080723203553-bsidcosj9ln1l2a8
    parent: michael.hudson at canonical.com-20080722035558-l8kyq1fmcjeamrgq
    committer: Michael Hudson <michael.hudson at canonical.com>
    branch nick: bzrdir.clone-pass-on-stacking-base-bug-250418
    timestamp: Thu 2008-07-24 08:35:53 +1200
    message:
      use TestNotApplicable in all the stacking clone() tests.
    modified:
      bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
    ------------------------------------------------------------
    revno: 3567.3.4
    revision-id:michael.hudson at canonical.com-20080722035558-l8kyq1fmcjeamrgq
    parent: michael.hudson at canonical.com-20080722034339-5g1ncta1ht2grt8i
    committer: Michael Hudson <michael.hudson at canonical.com>
    branch nick: bzrdir.clone-pass-on-stacking-base-bug-250418
    timestamp: Tue 2008-07-22 15:55:58 +1200
    message:
      make test a lot better
    modified:
      bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
    ------------------------------------------------------------
    revno: 3567.3.3
    revision-id:michael.hudson at canonical.com-20080722034339-5g1ncta1ht2grt8i
    parent: michael.hudson at canonical.com-20080722030243-gaec8odgm519lwq0
    committer: Michael Hudson <michael.hudson at canonical.com>
    branch nick: bzrdir.clone-pass-on-stacking-base-bug-250418
    timestamp: Tue 2008-07-22 15:43:39 +1200
    message:
      very hackish test
    modified:
      bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
    ------------------------------------------------------------
    revno: 3567.3.2
    revision-id:michael.hudson at canonical.com-20080722030243-gaec8odgm519lwq0
    parent: michael.hudson at canonical.com-20080721230902-uxnl2s9bjila8xk4
    parent: michael.hudson at canonical.com-20080722025510-uioyrzmam21fgu4y
    committer: Michael Hudson <michael.hudson at canonical.com>
    branch nick: bzrdir.clone-pass-on-stacking-base-bug-250418
    timestamp: Tue 2008-07-22 15:02:43 +1200
    message:
      merge rebase-..-paths
    modified:
      bzrlib/tests/test_urlutils.py  test_urlutils.py-20060502192900-46b1f9579987cf9c
      bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
    ------------------------------------------------------------
    revno: 3567.3.1
    revision-id:michael.hudson at canonical.com-20080721230902-uxnl2s9bjila8xk4
    parent: pqm at pqm.ubuntu.com-20080721151553-11iasd1407hkznk1
    author: Jonathan Lange" <jml at canonical.com>
    committer: Michael Hudson <michael.hudson at canonical.com>
    branch nick: bzrdir.clone-pass-on-stacking-base-bug-250418
    timestamp: Tue 2008-07-22 11:09:02 +1200
    message:
      jml's one line fix
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2008-07-22 09:05:52 +0000
+++ b/bzrlib/bzrdir.py	2008-07-23 22:07:42 +0000
@@ -217,7 +217,7 @@
         if local_repo:
             # may need to copy content in
             repository_policy = result.determine_repository_policy(
-                force_new_repo, stack_on)
+                force_new_repo, stack_on, self.root_transport.base)
             make_working_trees = local_repo.make_working_trees()
             result_repo = repository_policy.acquire_repository(
                 make_working_trees, local_repo.is_shared())

=== modified file 'bzrlib/tests/branch_implementations/test_stacking.py'
--- a/bzrlib/tests/branch_implementations/test_stacking.py	2008-07-16 22:58:50 +0000
+++ b/bzrlib/tests/branch_implementations/test_stacking.py	2008-07-23 21:11:09 +0000
@@ -139,11 +139,22 @@
         self.assertRaises(errors.NotStacked,
             new_branch.get_stacked_on_url)
 
-    def prepare_for_clone(self):
-        tree = self.make_branch_and_tree('stacked-on')
+    def make_stacked_bzrdir(self, in_directory=None):
+        """Create a stacked branch and return its bzrdir.
+
+        :param in_directory: If not None, create a directory of this
+            name and create the stacking and stacked-on bzrdirs in
+            this directory.
+        """
+        if in_directory is not None:
+            self.get_transport().mkdir(in_directory)
+            prefix = in_directory + '/'
+        else:
+            prefix = ''
+        tree = self.make_branch_and_tree(prefix + 'stacked-on')
         tree.commit('Added foo')
         stacked_bzrdir = tree.branch.bzrdir.sprout(
-            'stacked', tree.branch.last_revision(), stacked=True)
+            prefix + 'stacked', tree.branch.last_revision(), stacked=True)
         return stacked_bzrdir
 
     def test_clone_from_stacked_branch_preserve_stacking(self):
@@ -151,11 +162,11 @@
         # preserve_stacking is True, the cloned branch is stacked on the
         # same branch as the original.
         try:
-            stacked_bzrdir = self.prepare_for_clone()
+            stacked_bzrdir = self.make_stacked_bzrdir()
         except (errors.UnstackableBranchFormat,
-                errors.UnstackableRepositoryFormat):
+                errors.UnstackableRepositoryFormat), e:
             # not a testable combination.
-            return
+            raise TestNotApplicable(e)
         cloned_bzrdir = stacked_bzrdir.clone('cloned', preserve_stacking=True)
         try:
             self.assertEqual(
@@ -165,13 +176,29 @@
                 errors.UnstackableRepositoryFormat):
             pass
 
+    def test_clone_from_branch_stacked_on_relative_url_preserve_stacking(self):
+        # If a branch's stacked-on url is relative, we can still clone
+        # from it with preserve_stacking True and get a branch stacked
+        # on an appropriately adjusted relative url.
+        try:
+            stacked_bzrdir = self.make_stacked_bzrdir(in_directory='dir')
+        except (errors.UnstackableBranchFormat,
+                errors.UnstackableRepositoryFormat), e:
+            # not a testable combination.
+            raise TestNotApplicable(e)
+        stacked_bzrdir.open_branch().set_stacked_on_url('../stacked-on')
+        cloned_bzrdir = stacked_bzrdir.clone('cloned', preserve_stacking=True)
+        self.assertEqual(
+            '../dir/stacked-on',
+            cloned_bzrdir.open_branch().get_stacked_on_url())
+
     def test_clone_from_stacked_branch_no_preserve_stacking(self):
         try:
-            stacked_bzrdir = self.prepare_for_clone()
+            stacked_bzrdir = self.make_stacked_bzrdir()
         except (errors.UnstackableBranchFormat,
-                errors.UnstackableRepositoryFormat):
+                errors.UnstackableRepositoryFormat), e:
             # not a testable combination.
-            return
+            raise TestNotApplicable(e)
         cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked',
             preserve_stacking=False)
         unstacked_branch = cloned_unstacked_bzrdir.open_branch()




More information about the bazaar-commits mailing list