~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Robert Collins
  • Date: 2007-03-06 12:28:18 UTC
  • mto: (2321.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20070306122818-xk0lc3l01ecl6vbc
Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
418
418
        """
419
419
        return self.current_dirstate().get_parent_ids()
420
420
 
421
 
    def get_reference_revision(self, entry, path=None):
 
421
    def get_reference_revision(self, file_id, path=None):
422
422
        # referenced tree's revision is whatever's currently there
423
 
        return self.get_nested_tree(entry, path).last_revision()
 
423
        return self.get_nested_tree(file_id, path).last_revision()
424
424
 
425
 
    def get_nested_tree(self, entry, path=None):
 
425
    def get_nested_tree(self, file_id, path=None):
426
426
        if path is None:
427
 
            path = self.id2path(entry.file_id)
 
427
            path = self.id2path(file_id)
 
428
        # else: check file_id is at path?
428
429
        return WorkingTree.open(self.abspath(path))
429
430
 
430
431
    @needs_read_lock
468
469
                result.append(key[2])
469
470
        return iter(result)
470
471
 
 
472
    def iter_references(self):
 
473
        for key, tree_details in self.current_dirstate()._iter_entries():
 
474
            if tree_details[0][0] in ('a', 'r'): # absent, relocated
 
475
                # not relevant to the working tree
 
476
                continue
 
477
            if not key[1]:
 
478
                # the root is not a reference.
 
479
                continue
 
480
            path = pathjoin(self.basedir, key[0].decode('utf8'), key[1].decode('utf8'))
 
481
            if self._kind(path) == 'tree-reference':
 
482
                yield path, key[2]
 
483
 
471
484
    @needs_read_lock
472
485
    def kind(self, file_id):
473
486
        """Return the kind of a file.
478
491
        relpath = self.id2path(file_id)
479
492
        assert relpath != None, \
480
493
            "path for id {%s} is None!" % file_id
 
494
        return self._kind(relpath)
 
495
 
 
496
    def _kind(self, relpath):
481
497
        abspath = self.abspath(relpath)
482
498
        kind = file_kind(abspath)
483
499
        if kind == 'directory' and self._directory_is_tree_reference(relpath):
1403
1419
    def get_file_text(self, file_id):
1404
1420
        return ''.join(self.get_file_lines(file_id))
1405
1421
 
1406
 
    def get_reference_revision(self, entry, path=None):
1407
 
        return entry.reference_revision
 
1422
    def get_reference_revision(self, file_id, path=None):
 
1423
        return self.inventory[file_id].reference_revision
1408
1424
 
1409
1425
    def get_symlink_target(self, file_id):
1410
1426
        entry = self._get_entry(file_id=file_id)