~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/changeset.py

  • Committer: Robert Collins
  • Date: 2005-09-27 07:24:40 UTC
  • mfrom: (1185.1.41)
  • Revision ID: robertc@robertcollins.net-20050927072440-1bf4d99c3e1db5b3
pair programming worx... merge integration and weave

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