~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/vf_repository.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Repository formats built around versioned files."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
 
20
22
from bzrlib.lazy_import import lazy_import
21
23
lazy_import(globals(), """
23
25
 
24
26
from bzrlib import (
25
27
    check,
 
28
    config as _mod_config,
26
29
    debug,
27
30
    fetch as _mod_fetch,
28
31
    fifo_cache,
38
41
    tsort,
39
42
    ui,
40
43
    versionedfile,
 
44
    vf_search,
41
45
    )
42
46
 
43
47
from bzrlib.recordcounter import RecordCounter
44
48
from bzrlib.revisiontree import InventoryRevisionTree
45
49
from bzrlib.testament import Testament
 
50
from bzrlib.i18n import gettext
46
51
""")
47
52
 
48
53
from bzrlib import (
64
69
    CommitBuilder,
65
70
    InterRepository,
66
71
    MetaDirRepository,
67
 
    MetaDirRepositoryFormat,
 
72
    RepositoryFormatMetaDir,
68
73
    Repository,
69
74
    RepositoryFormat,
70
75
    )
71
76
 
72
77
from bzrlib.trace import (
73
 
    mutter,
 
78
    mutter
74
79
    )
75
80
 
76
81
 
79
84
 
80
85
    supports_full_versioned_files = True
81
86
    supports_versioned_directories = True
 
87
    supports_unreferenced_revisions = True
82
88
 
83
89
    # Should commit add an inventory, or an inventory delta to the repository.
84
90
    _commit_inv_deltas = True
103
109
    # the default CommitBuilder does not manage trees whose root is versioned.
104
110
    _versioned_root = False
105
111
 
106
 
    def __init__(self, repository, parents, config, timestamp=None,
 
112
    def __init__(self, repository, parents, config_stack, timestamp=None,
107
113
                 timezone=None, committer=None, revprops=None,
108
114
                 revision_id=None, lossy=False):
109
115
        super(VersionedFileCommitBuilder, self).__init__(repository,
110
 
            parents, config, timestamp, timezone, committer, revprops,
 
116
            parents, config_stack, timestamp, timezone, committer, revprops,
111
117
            revision_id, lossy)
112
118
        try:
113
119
            basis_id = self.parents[0]
194
200
                       revision_id=self._new_revision_id,
195
201
                       properties=self._revprops)
196
202
        rev.parent_ids = self.parents
197
 
        self.repository.add_revision(self._new_revision_id, rev,
198
 
            self.new_inventory, self._config)
 
203
        if self._config_stack.get('create_signatures') == _mod_config.SIGN_ALWAYS:
 
204
            testament = Testament(rev, self.revision_tree())
 
205
            plaintext = testament.as_short_text()
 
206
            self.repository.store_revision_signature(
 
207
                gpg.GPGStrategy(self._config_stack), plaintext,
 
208
                self._new_revision_id)
 
209
        self.repository._add_revision(rev)
199
210
        self._ensure_fallback_inventories()
200
211
        self.repository.commit_write_group()
201
212
        return self._new_revision_id
419
430
                return None, False, None
420
431
        # XXX: Friction: parent_candidates should return a list not a dict
421
432
        #      so that we don't have to walk the inventories again.
422
 
        parent_candiate_entries = ie.parent_candidates(parent_invs)
423
 
        head_set = self._heads(ie.file_id, parent_candiate_entries.keys())
 
433
        parent_candidate_entries = ie.parent_candidates(parent_invs)
 
434
        head_set = self._heads(ie.file_id, parent_candidate_entries.keys())
424
435
        heads = []
425
436
        for inv in parent_invs:
426
437
            if inv.has_id(ie.file_id):
441
452
            store = True
442
453
        if not store:
443
454
            # There is a single head, look it up for comparison
444
 
            parent_entry = parent_candiate_entries[heads[0]]
 
455
            parent_entry = parent_candidate_entries[heads[0]]
445
456
            # if the non-content specific data has changed, we'll be writing a
446
457
            # node:
447
458
            if (parent_entry.parent_id != ie.parent_id or
559
570
        :param iter_changes: An iter_changes iterator with the changes to apply
560
571
            to basis_revision_id. The iterator must not include any items with
561
572
            a current kind of None - missing items must be either filtered out
562
 
            or errored-on beefore record_iter_changes sees the item.
 
573
            or errored-on before record_iter_changes sees the item.
563
574
        :param _entry_factory: Private method to bind entry_factory locally for
564
575
            performance.
565
576
        :return: A generator of (file_id, relpath, fs_hash) tuples for use with
593
604
                        _mod_revision.NULL_REVISION))
594
605
        # The basis inventory from a repository 
595
606
        if revtrees:
596
 
            basis_inv = revtrees[0].inventory
 
607
            basis_tree = revtrees[0]
597
608
        else:
598
 
            basis_inv = self.repository.revision_tree(
599
 
                _mod_revision.NULL_REVISION).inventory
 
609
            basis_tree = self.repository.revision_tree(
 
610
                _mod_revision.NULL_REVISION)
 
611
        basis_inv = basis_tree.root_inventory
600
612
        if len(self.parents) > 0:
601
613
            if basis_revision_id != self.parents[0] and not ghost_basis:
602
614
                raise Exception(
603
615
                    "arbitrary basis parents not yet supported with merges")
604
616
            for revtree in revtrees[1:]:
605
 
                for change in revtree.inventory._make_delta(basis_inv):
 
617
                for change in revtree.root_inventory._make_delta(basis_inv):
606
618
                    if change[1] is None:
607
619
                        # Not present in this parent.
608
620
                        continue
918
930
        """
919
931
        if not self._format.supports_external_lookups:
920
932
            raise errors.UnstackableRepositoryFormat(self._format, self.base)
 
933
        # This can raise an exception, so should be done before we lock the
 
934
        # fallback repository.
 
935
        self._check_fallback_repository(repository)
921
936
        if self.is_locked():
922
937
            # This repository will call fallback.unlock() when we transition to
923
938
            # the unlocked state, so we make sure to increment the lock count
924
939
            repository.lock_read()
925
 
        self._check_fallback_repository(repository)
926
940
        self._fallback_repositories.append(repository)
927
941
        self.texts.add_fallback_versioned_files(repository.texts)
928
942
        self.inventories.add_fallback_versioned_files(repository.inventories)
1008
1022
            # return a new inventory, but as there is no revision tree cache in
1009
1023
            # repository this is safe for now - RBC 20081013
1010
1024
            if basis_inv is None:
1011
 
                basis_inv = basis_tree.inventory
 
1025
                basis_inv = basis_tree.root_inventory
1012
1026
            basis_inv.apply_delta(delta)
1013
1027
            basis_inv.revision_id = new_revision_id
1014
1028
            return (self.add_inventory(new_revision_id, basis_inv, parents),
1025
1039
        self.inventories._access.flush()
1026
1040
        return result
1027
1041
 
1028
 
    def add_revision(self, revision_id, rev, inv=None, config=None):
 
1042
    def add_revision(self, revision_id, rev, inv=None):
1029
1043
        """Add rev to the revision store as revision_id.
1030
1044
 
1031
1045
        :param revision_id: the revision id to use.
1032
1046
        :param rev: The revision object.
1033
1047
        :param inv: The inventory for the revision. if None, it will be looked
1034
1048
                    up in the inventory storer
1035
 
        :param config: If None no digital signature will be created.
1036
 
                       If supplied its signature_needed method will be used
1037
 
                       to determine if a signature should be made.
1038
1049
        """
1039
1050
        # TODO: jam 20070210 Shouldn't we check rev.revision_id and
1040
1051
        #       rev.parent_ids?
1041
1052
        _mod_revision.check_not_reserved_id(revision_id)
1042
 
        if config is not None and config.signature_needed():
1043
 
            if inv is None:
1044
 
                inv = self.get_inventory(revision_id)
1045
 
            tree = InventoryRevisionTree(self, inv, revision_id)
1046
 
            testament = Testament(rev, tree)
1047
 
            plaintext = testament.as_short_text()
1048
 
            self.store_revision_signature(
1049
 
                gpg.GPGStrategy(config), plaintext, revision_id)
1050
1053
        # check inventory present
1051
1054
        if not self.inventories.get_parent_map([(revision_id,)]):
1052
1055
            if inv is None:
1085
1088
        keys = {'chk_bytes':set(), 'inventories':set(), 'texts':set()}
1086
1089
        kinds = ['chk_bytes', 'texts']
1087
1090
        count = len(checker.pending_keys)
1088
 
        bar.update("inventories", 0, 2)
 
1091
        bar.update(gettext("inventories"), 0, 2)
1089
1092
        current_keys = checker.pending_keys
1090
1093
        checker.pending_keys = {}
1091
1094
        # Accumulate current checks.
1111
1114
            del keys['inventories']
1112
1115
        else:
1113
1116
            return
1114
 
        bar.update("texts", 1)
 
1117
        bar.update(gettext("texts"), 1)
1115
1118
        while (checker.pending_keys or keys['chk_bytes']
1116
1119
            or keys['texts']):
1117
1120
            # Something to check.
1180
1183
                'sha1 mismatch: %s has sha1 %s expected %s referenced by %s' %
1181
1184
                (record.key, sha1, item_data[1], item_data[2]))
1182
1185
 
 
1186
    @needs_read_lock
 
1187
    def _eliminate_revisions_not_present(self, revision_ids):
 
1188
        """Check every revision id in revision_ids to see if we have it.
 
1189
 
 
1190
        Returns a set of the present revisions.
 
1191
        """
 
1192
        result = []
 
1193
        graph = self.get_graph()
 
1194
        parent_map = graph.get_parent_map(revision_ids)
 
1195
        # The old API returned a list, should this actually be a set?
 
1196
        return parent_map.keys()
 
1197
 
1183
1198
    def __init__(self, _format, a_bzrdir, control_files):
1184
1199
        """Instantiate a VersionedFileRepository.
1185
1200
 
1186
1201
        :param _format: The format of the repository on disk.
1187
 
        :param a_bzrdir: The BzrDir of the repository.
 
1202
        :param controldir: The ControlDir of the repository.
1188
1203
        :param control_files: Control files to use for locking, etc.
1189
1204
        """
1190
1205
        # In the future we will have a single api for all stores for
1192
1207
        # this construct will accept instances of those things.
1193
1208
        super(VersionedFileRepository, self).__init__(_format, a_bzrdir,
1194
1209
            control_files)
 
1210
        self._transport = control_files._transport
 
1211
        self.base = self._transport.base
1195
1212
        # for tests
1196
1213
        self._reconcile_does_inventory_gc = True
1197
1214
        self._reconcile_fixes_text_parents = False
1202
1219
        # rather copying them?
1203
1220
        self._safe_to_return_from_cache = False
1204
1221
 
 
1222
    def fetch(self, source, revision_id=None, find_ghosts=False,
 
1223
            fetch_spec=None):
 
1224
        """Fetch the content required to construct revision_id from source.
 
1225
 
 
1226
        If revision_id is None and fetch_spec is None, then all content is
 
1227
        copied.
 
1228
 
 
1229
        fetch() may not be used when the repository is in a write group -
 
1230
        either finish the current write group before using fetch, or use
 
1231
        fetch before starting the write group.
 
1232
 
 
1233
        :param find_ghosts: Find and copy revisions in the source that are
 
1234
            ghosts in the target (and not reachable directly by walking out to
 
1235
            the first-present revision in target from revision_id).
 
1236
        :param revision_id: If specified, all the content needed for this
 
1237
            revision ID will be copied to the target.  Fetch will determine for
 
1238
            itself which content needs to be copied.
 
1239
        :param fetch_spec: If specified, a SearchResult or
 
1240
            PendingAncestryResult that describes which revisions to copy.  This
 
1241
            allows copying multiple heads at once.  Mutually exclusive with
 
1242
            revision_id.
 
1243
        """
 
1244
        if fetch_spec is not None and revision_id is not None:
 
1245
            raise AssertionError(
 
1246
                "fetch_spec and revision_id are mutually exclusive.")
 
1247
        if self.is_in_write_group():
 
1248
            raise errors.InternalBzrError(
 
1249
                "May not fetch while in a write group.")
 
1250
        # fast path same-url fetch operations
 
1251
        # TODO: lift out to somewhere common with RemoteRepository
 
1252
        # <https://bugs.launchpad.net/bzr/+bug/401646>
 
1253
        if (self.has_same_location(source)
 
1254
            and fetch_spec is None
 
1255
            and self._has_same_fallbacks(source)):
 
1256
            # check that last_revision is in 'from' and then return a
 
1257
            # no-operation.
 
1258
            if (revision_id is not None and
 
1259
                not _mod_revision.is_null(revision_id)):
 
1260
                self.get_revision(revision_id)
 
1261
            return 0, []
 
1262
        inter = InterRepository.get(source, self)
 
1263
        if (fetch_spec is not None and
 
1264
            not getattr(inter, "supports_fetch_spec", False)):
 
1265
            raise errors.UnsupportedOperation(
 
1266
                "fetch_spec not supported for %r" % inter)
 
1267
        return inter.fetch(revision_id=revision_id,
 
1268
            find_ghosts=find_ghosts, fetch_spec=fetch_spec)
 
1269
 
1205
1270
    @needs_read_lock
1206
1271
    def gather_stats(self, revid=None, committers=None):
1207
1272
        """See Repository.gather_stats()."""
1216
1281
            # result['size'] = t
1217
1282
        return result
1218
1283
 
1219
 
    def get_commit_builder(self, branch, parents, config, timestamp=None,
 
1284
    def get_commit_builder(self, branch, parents, config_stack, timestamp=None,
1220
1285
                           timezone=None, committer=None, revprops=None,
1221
1286
                           revision_id=None, lossy=False):
1222
1287
        """Obtain a CommitBuilder for this repository.
1223
1288
 
1224
1289
        :param branch: Branch to commit to.
1225
1290
        :param parents: Revision ids of the parents of the new revision.
1226
 
        :param config: Configuration to use.
 
1291
        :param config_stack: Configuration stack to use.
1227
1292
        :param timestamp: Optional timestamp recorded for commit.
1228
1293
        :param timezone: Optional timezone for timestamp.
1229
1294
        :param committer: Optional committer to set for commit.
1236
1301
            raise errors.BzrError("Cannot commit directly to a stacked branch"
1237
1302
                " in pre-2a formats. See "
1238
1303
                "https://bugs.launchpad.net/bzr/+bug/375013 for details.")
1239
 
        result = self._commit_builder_class(self, parents, config,
 
1304
        result = self._commit_builder_class(self, parents, config_stack,
1240
1305
            timestamp, timezone, committer, revprops, revision_id,
1241
1306
            lossy)
1242
1307
        self.start_write_group()
1498
1563
            text_keys[(file_id, revision_id)] = callable_data
1499
1564
        for record in self.texts.get_record_stream(text_keys, 'unordered', True):
1500
1565
            if record.storage_kind == 'absent':
1501
 
                raise errors.RevisionNotPresent(record.key, self)
 
1566
                raise errors.RevisionNotPresent(record.key[1], record.key[0])
1502
1567
            yield text_keys[record.key], record.get_bytes_as('chunked')
1503
1568
 
1504
1569
    def _generate_text_key_index(self, text_key_references=None,
1554
1619
        batch_size = 10 # should be ~150MB on a 55K path tree
1555
1620
        batch_count = len(revision_order) / batch_size + 1
1556
1621
        processed_texts = 0
1557
 
        pb.update("Calculating text parents", processed_texts, text_count)
 
1622
        pb.update(gettext("Calculating text parents"), processed_texts, text_count)
1558
1623
        for offset in xrange(batch_count):
1559
1624
            to_query = revision_order[offset * batch_size:(offset + 1) *
1560
1625
                batch_size]
1563
1628
            for revision_id in to_query:
1564
1629
                parent_ids = ancestors[revision_id]
1565
1630
                for text_key in revision_keys[revision_id]:
1566
 
                    pb.update("Calculating text parents", processed_texts)
 
1631
                    pb.update(gettext("Calculating text parents"), processed_texts)
1567
1632
                    processed_texts += 1
1568
1633
                    candidate_parents = []
1569
1634
                    for parent_id in parent_ids:
1583
1648
                            try:
1584
1649
                                inv = inventory_cache[parent_id]
1585
1650
                            except KeyError:
1586
 
                                inv = self.revision_tree(parent_id).inventory
 
1651
                                inv = self.revision_tree(parent_id).root_inventory
1587
1652
                                inventory_cache[parent_id] = inv
1588
1653
                            try:
1589
1654
                                parent_entry = inv[text_key[0]]
1639
1704
        num_file_ids = len(file_ids)
1640
1705
        for file_id, altered_versions in file_ids.iteritems():
1641
1706
            if pb is not None:
1642
 
                pb.update("Fetch texts", count, num_file_ids)
 
1707
                pb.update(gettext("Fetch texts"), count, num_file_ids)
1643
1708
            count += 1
1644
1709
            yield ("file", file_id, altered_versions)
1645
1710
 
1682
1747
        if ((None in revision_ids)
1683
1748
            or (_mod_revision.NULL_REVISION in revision_ids)):
1684
1749
            raise ValueError('cannot get null revision inventory')
1685
 
        return self._iter_inventories(revision_ids, ordering)
 
1750
        for inv, revid in self._iter_inventories(revision_ids, ordering):
 
1751
            if inv is None:
 
1752
                raise errors.NoSuchRevision(self, revid)
 
1753
            yield inv
1686
1754
 
1687
1755
    def _iter_inventories(self, revision_ids, ordering):
1688
1756
        """single-document based inventory iteration."""
1689
1757
        inv_xmls = self._iter_inventory_xmls(revision_ids, ordering)
1690
1758
        for text, revision_id in inv_xmls:
1691
 
            yield self._deserialise_inventory(revision_id, text)
 
1759
            if text is None:
 
1760
                yield None, revision_id
 
1761
            else:
 
1762
                yield self._deserialise_inventory(revision_id, text), revision_id
1692
1763
 
1693
1764
    def _iter_inventory_xmls(self, revision_ids, ordering):
1694
1765
        if ordering is None:
1712
1783
                else:
1713
1784
                    yield ''.join(chunks), record.key[-1]
1714
1785
            else:
1715
 
                raise errors.NoSuchRevision(self, record.key)
 
1786
                yield None, record.key[-1]
1716
1787
            if order_as_requested:
1717
1788
                # Yield as many results as we can while preserving order.
1718
1789
                while next_key in text_chunks:
1747
1818
    def _get_inventory_xml(self, revision_id):
1748
1819
        """Get serialized inventory as a string."""
1749
1820
        texts = self._iter_inventory_xmls([revision_id], 'unordered')
1750
 
        try:
1751
 
            text, revision_id = texts.next()
1752
 
        except StopIteration:
1753
 
            raise errors.HistoryMissing(self, 'inventory', revision_id)
 
1821
        text, revision_id = texts.next()
 
1822
        if text is None:
 
1823
            raise errors.NoSuchRevision(self, revision_id)
1754
1824
        return text
1755
1825
 
1756
1826
    @needs_read_lock
1831
1901
        """Return the graph walker for text revisions."""
1832
1902
        return graph.Graph(self.texts)
1833
1903
 
 
1904
    def revision_ids_to_search_result(self, result_set):
 
1905
        """Convert a set of revision ids to a graph SearchResult."""
 
1906
        result_parents = set()
 
1907
        for parents in self.get_graph().get_parent_map(
 
1908
            result_set).itervalues():
 
1909
            result_parents.update(parents)
 
1910
        included_keys = result_set.intersection(result_parents)
 
1911
        start_keys = result_set.difference(included_keys)
 
1912
        exclude_keys = result_parents.difference(result_set)
 
1913
        result = vf_search.SearchResult(start_keys, exclude_keys,
 
1914
            len(result_set), result_set)
 
1915
        return result
 
1916
 
1834
1917
    def _get_versioned_file_checker(self, text_key_references=None,
1835
1918
        ancestors=None):
1836
1919
        """Return an object suitable for checking versioned files.
1921
2004
            control_files)
1922
2005
 
1923
2006
 
1924
 
class MetaDirVersionedFileRepositoryFormat(MetaDirRepositoryFormat,
 
2007
class MetaDirVersionedFileRepositoryFormat(RepositoryFormatMetaDir,
1925
2008
        VersionedFileRepositoryFormat):
1926
2009
    """Base class for repository formats using versioned files in metadirs."""
1927
2010
 
2359
2442
        invs_sent_so_far = set([_mod_revision.NULL_REVISION])
2360
2443
        inventory_cache = lru_cache.LRUCache(50)
2361
2444
        null_inventory = from_repo.revision_tree(
2362
 
            _mod_revision.NULL_REVISION).inventory
 
2445
            _mod_revision.NULL_REVISION).root_inventory
2363
2446
        # XXX: ideally the rich-root/tree-refs flags would be per-revision, not
2364
2447
        # per-repo (e.g.  streaming a non-rich-root revision out of a rich-root
2365
2448
        # repo back into a non-rich-root repo ought to be allowed)
2450
2533
            self.text_index.iterkeys()])
2451
2534
        # text keys is now grouped by file_id
2452
2535
        n_versions = len(self.text_index)
2453
 
        progress_bar.update('loading text store', 0, n_versions)
 
2536
        progress_bar.update(gettext('loading text store'), 0, n_versions)
2454
2537
        parent_map = self.repository.texts.get_parent_map(self.text_index)
2455
2538
        # On unlistable transports this could well be empty/error...
2456
2539
        text_keys = self.repository.texts.keys()
2457
2540
        unused_keys = frozenset(text_keys) - set(self.text_index)
2458
2541
        for num, key in enumerate(self.text_index.iterkeys()):
2459
 
            progress_bar.update('checking text graph', num, n_versions)
 
2542
            progress_bar.update(gettext('checking text graph'), num, n_versions)
2460
2543
            correct_parents = self.calculate_file_version_parents(key)
2461
2544
            try:
2462
2545
                knit_parents = parent_map[key]
2472
2555
 
2473
2556
    _walk_to_common_revisions_batch_size = 50
2474
2557
 
 
2558
    supports_fetch_spec = True
 
2559
 
2475
2560
    @needs_write_lock
2476
2561
    def fetch(self, revision_id=None, find_ghosts=False,
2477
2562
            fetch_spec=None):
2483
2568
                            content is copied.
2484
2569
        :return: None.
2485
2570
        """
2486
 
        ui.ui_factory.warn_experimental_format_fetch(self)
 
2571
        if self.target._format.experimental:
 
2572
            ui.ui_factory.show_user_warning('experimental_format_fetch',
 
2573
                from_format=self.source._format,
 
2574
                to_format=self.target._format)
2487
2575
        from bzrlib.fetch import RepoFetcher
2488
2576
        # See <https://launchpad.net/bugs/456077> asking for a warning here
2489
2577
        if self.source._format.network_name() != self.target._format.network_name():
2550
2638
                searcher.stop_searching_any(stop_revs)
2551
2639
            if searcher_exhausted:
2552
2640
                break
2553
 
        return searcher.get_result()
 
2641
        (started_keys, excludes, included_keys) = searcher.get_state()
 
2642
        return vf_search.SearchResult(started_keys, excludes,
 
2643
            len(included_keys), included_keys)
2554
2644
 
2555
2645
    @needs_read_lock
2556
2646
    def search_missing_revision_ids(self,
2705
2795
        """
2706
2796
        deltas = []
2707
2797
        # Generate deltas against each tree, to find the shortest.
 
2798
        # FIXME: Support nested trees
2708
2799
        texts_possibly_new_in_tree = set()
2709
2800
        for basis_id, basis_tree in possible_trees:
2710
 
            delta = tree.inventory._make_delta(basis_tree.inventory)
 
2801
            delta = tree.root_inventory._make_delta(basis_tree.root_inventory)
2711
2802
            for old_path, new_path, file_id, new_entry in delta:
2712
2803
                if new_path is None:
2713
2804
                    # This file_id isn't present in the new rev, so we don't
2750
2841
            parents_parents = [key[-1] for key in parents_parents_keys]
2751
2842
            basis_id = _mod_revision.NULL_REVISION
2752
2843
            basis_tree = self.source.revision_tree(basis_id)
2753
 
            delta = parent_tree.inventory._make_delta(basis_tree.inventory)
 
2844
            delta = parent_tree.root_inventory._make_delta(
 
2845
                basis_tree.root_inventory)
2754
2846
            self.target.add_inventory_by_delta(
2755
2847
                basis_id, delta, current_revision_id, parents_parents)
2756
2848
            cache[current_revision_id] = parent_tree
2815
2907
                kind = entry.kind
2816
2908
                texts_possibly_new_in_tree.add((file_id, entry.revision))
2817
2909
            for basis_id, basis_tree in possible_trees:
2818
 
                basis_inv = basis_tree.inventory
 
2910
                basis_inv = basis_tree.root_inventory
2819
2911
                for file_key in list(texts_possibly_new_in_tree):
2820
2912
                    file_id, file_revision = file_key
2821
2913
                    try:
2903
2995
        for offset in range(0, len(revision_ids), batch_size):
2904
2996
            self.target.start_write_group()
2905
2997
            try:
2906
 
                pb.update('Transferring revisions', offset,
 
2998
                pb.update(gettext('Transferring revisions'), offset,
2907
2999
                          len(revision_ids))
2908
3000
                batch = revision_ids[offset:offset+batch_size]
2909
3001
                basis_id = self._fetch_batch(batch, basis_id, cache)
2917
3009
                    hints.extend(hint)
2918
3010
        if hints and self.target._format.pack_compresses:
2919
3011
            self.target.pack(hint=hints)
2920
 
        pb.update('Transferring revisions', len(revision_ids),
 
3012
        pb.update(gettext('Transferring revisions'), len(revision_ids),
2921
3013
                  len(revision_ids))
2922
3014
 
2923
3015
    @needs_write_lock
2928
3020
            revision_ids = fetch_spec.get_keys()
2929
3021
        else:
2930
3022
            revision_ids = None
2931
 
        ui.ui_factory.warn_experimental_format_fetch(self)
 
3023
        if self.source._format.experimental:
 
3024
            ui.ui_factory.show_user_warning('experimental_format_fetch',
 
3025
                from_format=self.source._format,
 
3026
                to_format=self.target._format)
2932
3027
        if (not self.source.supports_rich_root()
2933
3028
            and self.target.supports_rich_root()):
2934
3029
            self._converting_to_rich_root = True
3029
3124
            _install_revision(repository, revision, revision_tree, signature,
3030
3125
                inventory_cache)
3031
3126
            if pb is not None:
3032
 
                pb.update('Transferring revisions', n + 1, num_revisions)
 
3127
                pb.update(gettext('Transferring revisions'), n + 1, num_revisions)
3033
3128
    except:
3034
3129
        repository.abort_write_group()
3035
3130
        raise
3050
3145
            parent_trees[p_id] = repository.revision_tree(
3051
3146
                                     _mod_revision.NULL_REVISION)
3052
3147
 
3053
 
    inv = revision_tree.inventory
 
3148
    # FIXME: Support nested trees
 
3149
    inv = revision_tree.root_inventory
3054
3150
    entries = inv.iter_entries()
3055
3151
    # backwards compatibility hack: skip the root id.
3056
3152
    if not repository.supports_rich_root():