/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/workingtree_4.py

  • Committer: Martin Pool
  • Date: 2007-09-14 06:31:28 UTC
  • mfrom: (2822 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2823.
  • Revision ID: mbp@sourcefrog.net-20070914063128-0p7mh6zfb4pzdg9p
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    bzrdir,
44
44
    cache_utf8,
45
45
    conflicts as _mod_conflicts,
 
46
    debug,
46
47
    delta,
47
48
    dirstate,
48
49
    errors,
55
56
    revision as _mod_revision,
56
57
    revisiontree,
57
58
    textui,
 
59
    trace,
58
60
    transform,
59
61
    urlutils,
60
62
    xml5,
130
132
        """
131
133
        self._format = _format
132
134
        self.bzrdir = _bzrdir
133
 
        from bzrlib.trace import note, mutter
134
135
        assert isinstance(basedir, basestring), \
135
136
            "base directory %r is not a string" % basedir
136
137
        basedir = safe_unicode(basedir)
408
409
    def get_file_sha1(self, file_id, path=None, stat_value=None):
409
410
        # check file id is valid unconditionally.
410
411
        entry = self._get_entry(file_id=file_id, path=path)
411
 
        assert entry[0] is not None, 'what error should this raise'
 
412
        if entry[0] is None:
 
413
            raise errors.NoSuchId(self, file_id)
412
414
        if path is None:
413
415
            path = pathjoin(entry[0][0], entry[0][1]).decode('utf8')
414
416
 
430
432
 
431
433
    def _get_inventory(self):
432
434
        """Get the inventory for the tree. This is only valid within a lock."""
 
435
        if 'evil' in debug.debug_flags:
 
436
            trace.mutter_callsite(2,
 
437
                "accessing .inventory forces a size of tree translation.")
433
438
        if self._inventory is not None:
434
439
            return self._inventory
435
440
        self._must_be_locked()
567
572
        if parent_ids:
568
573
            return parent_ids[0]
569
574
        else:
570
 
            return None
 
575
            return _mod_revision.NULL_REVISION
571
576
 
572
577
    def lock_read(self):
573
578
        """See Branch.lock_read, and WorkingTree.unlock."""
1113
1118
 
1114
1119
    def unlock(self):
1115
1120
        """Unlock in format 4 trees needs to write the entire dirstate."""
 
1121
        # do non-implementation specific cleanup
 
1122
        self._cleanup()
 
1123
 
1116
1124
        if self._control_files._lock_count == 1:
1117
1125
            # eventually we should do signature checking during read locks for
1118
1126
            # dirstate updates.
1346
1354
        return "<%s of %s in %s>" % \
1347
1355
            (self.__class__.__name__, self._revision_id, self._dirstate)
1348
1356
 
1349
 
    def annotate_iter(self, file_id):
 
1357
    def annotate_iter(self, file_id,
 
1358
                      default_revision=_mod_revision.CURRENT_REVISION):
1350
1359
        """See Tree.annotate_iter"""
1351
 
        w = self._repository.weave_store.get_weave(file_id,
1352
 
                           self._repository.get_transaction())
 
1360
        w = self._get_weave(file_id)
1353
1361
        return w.annotate_iter(self.inventory[file_id].revision)
1354
1362
 
 
1363
    def _get_ancestors(self, default_revision):
 
1364
        return set(self._repository.get_ancestry(self._revision_id,
 
1365
                                                 topo_sorted=False))
1355
1366
    def _comparison_data(self, entry, path):
1356
1367
        """See Tree._comparison_data."""
1357
1368
        if entry is None:
1490
1501
            return parent_details[1]
1491
1502
        return None
1492
1503
 
 
1504
    @symbol_versioning.deprecated_method(symbol_versioning.zero_ninety)
1493
1505
    def get_weave(self, file_id):
 
1506
        return self._get_weave(file_id)
 
1507
 
 
1508
    def _get_weave(self, file_id):
1494
1509
        return self._repository.weave_store.get_weave(file_id,
1495
1510
                self._repository.get_transaction())
1496
1511
 
1497
 
    def get_file(self, file_id):
 
1512
    def get_file(self, file_id, path=None):
1498
1513
        return StringIO(self.get_file_text(file_id))
1499
1514
 
1500
1515
    def get_file_lines(self, file_id):
1501
1516
        ie = self.inventory[file_id]
1502
 
        return self._repository.weave_store.get_weave(file_id,
1503
 
                self._repository.get_transaction()).get_lines(ie.revision)
 
1517
        return self._get_weave(file_id).get_lines(ie.revision)
1504
1518
 
1505
1519
    def get_file_size(self, file_id):
1506
1520
        return self.inventory[file_id].text_size
1511
1525
    def get_reference_revision(self, file_id, path=None):
1512
1526
        return self.inventory[file_id].reference_revision
1513
1527
 
 
1528
    def iter_files_bytes(self, desired_files):
 
1529
        """See Tree.iter_files_bytes.
 
1530
 
 
1531
        This version is implemented on top of Repository.iter_files_bytes"""
 
1532
        parent_index = self._get_parent_index()
 
1533
        repo_desired_files = []
 
1534
        for file_id, identifier in desired_files:
 
1535
            entry = self._get_entry(file_id)
 
1536
            if entry == (None, None):
 
1537
                raise errors.NoSuchId(self, file_id)
 
1538
            repo_desired_files.append((file_id, entry[1][parent_index][4],
 
1539
                                       identifier))
 
1540
        return self._repository.iter_files_bytes(repo_desired_files)
 
1541
 
1514
1542
    def get_symlink_target(self, file_id):
1515
1543
        entry = self._get_entry(file_id=file_id)
1516
1544
        parent_index = self._get_parent_index()
1682
1710
        """
1683
1711
        utf8_decode = cache_utf8._utf8_decode
1684
1712
        _minikind_to_kind = dirstate.DirState._minikind_to_kind
 
1713
        cmp_by_dirs = dirstate.cmp_by_dirs
1685
1714
        # NB: show_status depends on being able to pass in non-versioned files
1686
1715
        # and report them as unknown
1687
1716
        # TODO: handle extra trees in the dirstate.
1688
1717
        # TODO: handle comparisons as an empty tree as a different special
1689
1718
        # case? mbp 20070226
1690
 
        if extra_trees or (self.source._revision_id == NULL_REVISION):
 
1719
        if (extra_trees or (self.source._revision_id == NULL_REVISION)
 
1720
            or specific_files == []):
1691
1721
            # we can't fast-path these cases (yet)
1692
1722
            for f in super(InterDirStateTree, self)._iter_changes(
1693
1723
                include_unchanged, specific_files, pb, extra_trees,
2168
2198
                   current_block is not None):
2169
2199
                if (current_dir_info and current_block
2170
2200
                    and current_dir_info[0][0] != current_block[0]):
2171
 
                    if current_dir_info[0][0].split('/') < current_block[0].split('/'):
 
2201
                    if cmp_by_dirs(current_dir_info[0][0], current_block[0]) < 0:
2172
2202
                        # filesystem data refers to paths not covered by the dirblock.
2173
2203
                        # this has two possibilities:
2174
2204
                        # A) it is versioned but empty, so there is no block for it