~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2005-10-27 23:14:48 UTC
  • mfrom: (1185.16.130)
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1491.
  • Revision ID: abentley@panoramicfeedback.com-20051027231448-ba0ae9cde819edc9
MergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        for line in lines:
87
87
            d_file.write(line)
88
88
 
89
 
    def add_suffix(self, name, suffix, last_new_name=None):
 
89
    def add_suffix(self, name, suffix, last_new_name=None, fix_inventory=True):
90
90
        """Rename a file to append a suffix.  If the new name exists, the
91
91
        suffix is added repeatedly until a non-existant name is found
92
92
 
99
99
        new_name = last_new_name+suffix
100
100
        try:
101
101
            rename(name, new_name)
102
 
            try:
103
 
                relpath = self.this_tree.relpath(name)
104
 
            except NotBranchError:
105
 
                relpath = None
106
 
            if relpath is not None:
107
 
                file_id = self.this_tree.path2id(relpath)
108
 
                if file_id is not None:
109
 
                    new_path = self.this_tree.relpath(new_name)
110
 
                    rename(new_name, name)
111
 
                    self.this_tree.branch.rename_one(relpath, new_path)
112
 
                    assert self.this_tree.id2path(file_id) == relpath
113
 
                    self.this_tree._inventory = self.this_tree.branch.inventory
114
 
                    assert self.this_tree.id2path(file_id) == new_path
 
102
            if fix_inventory is True:
 
103
                try:
 
104
                    relpath = self.this_tree.relpath(name)
 
105
                except NotBranchError:
 
106
                    relpath = None
 
107
                if relpath is not None:
 
108
                    file_id = self.this_tree.path2id(relpath)
 
109
                    if file_id is not None:
 
110
                        new_path = self.this_tree.relpath(new_name)
 
111
                        rename(new_name, name)
 
112
                        self.this_tree.branch.rename_one(relpath, new_path)
 
113
                        assert self.this_tree.id2path(file_id) == relpath
 
114
                        self.this_tree._inventory = self.this_tree.branch.inventory
 
115
                        assert self.this_tree.id2path(file_id) == new_path
115
116
        except OSError, e:
116
117
            if e.errno != errno.EEXIST and e.errno != errno.ENOTEMPTY:
117
118
                raise
118
 
            return self.add_suffix(name, suffix, last_new_name=new_name)
 
119
            return self.add_suffix(name, suffix, last_new_name=new_name, 
 
120
                                   fix_inventory=fix_inventory)
119
121
        return new_name
120
122
 
121
123
    def conflict(self, text):
132
134
        :param base_path: Path to the file text for the BASE tree
133
135
        :param other_path: Path to the file text for the OTHER tree
134
136
        """
135
 
        self.add_suffix(this_path, ".THIS")
 
137
        self.add_suffix(this_path, ".THIS", fix_inventory=False)
136
138
        self.dump(base_lines, this_path+".BASE")
137
139
        self.dump(other_lines, this_path+".OTHER")
138
140
        rename(new_file, this_path)