~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/changeset.py

Merge in format-5 work - release bzr 0.1rc1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import patch
19
19
import stat
20
20
from bzrlib.trace import mutter
 
21
from bzrlib.osutils import rename
 
22
import bzrlib
21
23
 
22
24
# XXX: mbp: I'm not totally convinced that we should handle conflicts
23
25
# as part of changeset application, rather than only in the merge
42
44
        newdict[value] = key
43
45
    return newdict
44
46
 
45
 
 
46
47
       
47
48
class ChangeUnixPermissions(object):
48
49
    """This is two-way change, suitable for file modification, creation,
92
93
    def __ne__(self, other):
93
94
        return not (self == other)
94
95
 
 
96
 
95
97
def dir_create(filename, conflict_handler, reverse):
96
98
    """Creates the directory, or deletes it if reverse is true.  Intended to be
97
99
    used with ReplaceContents.
117
119
        try:
118
120
            os.rmdir(filename)
119
121
        except OSError, e:
120
 
            if e.errno != 39:
 
122
            if e.errno != errno.ENOTEMPTY:
121
123
                raise
122
124
            if conflict_handler.rmdir_non_empty(filename) == "skip":
123
125
                return
124
126
            os.rmdir(filename)
125
127
 
126
 
                
127
 
            
128
128
 
129
129
class SymlinkCreate(object):
130
130
    """Creates or deletes a symlink (for use with ReplaceContents)"""
353
353
        status = patch.diff3(new_file, filename, base, other)
354
354
        if status == 0:
355
355
            os.chmod(new_file, os.stat(filename).st_mode)
356
 
            os.rename(new_file, filename)
 
356
            rename(new_file, filename)
357
357
            return
358
358
        else:
359
359
            assert(status == 1)
831
831
            if src_path is not None:
832
832
                src_path = os.path.join(dir, src_path)
833
833
                try:
834
 
                    os.rename(src_path, to_name)
 
834
                    rename(src_path, to_name)
835
835
                    temp_name[entry.id] = to_name
836
836
                except OSError, e:
837
837
                    if e.errno != errno.ENOENT:
863
863
            continue
864
864
        new_path = os.path.join(dir, new_tree_path)
865
865
        old_path = changed_inventory.get(entry.id)
866
 
        if os.path.exists(new_path):
 
866
        if bzrlib.osutils.lexists(new_path):
867
867
            if conflict_handler.target_exists(entry, new_path, old_path) == \
868
868
                "skip":
869
869
                continue
874
874
            if old_path is None:
875
875
                continue
876
876
            try:
877
 
                os.rename(old_path, new_path)
 
877
                rename(old_path, new_path)
878
878
                changed_inventory[entry.id] = new_tree_path
879
879
            except OSError, e:
880
880
                raise Exception ("%s is missing" % new_path)
1384
1384
 
1385
1385
        if cs_entry is None:
1386
1386
            return None
 
1387
 
 
1388
        full_path_a = self.tree_a.readonly_path(id)
 
1389
        full_path_b = self.tree_b.readonly_path(id)
 
1390
        stat_a = self.lstat(full_path_a)
 
1391
        stat_b = self.lstat(full_path_b)
 
1392
 
 
1393
        cs_entry.metadata_change = self.make_mode_change(stat_a, stat_b)
 
1394
 
1387
1395
        if id in self.tree_a and id in self.tree_b:
1388
1396
            a_sha1 = self.tree_a.get_file_sha1(id)
1389
1397
            b_sha1 = self.tree_b.get_file_sha1(id)
1390
1398
            if None not in (a_sha1, b_sha1) and a_sha1 == b_sha1:
1391
1399
                return cs_entry
1392
1400
 
1393
 
        full_path_a = self.tree_a.readonly_path(id)
1394
 
        full_path_b = self.tree_b.readonly_path(id)
1395
 
        stat_a = self.lstat(full_path_a)
1396
 
        stat_b = self.lstat(full_path_b)
1397
 
        
1398
 
        cs_entry.metadata_change = self.make_mode_change(stat_a, stat_b)
1399
1401
        cs_entry.contents_change = self.make_contents_change(full_path_a,
1400
1402
                                                             stat_a, 
1401
1403
                                                             full_path_b,