/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

merge bzr.dev r3564

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
import bzrlib
25
25
from bzrlib import (
 
26
    conflicts as _mod_conflicts,
26
27
    delta,
27
28
    filters,
28
29
    osutils,
29
30
    revision as _mod_revision,
30
 
    conflicts as _mod_conflicts,
 
31
    rules,
31
32
    symbol_versioning,
32
33
    )
33
34
from bzrlib.decorators import needs_read_lock
177
178
    def iter_entries_by_dir(self, specific_file_ids=None):
178
179
        """Walk the tree in 'by_dir' order.
179
180
 
180
 
        This will yield each entry in the tree as a (path, entry) tuple. The
181
 
        order that they are yielded is: the contents of a directory are 
182
 
        preceeded by the parent of a directory, and all the contents of a 
183
 
        directory are grouped together.
 
181
        This will yield each entry in the tree as a (path, entry) tuple.
 
182
        The order that they are yielded is:
 
183
 
 
184
        Directories are walked in a depth-first lexicographical order,
 
185
        however, whenever a directory is reached, all of its direct child
 
186
        nodes are yielded in  lexicographical order before yielding the
 
187
        grandchildren.
 
188
 
 
189
        For example, in the tree::
 
190
 
 
191
           a/
 
192
             b/
 
193
               c
 
194
             d/
 
195
               e
 
196
           f/
 
197
             g
 
198
 
 
199
        The yield order (ignoring root) would be::
 
200
          a, f, a/b, a/d, a/b/c, a/d/e, f/g
184
201
        """
185
202
        return self.inventory.iter_entries_by_dir(
186
203
            specific_file_ids=specific_file_ids)
359
376
                                 last_revision_base)
360
377
 
361
378
    def _get_file_revision(self, file_id, vf, tree_revision):
 
379
        """Ensure that file_id, tree_revision is in vf to plan the merge."""
362
380
        def file_revision(revision_tree):
363
381
            revision_tree.lock_read()
364
382
            try:
373
391
                except:
374
392
                    yield self.repository.revision_tree(revision_id)
375
393
 
376
 
        if getattr(self, '_get_weave', None) is None:
 
394
        if getattr(self, '_repository', None) is None:
377
395
            last_revision = tree_revision
378
 
            parent_revisions = [file_revision(t) for t in iter_parent_trees()]
379
 
            vf.add_lines(last_revision, parent_revisions,
 
396
            parent_keys = [(file_id, file_revision(t)) for t in
 
397
                iter_parent_trees()]
 
398
            vf.add_lines((file_id, last_revision), parent_keys,
380
399
                         self.get_file(file_id).readlines())
381
400
            repo = self.branch.repository
382
 
            transaction = repo.get_transaction()
383
 
            base_vf = repo.weave_store.get_weave(file_id, transaction)
 
401
            base_vf = repo.texts
384
402
        else:
385
403
            last_revision = file_revision(self)
386
 
            base_vf = self._get_weave(file_id)
387
 
        vf.fallback_versionedfiles.append(base_vf)
 
404
            base_vf = self._repository.texts
 
405
        if base_vf not in vf.fallback_versionedfiles:
 
406
            vf.fallback_versionedfiles.append(base_vf)
388
407
        return last_revision
389
408
 
390
409
    inventory = property(_get_inventory,
433
452
        """
434
453
        return find_ids_across_trees(paths, [self] + list(trees), require_versioned)
435
454
 
 
455
    @symbol_versioning.deprecated_method(symbol_versioning.one_six)
436
456
    def print_file(self, file_id):
437
457
        """Print file with id `file_id` to stdout."""
438
458
        import sys
527
547
            return []
528
548
        if path is None:
529
549
            path = self.id2path(file_id)
530
 
        prefs = None
531
 
        # TODO: Replace the line above with the line below
532
 
        # (when the rule-based preferences branch is merged)
533
 
        #prefs = rules.iter_search_rules(self.branch, [path],
534
 
        #    filter_pref_names).next()
 
550
        prefs = rules.iter_search_rules(self.branch, [path],
 
551
            filter_pref_names).next()
535
552
        return filters._get_filter_stack_for(prefs)
536
553
 
 
554
    def iter_search_rules(self, path_names, pref_names=None,
 
555
        _default_searcher=rules._per_user_searcher):
 
556
        """Find the preferences for filenames in a tree.
 
557
 
 
558
        :param path_names: an iterable of paths to find attributes for.
 
559
          Paths are given relative to the root of the tree.
 
560
        :param pref_names: the list of preferences to lookup - None for all
 
561
        :param _default_searcher: private parameter to assist testing - don't use
 
562
        :return: an iterator of tuple sequences, one per path-name.
 
563
          See _RulesSearcher.get_items for details on the tuple sequence.
 
564
        """
 
565
        searcher = self._get_rules_searcher(_default_searcher)
 
566
        if searcher is not None:
 
567
            if pref_names is not None:
 
568
                for path in path_names:
 
569
                    yield searcher.get_selected_items(path, pref_names)
 
570
            else:
 
571
                for path in path_names:
 
572
                    yield searcher.get_items(path)
 
573
 
 
574
    @needs_read_lock
 
575
    def _get_rules_searcher(self, default_searcher):
 
576
        """Get the RulesSearcher for this tree given the default one."""
 
577
        searcher = default_searcher
 
578
        file_id = self.path2id(rules.RULES_TREE_FILENAME)
 
579
        if file_id is not None:
 
580
            ini_file = self.get_file(file_id)
 
581
            searcher = rules._StackedRulesSearcher(
 
582
                [rules._IniBasedRulesSearcher(ini_file), default_searcher])
 
583
        return searcher
 
584
 
537
585
 
538
586
class EmptyTree(Tree):
539
587