~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/changeset.py

  • Committer: Martin Pool
  • Date: 2005-09-22 12:12:53 UTC
  • Revision ID: mbp@sourcefrog.net-20050922121253-eae2a3240ea5e493
- upgrade can no longer be done in current version branches
  so don't test it

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
21
 
23
22
# XXX: mbp: I'm not totally convinced that we should handle conflicts
24
23
# as part of changeset application, rather than only in the merge
43
42
        newdict[value] = key
44
43
    return newdict
45
44
 
 
45
 
46
46
       
47
47
class ChangeUnixPermissions(object):
48
48
    """This is two-way change, suitable for file modification, creation,
92
92
    def __ne__(self, other):
93
93
        return not (self == other)
94
94
 
95
 
 
96
95
def dir_create(filename, conflict_handler, reverse):
97
96
    """Creates the directory, or deletes it if reverse is true.  Intended to be
98
97
    used with ReplaceContents.
118
117
        try:
119
118
            os.rmdir(filename)
120
119
        except OSError, e:
121
 
            if e.errno != errno.ENOTEMPTY:
 
120
            if e.errno != 39:
122
121
                raise
123
122
            if conflict_handler.rmdir_non_empty(filename) == "skip":
124
123
                return
125
124
            os.rmdir(filename)
126
125
 
 
126
                
 
127
            
127
128
 
128
129
class SymlinkCreate(object):
129
130
    """Creates or deletes a symlink (for use with ReplaceContents)"""
352
353
        status = patch.diff3(new_file, filename, base, other)
353
354
        if status == 0:
354
355
            os.chmod(new_file, os.stat(filename).st_mode)
355
 
            rename(new_file, filename)
 
356
            os.rename(new_file, filename)
356
357
            return
357
358
        else:
358
359
            assert(status == 1)
830
831
            if src_path is not None:
831
832
                src_path = os.path.join(dir, src_path)
832
833
                try:
833
 
                    rename(src_path, to_name)
 
834
                    os.rename(src_path, to_name)
834
835
                    temp_name[entry.id] = to_name
835
836
                except OSError, e:
836
837
                    if e.errno != errno.ENOENT:
873
874
            if old_path is None:
874
875
                continue
875
876
            try:
876
 
                rename(old_path, new_path)
 
877
                os.rename(old_path, new_path)
877
878
                changed_inventory[entry.id] = new_tree_path
878
879
            except OSError, e:
879
880
                raise Exception ("%s is missing" % new_path)
1002
1003
    descend from this class if they have a better way to handle some or
1003
1004
    all types of conflict.
1004
1005
    """
 
1006
    def __init__(self, dir):
 
1007
        self.dir = dir
 
1008
    
1005
1009
    def missing_parent(self, pathname):
1006
1010
        parent = os.path.dirname(pathname)
1007
1011
        raise Exception("Parent directory missing for %s" % pathname)
1080
1084
    :rtype: Dictionary
1081
1085
    """
1082
1086
    if conflict_handler is None:
1083
 
        conflict_handler = ExceptionConflictHandler()
 
1087
        conflict_handler = ExceptionConflictHandler(dir)
1084
1088
    temp_dir = os.path.join(dir, "bzr-tree-change")
1085
1089
    try:
1086
1090
        os.mkdir(temp_dir)