~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Aaron Bentley
  • Date: 2007-01-15 13:10:20 UTC
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20070115131020-wr397y8izr6i2epm
Work on checking out by-reference trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import errno
19
19
from stat import S_ISREG
20
20
 
21
 
from bzrlib import bzrdir, errors
 
21
from bzrlib import (
 
22
    bzrdir,
 
23
    errors,
 
24
    inventory
 
25
    )
22
26
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
23
27
                           ReusingTransform, NotVersionedError, CantMoveRoot,
24
28
                           ExistingLimbo, ImmortalLimbo, NoFinalPath)
99
103
        self._new_contents = {}
100
104
        self._removed_contents = set()
101
105
        self._new_executability = {}
 
106
        self._new_reference_revision = {}
102
107
        self._new_id = {}
103
108
        self._non_present_ids = {}
104
109
        self._r_new_id = {}
350
355
        else:
351
356
            unique_add(self._new_executability, trans_id, executability)
352
357
 
 
358
    def set_tree_reference(self, revision_id, trans_id):
 
359
        """Set the reference associated with a directory"""
 
360
        unique_add(self._new_reference_revision, trans_id, revision_id)
 
361
 
353
362
    def version_file(self, file_id, trans_id):
354
363
        """Schedule a file to become versioned."""
355
364
        assert file_id is not None
815
824
                if trans_id in self._new_id:
816
825
                    if kind is None:
817
826
                        kind = file_kind(self._tree.abspath(path))
818
 
                    inv.add_path(path, kind, self._new_id[trans_id])
 
827
                    if trans_id in self._new_reference_revision:
 
828
                        entry = inventory.TreeReference(self._new_id[trans_id], 
 
829
                            self._new_name[trans_id], 
 
830
                            self.final_file_id(self._new_parent[trans_id]),
 
831
                            None, self._new_reference_revision[trans_id])
 
832
                        inv.add(entry)
 
833
                    else:
 
834
                        inv.add_path(path, kind, self._new_id[trans_id])
819
835
                elif trans_id in self._new_name or trans_id in\
820
836
                    self._new_parent:
821
837
                    entry = limbo_inv.get(trans_id)
1086
1102
        executable = tree.is_executable(entry.file_id)
1087
1103
        return tt.new_file(name, parent_id, contents, entry.file_id, 
1088
1104
                           executable)
1089
 
    elif kind == 'directory':
1090
 
        return tt.new_directory(name, parent_id, entry.file_id)
 
1105
    elif kind in ('directory', 'tree-reference'):
 
1106
        trans_id = tt.new_directory(name, parent_id, entry.file_id)
 
1107
        if kind == 'tree-reference':
 
1108
            tt.set_tree_reference(entry.reference_revision, trans_id)
 
1109
        return trans_id 
1091
1110
    elif kind == 'symlink':
1092
1111
        target = tree.get_symlink_target(entry.file_id)
1093
1112
        return tt.new_symlink(name, parent_id, target, entry.file_id)
 
1113
    else:
 
1114
        raise errors.BadFileKindError(name, kind)
1094
1115
 
1095
1116
def create_by_entry(tt, entry, tree, trans_id, lines=None, mode_id=None):
1096
1117
    """Create new file contents according to an inventory entry."""