Rev 4289: (andrew) Push parent inventories for all transferred revisions to in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Apr 14 04:15:48 BST 2009


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

------------------------------------------------------------
revno: 4289
revision-id: pqm at pqm.ubuntu.com-20090414031543-gqbs23oebd68p7h7
parent: pqm at pqm.ubuntu.com-20090413175307-kzfbzfxgscia4sto
parent: andrew.bennetts at canonical.com-20090414022613-g4t18jvbsvyrmohf
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-04-14 04:15:43 +0100
message:
  (andrew) Push parent inventories for all transferred revisions to
  	stacked branches.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branchbuilder.py        branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
  bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
  bzrlib/tests/interrepository_implementations/__init__.py __init__.py-20060220054744-baf49a1f88f17b1a
  bzrlib/tests/interrepository_implementations/test_fetch.py test_fetch.py-20080425213627-j60cjh782ufm83ry-1
    ------------------------------------------------------------
    revno: 4257.3.10
    revision-id: andrew.bennetts at canonical.com-20090414022613-g4t18jvbsvyrmohf
    parent: andrew.bennetts at canonical.com-20090409075507-uz3dw3tpmvew5v25
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Tue 2009-04-14 12:26:13 +1000
    message:
      Expand comment a little.
    modified:
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
    ------------------------------------------------------------
    revno: 4257.3.9
    revision-id: andrew.bennetts at canonical.com-20090409075507-uz3dw3tpmvew5v25
    parent: andrew.bennetts at canonical.com-20090409025917-efcnmph4db2emeki
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Thu 2009-04-09 17:55:07 +1000
    message:
      Add fix to InterDifferingSerializer too, although it's pretty ugly.
    modified:
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/tests/interrepository_implementations/test_fetch.py test_fetch.py-20080425213627-j60cjh782ufm83ry-1
    ------------------------------------------------------------
    revno: 4257.3.8
    revision-id: andrew.bennetts at canonical.com-20090409025917-efcnmph4db2emeki
    parent: andrew.bennetts at canonical.com-20090409004452-zfor5z6tedn63prx
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Thu 2009-04-09 12:59:17 +1000
    message:
      Fix TestCase.make_branch_builder to make a branch in the specified format.  Also add an interrepo test scenario for KnitPack1 -> KnitPack6RichRoot, which fails.
    modified:
      bzrlib/branchbuilder.py        branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/interrepository_implementations/__init__.py __init__.py-20060220054744-baf49a1f88f17b1a
    ------------------------------------------------------------
    revno: 4257.3.7
    revision-id: andrew.bennetts at canonical.com-20090409004452-zfor5z6tedn63prx
    parent: andrew.bennetts at canonical.com-20090408053448-awacfn10peec2vkm
    parent: pqm at pqm.ubuntu.com-20090408225022-exxekai8bxhxrayk
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Thu 2009-04-09 10:44:52 +1000
    message:
      Merge bzr.dev.
    added:
      bzrlib/_chk_map_py.py          _chk_map_py.py-20090309114220-1kurz7oez2gwqtcf-1
      bzrlib/_chk_map_pyx.pyx        _chk_map_pyx.pyx-20090309111231-peyz7p2azr0dzdrb-1
      bzrlib/_groupcompress_py.py    _groupcompress_py.py-20090324110021-j63s399f4icrgw4p-1
      bzrlib/_groupcompress_pyx.pyx  _groupcompress_c.pyx-20080724041824-yelg6ii7c7zxt4z0-1
      bzrlib/chk_map.py              chk_map.py-20081001014447-ue6kkuhofvdecvxa-1
      bzrlib/chk_serializer.py       chk_serializer.py-20081002064345-2tofdfj2eqq01h4b-1
      bzrlib/delta.h                 delta.h-20090227173129-qsu3u43vowf1q3ay-1
      bzrlib/diff-delta.c            diffdelta.c-20090226042143-l9wzxynyuxnb5hus-1
      bzrlib/groupcompress.py        groupcompress.py-20080705181503-ccbxd6xuy1bdnrpu-8
      bzrlib/repofmt/groupcompress_repo.py repofmt.py-20080715094215-wp1qfvoo7093c8qr-1
      bzrlib/tests/per_repository_chk/ per_repository_chk-20080925061730-e4g24t5xstp2n2vp-1
      bzrlib/tests/per_repository_chk/__init__.py __init__.py-20080925061730-e4g24t5xstp2n2vp-2
      bzrlib/tests/per_repository_chk/test_supported.py test_supported.py-20080925063728-k65ry0n2rhta6t34-1
      bzrlib/tests/per_repository_chk/test_unsupported.py test_unsupported.py-20080925063728-k65ry0n2rhta6t34-2
      bzrlib/tests/test__chk_map.py  test__chk_map.py-20090309114220-1kurz7oez2gwqtcf-2
      bzrlib/tests/test__groupcompress.py test__groupcompress_-20080724145854-koifwb7749cfzrvj-1
      bzrlib/tests/test_chk_map.py   test_chk_map.py-20081001014447-ue6kkuhofvdecvxa-2
      bzrlib/tests/test_groupcompress.py test_groupcompress.p-20080705181503-ccbxd6xuy1bdnrpu-13
    modified:
      .bzrignore                     bzrignore-20050311232317-81f7b71efa2db11a
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzr                            bzr.py-20050313053754-5485f144c7006fa6
      bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
      bzrlib/_btree_serializer_c.pyx _parse_btree_c.pyx-20080703034413-3q25bklkenti3p8p-2
      bzrlib/annotate.py             annotate.py-20050922133147-7c60541d2614f022
      bzrlib/btree_index.py          index.py-20080624222253-p0x5f92uyh5hw734-7
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/dirstate.py             dirstate.py-20060728012006-d6mvoihjb3je9peu-1
      bzrlib/filters/__init__.py     __init__.py-20080416080515-mkxl29amuwrf6uir-2
      bzrlib/filters/eol.py          eol.py-20090327060429-todzdjmqt3bpv5r8-1
      bzrlib/hooks.py                hooks.py-20070325015548-ix4np2q0kd8452au-1
      bzrlib/inventory.py            inventory.py-20050309040759-6648b84ca2005b37
      bzrlib/option.py               option.py-20051014052914-661fb36e76e7362f
      bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
      bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/revisiontree.py         revisiontree.py-20060724012533-bg8xyryhxd0o0i0h-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
      bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
      bzrlib/tests/blackbox/test_export.py test_export.py-20051229024010-e6c26658e460fb1c
      bzrlib/tests/blackbox/test_filesystem_cicp.py test_filesystem_cicp-20081028010456-vclkg401m81keaxc-1
      bzrlib/tests/blackbox/test_filtered_view_ops.py test_filtered_view_o-20081110012645-5t7ogtola0l33lkg-1
      bzrlib/tests/blackbox/test_ls.py test_ls.py-20060712232047-0jraqpecwngee12y-1
      bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
      bzrlib/tests/blackbox/test_selftest.py test_selftest.py-20060123024542-01c5f1bbcb596d78
      bzrlib/tests/blackbox/test_view.py test_view.py-20080731135100-66o8o32heop7augi-1
      bzrlib/tests/intertree_implementations/__init__.py __init__.py-20060724101752-09ysswo1a92uqyoz-3
      bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
      bzrlib/tests/inventory_implementations/basics.py basics.py-20070903044446-kdjwbiu1p1zi9phs-1
      bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
      bzrlib/tests/test_branch.py    test_branch.py-20060116013032-97819aa07b8ab3b5
      bzrlib/tests/test_commands.py  test_command.py-20051019190109-3b17be0f52eaa7a8
      bzrlib/tests/test_export.py    test_export.py-20090220201010-tpbxssdnezsvu9pk-1
      bzrlib/tests/test_filters.py   test_filters.py-20080417120614-tc3zok0vvvprsc99-1
      bzrlib/tests/test_hooks.py     test_hooks.py-20070628030849-89rtsbe5dmer5npz-1
      bzrlib/tests/test_inv.py       testinv.py-20050722220913-1dc326138d1a5892
      bzrlib/tests/test_options.py   testoptions.py-20051014093702-96457cfc86319a8f
      bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
      bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
      bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
      bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
      bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
      bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
      bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
      bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
      doc/developers/development-repo.txt developmentrepo.txt-20080102200205-raj42k61dch8pjmj-1
      setup.py                       setup.py-20050314065409-02f8a0a6e3f9bc70
    ------------------------------------------------------------
    revno: 4257.3.6
    revision-id: andrew.bennetts at canonical.com-20090408053448-awacfn10peec2vkm
    parent: andrew.bennetts at canonical.com-20090408051015-j2jthymagdbek3a7
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Wed 2009-04-08 15:34:48 +1000
    message:
      The NULL_REVISION of an inventory is never missing.
    modified:
      bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
    ------------------------------------------------------------
    revno: 4257.3.5
    revision-id: andrew.bennetts at canonical.com-20090408051015-j2jthymagdbek3a7
    parent: andrew.bennetts at canonical.com-20090408022846-honfnb61ucbcvrio
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Wed 2009-04-08 15:10:15 +1000
    message:
      Loosen the stacked push ratchet one notch to accomodate the parent inventories fix.
    modified:
      bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
    ------------------------------------------------------------
    revno: 4257.3.4
    revision-id: andrew.bennetts at canonical.com-20090408022846-honfnb61ucbcvrio
    parent: andrew.bennetts at canonical.com-20090407071448-unyb0v5oc6ifbo14
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Wed 2009-04-08 12:28:46 +1000
    message:
      Add NEWS entry.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 4257.3.3
    revision-id: andrew.bennetts at canonical.com-20090407071448-unyb0v5oc6ifbo14
    parent: andrew.bennetts at canonical.com-20090407061007-neeheqyrkhc9d4yp
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Tue 2009-04-07 17:14:48 +1000
    message:
      missing_keys from sink.insert_stream should be a set, not a tuple.
    modified:
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
    ------------------------------------------------------------
    revno: 4257.3.2
    revision-id: andrew.bennetts at canonical.com-20090407061007-neeheqyrkhc9d4yp
    parent: andrew.bennetts at canonical.com-20090407054148-slyxftgur0jwtsep
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Tue 2009-04-07 16:10:07 +1000
    message:
      Check during fetch if we are going to be missing data necessary to calculate altered fileids for stacked revisions.
    modified:
      bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
      bzrlib/tests/interrepository_implementations/test_fetch.py test_fetch.py-20080425213627-j60cjh782ufm83ry-1
    ------------------------------------------------------------
    revno: 4257.3.1
    revision-id: andrew.bennetts at canonical.com-20090407054148-slyxftgur0jwtsep
    parent: pqm at pqm.ubuntu.com-20090406052052-fyud2y3vlghiasig
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: stacking-inventory
    timestamp: Tue 2009-04-07 15:41:48 +1000
    message:
      Add failing test.
    modified:
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/tests/interrepository_implementations/test_fetch.py test_fetch.py-20080425213627-j60cjh782ufm83ry-1
=== modified file 'NEWS'
--- a/NEWS	2009-04-11 13:01:19 +0000
+++ b/NEWS	2009-04-14 03:15:43 +0000
@@ -242,6 +242,14 @@
   both branches, we know that the trunk for the project can be read too,
   so the upgrade will not inconvenience users. (Robert Collins, #345169)
 
+* Pushing a new stacked branch will also push the parent inventories for
+  revisions at the stacking boundary.  This makes sure that the stacked
+  branch has enough data to calculate inventory deltas for all of its
+  revisions (without requiring the fallback branch).  This avoids
+  "'AbsentContentFactory' object has no attribute 'get_bytes_as'" errors
+  when fetching the stacked branch from a 1.13 (or later) smart server.
+  This partially fixes #354036.  (Andrew Bennetts, Robert Collins)
+
 * The full test suite is passing again on OSX. Several minor issues (mostly
   test related) have been fixed. (Vincent Ladeuil, #355273).
 

=== modified file 'bzrlib/branchbuilder.py'
--- a/bzrlib/branchbuilder.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/branchbuilder.py	2009-04-09 02:59:17 +0000
@@ -56,7 +56,7 @@
         a series in progress, it should be None.
     """
 
-    def __init__(self, transport, format=None):
+    def __init__(self, transport=None, format=None, branch=None):
         """Construct a BranchBuilder on transport.
 
         :param transport: The transport the branch should be created on.
@@ -64,15 +64,26 @@
             it will be created.
         :param format: Either a BzrDirFormat, or the name of a format in the
             bzrdir format registry for the branch to be built.
+        :param branch: An already constructed branch to use.  This param is
+            mutually exclusive with the transport and format params.
         """
-        if not transport.has('.'):
-            transport.mkdir('.')
-        if format is None:
-            format = 'default'
-        if isinstance(format, str):
-            format = bzrdir.format_registry.make_bzrdir(format)
-        self._branch = bzrdir.BzrDir.create_branch_convenience(transport.base,
-            format=format, force_new_tree=False)
+        if branch is not None:
+            if format is not None:
+                raise AssertionError(
+                    "branch and format kwargs are mutually exclusive")
+            if transport is not None:
+                raise AssertionError(
+                    "branch and transport kwargs are mutually exclusive")
+            self._branch = branch
+        else:
+            if not transport.has('.'):
+                transport.mkdir('.')
+            if format is None:
+                format = 'default'
+            if isinstance(format, str):
+                format = bzrdir.format_registry.make_bzrdir(format)
+            self._branch = bzrdir.BzrDir.create_branch_convenience(
+                transport.base, format=format, force_new_tree=False)
         self._tree = None
 
     def build_commit(self, **commit_kwargs):

=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py	2009-03-30 11:49:32 +0000
+++ b/bzrlib/fetch.py	2009-04-14 03:15:43 +0000
@@ -136,6 +136,18 @@
             pb.update("Inserting stream")
             resume_tokens, missing_keys = self.sink.insert_stream(
                 stream, from_format, [])
+            if self.to_repository._fallback_repositories:
+                # Find all the parent revisions referenced by the stream, but
+                # not present in the stream, and make sure we have their
+                # inventories.
+                revision_ids = search.get_keys()
+                parent_maps = self.to_repository.get_parent_map(revision_ids)
+                parents = set()
+                map(parents.update, parent_maps.itervalues())
+                parents.difference_update(revision_ids)
+                parents.discard(NULL_REVISION)
+                missing_keys.update(
+                    ('inventories', rev_id) for rev_id in parents)
             if missing_keys:
                 pb.update("Missing keys")
                 stream = source.get_stream_for_missing_keys(missing_keys)

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2009-04-09 20:23:07 +0000
+++ b/bzrlib/remote.py	2009-04-14 03:15:43 +0000
@@ -1645,7 +1645,7 @@
         if response[0][0] == 'missing-basis':
             tokens, missing_keys = bencode.bdecode_as_tuple(response[0][1])
             resume_tokens = tokens
-            return resume_tokens, missing_keys
+            return resume_tokens, set(missing_keys)
         else:
             self.target_repo.refresh_data()
             return [], set()

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2009-04-09 20:23:07 +0000
+++ b/bzrlib/repository.py	2009-04-14 03:15:43 +0000
@@ -3362,7 +3362,7 @@
     @classmethod
     def _get_repo_format_to_test(self):
         from bzrlib.repofmt import pack_repo
-        return pack_repo.RepositoryFormatKnitPack1()
+        return pack_repo.RepositoryFormatKnitPack6RichRoot()
 
     @staticmethod
     def is_compatible(source, target):
@@ -3626,9 +3626,28 @@
         to_texts.insert_record_stream(from_texts.get_record_stream(
             text_keys, self.target._format._fetch_order,
             not self.target._format._fetch_uses_deltas))
-        # insert deltas
+        # insert inventory deltas
         for delta in pending_deltas:
             self.target.add_inventory_by_delta(*delta)
+        if self.target._fallback_repositories:
+            # Make sure this stacked repository has all the parent inventories
+            # for the new revisions that we are about to insert.  We do this
+            # before adding the revisions so that no revision is added until
+            # all the inventories it may depend on are added.
+            parent_ids = set()
+            revision_ids = set()
+            for revision in pending_revisions:
+                revision_ids.add(revision.revision_id)
+                parent_ids.update(revision.parent_ids)
+            parent_ids.difference_update(revision_ids)
+            parent_ids.discard(_mod_revision.NULL_REVISION)
+            parent_map = self.source.get_parent_map(parent_ids)
+            for parent_tree in self.source.revision_trees(parent_ids):
+                basis_id, delta = self._get_delta_for_revision(tree, parent_ids, basis_id, cache)
+                current_revision_id = parent_tree.get_revision_id()
+                parents_parents = parent_map[current_revision_id]
+                self.target.add_inventory_by_delta(
+                    basis_id, delta, current_revision_id, parents_parents)
         # insert signatures and revisions
         for revision in pending_revisions:
             try:

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-04-09 23:12:55 +0000
+++ b/bzrlib/tests/__init__.py	2009-04-14 03:15:43 +0000
@@ -2154,8 +2154,8 @@
         return memorytree.MemoryTree.create_on_branch(b)
 
     def make_branch_builder(self, relpath, format=None):
-        return branchbuilder.BranchBuilder(self.get_transport(relpath),
-            format=format)
+        branch = self.make_branch(relpath, format=format)
+        return branchbuilder.BranchBuilder(branch=branch)
 
     def overrideEnvironmentForTesting(self):
         os.environ['HOME'] = self.test_home_dir

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2009-04-08 03:34:31 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2009-04-09 00:44:52 +0000
@@ -217,7 +217,7 @@
         # being too low. If rpc_count increases, more network roundtrips have
         # become necessary for this use case. Please do not adjust this number
         # upwards without agreement from bzr's network support maintainers.
-        self.assertLength(42, self.hpss_calls)
+        self.assertLength(43, self.hpss_calls)
         remote = Branch.open('public')
         self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
 

=== modified file 'bzrlib/tests/interrepository_implementations/__init__.py'
--- a/bzrlib/tests/interrepository_implementations/__init__.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/interrepository_implementations/__init__.py	2009-04-09 02:59:17 +0000
@@ -32,9 +32,10 @@
     )
 
 from bzrlib.repository import (
-                               InterKnitRepo,
-                               InterRepository,
-                               )
+    InterDifferingSerializer,
+    InterKnitRepo,
+    InterRepository,
+    )
 from bzrlib.tests import (
                           default_transport,
                           multiply_tests,
@@ -107,6 +108,9 @@
     result.append((InterKnitRepo,
                    pack_repo.RepositoryFormatKnitPack3(),
                    pack_repo.RepositoryFormatKnitPack4()))
+    result.append((InterDifferingSerializer,
+                   pack_repo.RepositoryFormatKnitPack1(),
+                   pack_repo.RepositoryFormatKnitPack6RichRoot()))
     return result
 
 

=== modified file 'bzrlib/tests/interrepository_implementations/test_fetch.py'
--- a/bzrlib/tests/interrepository_implementations/test_fetch.py	2009-03-30 11:49:32 +0000
+++ b/bzrlib/tests/interrepository_implementations/test_fetch.py	2009-04-14 03:15:43 +0000
@@ -124,6 +124,44 @@
             to_repo.texts.get_record_stream([('foo', revid)],
             'unordered', True).next().get_bytes_as('fulltext'))
 
+    def test_fetch_parent_inventories_at_stacking_boundary(self):
+        """Fetch to a stacked branch copies inventories for parents of
+        revisions at the stacking boundary.
+
+        This is necessary so that the server is able to determine the file-ids
+        altered by all revisions it contains, which means that it needs both
+        the inventory for any revision it has, and the inventories of all that
+        revision's parents.
+        """
+        to_repo = self.make_to_repository('to')
+        if not to_repo._format.supports_external_lookups:
+            raise TestNotApplicable("Need stacking support in the target.")
+        builder = self.make_branch_builder('branch')
+        builder.start_series()
+        builder.build_snapshot('base', None, [
+            ('add', ('', 'root-id', 'directory', ''))])
+        builder.build_snapshot('left', ['base'], [])
+        builder.build_snapshot('right', ['base'], [])
+        builder.build_snapshot('merge', ['left', 'right'], [])
+        builder.finish_series()
+        branch = builder.get_branch()
+        repo = self.make_to_repository('trunk')
+        trunk = repo.bzrdir.create_branch()
+        trunk.repository.fetch(branch.repository, 'left')
+        trunk.repository.fetch(branch.repository, 'right')
+        repo = self.make_to_repository('stacked')
+        stacked_branch = repo.bzrdir.create_branch()
+        stacked_branch.set_stacked_on_url(trunk.base)
+        stacked_branch.repository.fetch(branch.repository, 'merge')
+        unstacked_repo = stacked_branch.bzrdir.open_repository()
+        unstacked_repo.lock_read()
+        self.addCleanup(unstacked_repo.unlock)
+        self.assertFalse(unstacked_repo.has_revision('left'))
+        self.assertFalse(unstacked_repo.has_revision('right'))
+        self.assertEqual(
+            set([('left',), ('right',), ('merge',)]),
+            unstacked_repo.inventories.keys())
+
     def test_fetch_missing_basis_text(self):
         """If fetching a delta, we should die if a basis is not present."""
         tree = self.make_branch_and_tree('tree')




More information about the bazaar-commits mailing list