~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_core.py

  • Committer: abentley
  • Date: 2005-10-14 02:34:55 UTC
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1460.
  • Revision ID: abentley@lappy-20051014023455-a86628f6fdc2e6d1
Removed all remaining use of readonly_path

Show diffs side-by-side

added added

removed removed

Lines of Context:
210
210
    contents = entry.contents_change
211
211
    if contents is None:
212
212
        return None
213
 
    this_path = this.readonly_path(entry.id)
 
213
    if entry.id in this:
 
214
        this_path = this.id2abspath(entry.id)
 
215
    else:
 
216
        this_path = None
214
217
    def make_merge():
215
218
        if this_path is None:
216
219
            return conflict_handler.missing_for_merge(entry.id, 
237
240
                if this_contents == contents.new_contents:
238
241
                    return None
239
242
                else:
240
 
                    other_path = other.readonly_path(entry.id)    
241
243
                    conflict_handler.new_contents_conflict(this_path, 
242
 
                                                           other_path)
 
244
                                                           other_contents)
243
245
        elif isinstance(contents.old_contents, changeset.TreeFileCreate) and \
244
246
            isinstance(contents.new_contents, changeset.TreeFileCreate):
245
247
            return make_merge()
261
263
    metadata = entry.metadata_change
262
264
    if metadata is None:
263
265
        return None
264
 
    if isinstance(metadata, changeset.ChangeExecFlag):
265
 
        if metadata.new_exec_flag is None:
266
 
            return None
267
 
        elif metadata.old_exec_flag is None:
268
 
            return metadata
269
 
        else:
270
 
            base_path = base.readonly_path(entry.id)
271
 
            other_path = other.readonly_path(entry.id)    
272
 
            return ExecFlagMerge(base_path, other_path)
 
266
    assert isinstance(metadata, changeset.ChangeExecFlag)
 
267
    if metadata.new_exec_flag is None:
 
268
        return None
 
269
    elif metadata.old_exec_flag is None:
 
270
        return metadata
 
271
    else:
 
272
        return ExecFlagMerge(base, other, entry.id)
273
273
    
274
274
 
275
275
class ExecFlagMerge(object):
276
 
    def __init__(self, base_path, other_path):
277
 
        self.base_path = base_path
278
 
        self.other_path = other_path
 
276
    def __init__(self, base_tree, other_tree, file_id):
 
277
        self.base_tree = base_tree
 
278
        self.other_tree = other_tree
 
279
        self.file_id = file_id
279
280
 
280
281
    def apply(self, filename, conflict_handler, reverse=False):
281
282
        if not reverse:
282
 
            base = self.base_path
283
 
            other = self.other_path
 
283
            base = self.base_tree
 
284
            other = self.other_tree
284
285
        else:
285
 
            base = self.other_path
286
 
            other = self.base_path
287
 
        base_mode = os.stat(base).st_mode
288
 
        base_exec_flag = bool(base_mode & 0111)
289
 
        other_mode = os.stat(other).st_mode
290
 
        other_exec_flag = bool(other_mode & 0111)
 
286
            base = self.other_tree
 
287
            other = self.base_tree
 
288
        base_exec_flag = base.is_executable(self.file_id)
 
289
        other_exec_flag = other.is_executable(self.file_id)
291
290
        this_mode = os.stat(filename).st_mode
292
291
        this_exec_flag = bool(this_mode & 0111)
293
292
        if (base_exec_flag != other_exec_flag and