1
# Copyright (C) 2008 Aaron Bentley <aaron@aaronbentley.com>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from bzrlib import transform
21
class ShelfCreator(object):
23
def __init__(self, work_tree):
24
self.work_tree = work_tree
25
self.work_transform = transform.TreeTransform(work_tree)
26
self.base_tree = work_tree.basis_tree()
27
self.shelf_transform = transform.TransformPreview(self.base_tree)
29
self.iter_changes = work_tree.iter_changes(self.base_tree)
32
for (file_id, paths, changed, versioned, parents, names, kind,
33
executable) in self.iter_changes:
34
if names[0] != names[1] or parents[0] != parents[1]:
35
self.renames[file_id] = (names, parents)
36
yield ('rename', file_id) + paths
38
def shelve_rename(self, file_id):
39
names, parents = self.renames[file_id]
40
w_trans_id = self.work_transform.trans_id_file_id(file_id)
41
work_parent = self.work_transform.trans_id_file_id(parents[0])
42
self.work_transform.adjust_path(names[0], work_parent, w_trans_id)
44
s_trans_id = self.shelf_transform.trans_id_file_id(file_id)
45
shelf_parent = self.shelf_transform.trans_id_file_id(parents[1])
46
self.shelf_transform.adjust_path(names[1], shelf_parent, s_trans_id)
49
self.work_transform.finalize()
50
self.shelf_transform.finalize()