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

Reduce number of round trips when fetching from Git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    lockdir,
39
39
    osutils,
40
40
    transport,
41
 
    tree,
42
41
    urlutils,
43
42
    workingtree,
44
43
    )
109
108
                    # TODO: Rather than come up with something here, use the old index
110
109
                    file = StringIO()
111
110
                    stat_val = (0, 0, 0, 0, stat.S_IFREG | 0644, 0, 0, 0, 0, 0)
112
 
                blob.set_raw_string(file.read())
 
111
                blob._text = file.read()
113
112
            elif entry.kind == "symlink":
114
113
                blob = Blob()
115
 
                try:
116
 
                    stat_val = os.lstat(self.abspath(path))
117
 
                except (errors.NoSuchFile, OSError):
118
 
                    # TODO: Rather than come up with something here, use the 
119
 
                    # old index
120
 
                    stat_val = (0, 0, 0, 0, stat.S_IFLNK, 0, 0, 0, 0, 0)
121
 
                blob.set_raw_string(entry.symlink_target)
 
114
                stat_val = os.stat(self.abspath(path))
 
115
                blob._text = entry.symlink_target
122
116
            # Add object to the repository if it didn't exist yet
123
117
            if not blob.id in self.repository._git.object_store:
124
118
                self.repository._git.object_store.add_object(blob)
125
119
            # Add an entry to the index or update the existing entry
126
 
            flags = 0 # FIXME
127
 
            self.index[path.encode("utf-8")] = (stat_val.st_ctime, stat_val.st_mtime, stat_val.st_dev, stat_val.st_ino, stat_val.st_mode, stat_val.st_uid, stat_val.st_gid, stat_val.st_size, blob.id, flags)
 
120
            (mode, ino, dev, links, uid, gid, size, atime, mtime, ctime) = stat_val
 
121
            flags = 0
 
122
            self.index[path.encode("utf-8")] = (ctime, mtime, ino, dev, mode, uid, gid, size, blob.id, flags)
128
123
 
129
124
    def flush(self):
130
125
        # TODO: Maybe this should only write on dirty ?
151
146
        self._ignoreset = ignore_globs
152
147
        return ignore_globs
153
148
 
154
 
    def set_last_revision(self, revid):
155
 
        self._change_last_revision(revid)
156
 
 
157
149
    def _reset_data(self):
158
150
        self._inventory_is_modified = False
159
151
        basis_inv = self.repository.get_inventory(self.mapping.revision_id_foreign_to_bzr(self.repository._git.head()))
160
 
        result = GitIndexInventory(basis_inv, self.mapping, self.index,
161
 
            self.repository._git.object_store)
 
152
        result = GitIndexInventory(basis_inv, self.mapping, self.index)
162
153
        self._set_inventory(result, dirty=False)
163
154
 
164
155
    @needs_read_lock
167
158
            path = self._inventory.id2path(file_id)
168
159
        return osutils.sha_file_by_name(self.abspath(path).encode(osutils._fs_enc))
169
160
 
170
 
    def iter_changes(self, from_tree, include_unchanged=False,
171
 
                     specific_files=None, pb=None, extra_trees=None,
172
 
                     require_versioned=True, want_unversioned=False):
173
 
 
174
 
        intertree = tree.InterTree.get(from_tree, self)
175
 
        return intertree.iter_changes(include_unchanged, specific_files, pb,
176
 
            extra_trees, require_versioned, want_unversioned=want_unversioned)
177
 
 
178
161
 
179
162
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat):
180
163