~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_core.py

  • Committer: Aaron Bentley
  • Date: 2005-10-04 04:32:32 UTC
  • mfrom: (1185.12.6)
  • mto: (1185.12.13)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: aaron.bentley@utoronto.ca-20051004043231-40302a149769263b
merged my own changes

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"""
206
208
    tree_entry = tree.tree.inventory[file_id]
207
209
    if tree_entry.kind == "file":
208
210
        return changeset.FileCreate(tree.get_file(file_id).read())
 
211
    elif tree_entry.kind == "symlink":
 
212
        return changeset.SymlinkCreate(tree.get_symlink_target(file_id))
209
213
    else:
210
214
        assert tree_entry.kind in ("root_directory", "directory")
211
215
        return changeset.dir_create
228
232
            return None
229
233
        if contents.new_contents is None:
230
234
            this_contents = get_contents(entry, this)
231
 
            if this_path is not None and os.path.exists(this_path):
 
235
            if this_path is not None and bzrlib.osutils.lexists(this_path):
232
236
                if this_contents != contents.old_contents:
233
237
                    return conflict_handler.rem_contents_conflict(this_path, 
234
238
                        this_contents, contents.old_contents)
236
240
            else:
237
241
                return None
238
242
        elif contents.old_contents is None:
239
 
            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):
240
244
                return contents
241
245
            else:
242
246
                this_contents = get_contents(entry, this)
253
257
            raise Exception("Unhandled merge scenario")
254
258
 
255
259
def make_merged_metadata(entry, base, other):
256
 
    if entry.metadata_change is not None:
257
 
        base_path = base.readonly_path(entry.id)
258
 
        other_path = other.readonly_path(entry.id)    
259
 
        return PermissionsMerge(base_path, other_path)
 
260
    metadata = entry.metadata_change
 
261
    if metadata is None:
 
262
        return None
 
263
    if isinstance(metadata, changeset.ChangeUnixPermissions):
 
264
        if metadata.new_mode is None:
 
265
            return None
 
266
        elif metadata.old_mode is None:
 
267
            return metadata
 
268
        else:
 
269
            base_path = base.readonly_path(entry.id)
 
270
            other_path = other.readonly_path(entry.id)    
 
271
            return PermissionsMerge(base_path, other_path)
260
272
    
261
273
 
262
274
class PermissionsMerge(object):