~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_core.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-08-26 01:50:01 UTC
  • mto: (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 1178.
  • Revision ID: aaron.bentley@utoronto.ca-20050826015001-d8b6e6330cb6401a
Merged from bzr.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
    from bzrlib.trace import mutter
151
151
    def entry_data(file_id, tree):
152
152
        assert hasattr(tree, "__contains__"), "%s" % tree
153
 
        if not tree.has_or_had_id(file_id):
 
153
        if file_id not in tree:
154
154
            return (None, None, "")
155
155
        entry = tree.tree.inventory[file_id]
156
156
        my_dir = tree.id2path(entry.parent_id)
176
176
        new_parent = conflict_handler.move_conflict(entry.id, this_dir,
177
177
                                                    base_dir, other_dir)
178
178
    def get_path(name, parent):
179
 
        if name is not None:
180
 
            if name == "":
181
 
                assert parent is None
182
 
                return './.'
 
179
        if name is not None and parent is not None:
183
180
            parent_dir = {this_parent: this_dir, other_parent: other_dir, 
184
181
                          base_parent: base_dir}
185
182
            directory = parent_dir[parent]
186
183
            return os.path.join(directory, name)
187
184
        else:
188
 
            assert parent is None
 
185
            assert name is None and parent is None
189
186
            return None
190
187
 
191
188
    old_path = get_path(old_name, old_parent)
197
194
    return new_entry
198
195
 
199
196
 
200
 
def get_contents(entry, tree):
201
 
    """Get a contents change element suitable for use with ReplaceContents
202
 
    """
203
 
    tree_entry = tree.tree.inventory[entry.id]
204
 
    if tree_entry.kind == "file":
205
 
        return changeset.FileCreate(tree.get_file(entry.id).read())
206
 
    else:
207
 
        assert tree_entry.kind in ("root_directory", "directory")
208
 
        return changeset.dir_create
209
 
 
210
 
 
211
197
def make_merged_contents(entry, this, base, other, conflict_handler,
212
198
                         merge_factory):
213
199
    contents = entry.contents_change
232
218
            if this_path is None or not os.path.exists(this_path):
233
219
                return contents
234
220
            else:
235
 
                this_contents = get_contents(entry, this)
 
221
                this_contents = changeset.FileCreate(file(this_path, 
 
222
                                                     "rb").read())
236
223
                if this_contents == contents.new_contents:
237
224
                    return None
238
225
                else:
355
342
    def __contains__(self, file_id):
356
343
        return file_id in self.inventory
357
344
 
358
 
    def has_or_had_id(self, file_id):
359
 
        return file_id in self
360
 
 
361
345
    def get_file(self, file_id):
362
346
        path = self.readonly_path(file_id)
363
347
        return file(path, "rb")