~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_core.py

  • Committer: Robert Collins
  • Date: 2005-10-02 21:51:29 UTC
  • mfrom: (1396)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20051002215128-5686c7d24bf9bdb9
merge from martins newformat branch - brings in transport abstraction

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os.path
 
2
 
1
3
import changeset
2
4
from changeset import Inventory, apply_changeset, invert_dict
3
 
import os.path
4
 
from osutils import backup_file, rename
5
 
from merge3 import Merge3
 
5
from bzrlib.osutils import backup_file, rename
 
6
from bzrlib.merge3 import Merge3
 
7
import bzrlib
6
8
 
7
9
class ApplyMerge3:
8
10
    """Contents-change wrapper around merge3.Merge3"""
198
200
 
199
201
 
200
202
def get_contents(entry, tree):
 
203
    return get_id_contents(entry.id, tree)
 
204
 
 
205
def get_id_contents(file_id, tree):
201
206
    """Get a contents change element suitable for use with ReplaceContents
202
207
    """
203
 
    tree_entry = tree.tree.inventory[entry.id]
 
208
    tree_entry = tree.tree.inventory[file_id]
204
209
    if tree_entry.kind == "file":
205
 
        return changeset.FileCreate(tree.get_file(entry.id).read())
 
210
        return changeset.FileCreate(tree.get_file(file_id).read())
206
211
    elif tree_entry.kind == "symlink":
207
 
        return changeset.SymlinkCreate(tree.get_symlink_target(entry.id))
 
212
        return changeset.SymlinkCreate(tree.get_symlink_target(file_id))
208
213
    else:
209
214
        assert tree_entry.kind in ("root_directory", "directory")
210
215
        return changeset.dir_create
226
231
        if contents.old_contents is None and contents.new_contents is None:
227
232
            return None
228
233
        if contents.new_contents is None:
229
 
            if this_path is not None and os.path.exists(this_path):
 
234
            this_contents = get_contents(entry, this)
 
235
            if this_path is not None and bzrlib.osutils.lexists(this_path):
 
236
                if this_contents != contents.old_contents:
 
237
                    return conflict_handler.rem_contents_conflict(this_path, 
 
238
                        this_contents, contents.old_contents)
230
239
                return contents
231
240
            else:
232
241
                return None
233
242
        elif contents.old_contents is None:
234
 
            if this_path is None or not os.path.exists(this_path):
 
243
            if this_path is None or not bzrlib.osutils.lexists(this_path):
235
244
                return contents
236
245
            else:
237
246
                this_contents = get_contents(entry, this)