~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branchbuilder.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-23 02:35:09 UTC
  • mto: (3514.4.17 merge_lca_multi)
  • mto: This revision was merged to the branch mainline in revision 3748.
  • Revision ID: john@arbash-meinel.com-20080723023509-1t4wkw5wjif7h72i
Implement rename_one on MemoryTree, and expose that in the Branch Builder

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
            to_add_kinds = []
143
143
            new_contents = {}
144
144
            to_unversion_ids = []
145
 
            # TODO: MemoryTree doesn't support rename() or
146
 
            #       apply_inventory_delta, so we'll postpone allowing renames
147
 
            #       for now
148
 
            # to_rename = []
 
145
            to_rename = []
149
146
            for action, info in actions:
150
147
                if action == 'add':
151
148
                    path, file_id, kind, content = info
162
159
                    new_contents[file_id] = content
163
160
                elif action == 'unversion':
164
161
                    to_unversion_ids.append(info)
 
162
                elif action == 'rename':
 
163
                    from_relpath, to_relpath = info
 
164
                    to_rename.append((from_relpath, to_relpath))
165
165
                else:
166
166
                    raise errors.UnknownBuildAction(action)
167
167
            if to_unversion_ids:
172
172
                    tree.add([path], [file_id], ['directory'])
173
173
                else:
174
174
                    tree.mkdir(path, file_id)
 
175
            for from_relpath, to_relpath in to_rename:
 
176
                tree.rename_one(from_relpath, to_relpath)
175
177
            tree.add(to_add_files, to_add_file_ids, to_add_kinds)
176
178
            for file_id, content in new_contents.iteritems():
177
179
                tree.put_file_bytes_non_atomic(file_id, content)