~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-06 06:48:25 UTC
  • mfrom: (4070.8.6 debug-config)
  • Revision ID: pqm@pqm.ubuntu.com-20090306064825-kbpwggw21dygeix6
(mbp) debug_flags configuration option

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
import errno
43
43
        """
44
44
        self.work_tree = work_tree
45
45
        self.work_transform = transform.TreeTransform(work_tree)
46
 
        try:
47
 
            self.target_tree = target_tree
48
 
            self.shelf_transform = transform.TransformPreview(self.target_tree)
49
 
            try:
50
 
                self.renames = {}
51
 
                self.creation = {}
52
 
                self.deletion = {}
53
 
                self.iter_changes = work_tree.iter_changes(
54
 
                    self.target_tree, specific_files=file_list)
55
 
            except:
56
 
                self.shelf_transform.finalize()
57
 
                raise
58
 
        except:
59
 
            self.work_transform.finalize()
60
 
            raise
 
46
        self.target_tree = target_tree
 
47
        self.shelf_transform = transform.TransformPreview(self.target_tree)
 
48
        self.renames = {}
 
49
        self.creation = {}
 
50
        self.deletion = {}
 
51
        self.iter_changes = work_tree.iter_changes(self.target_tree,
 
52
                                                   specific_files=file_list)
61
53
 
62
54
    def iter_shelvable(self):
63
55
        """Iterable of tuples describing shelvable changes.
69
61
           ('rename', file_id, target_path, work_path)
70
62
           ('change kind', file_id, target_kind, work_kind, target_path)
71
63
           ('modify text', file_id)
72
 
           ('modify target', file_id, target_target, work_target)
73
64
        """
74
65
        for (file_id, paths, changed, versioned, parents, names, kind,
75
66
             executable) in self.iter_changes:
88
79
 
89
80
                if kind[0] != kind [1]:
90
81
                    yield ('change kind', file_id, kind[0], kind[1], paths[0])
91
 
                elif kind[0] == 'symlink':
92
 
                    t_target = self.target_tree.get_symlink_target(file_id)
93
 
                    w_target = self.work_tree.get_symlink_target(file_id)
94
 
                    yield ('modify target', file_id, paths[0], t_target,
95
 
                            w_target)
96
82
                elif changed:
97
83
                    yield ('modify text', file_id)
98
84
 
110
96
        shelf_parent = self.shelf_transform.trans_id_file_id(parents[1])
111
97
        self.shelf_transform.adjust_path(names[1], shelf_parent, s_trans_id)
112
98
 
113
 
    def shelve_modify_target(self, file_id):
114
 
        """Shelve a change of symlink target.
115
 
 
116
 
        :param file_id: The file id of the symlink which changed target.
117
 
        :param new_target: The target that the symlink should have due
118
 
            to shelving.
119
 
        """
120
 
        new_target = self.target_tree.get_symlink_target(file_id)
121
 
        w_trans_id = self.work_transform.trans_id_file_id(file_id)
122
 
        self.work_transform.delete_contents(w_trans_id)
123
 
        self.work_transform.create_symlink(new_target, w_trans_id)
124
 
 
125
 
        old_target = self.work_tree.get_symlink_target(file_id)
126
 
        s_trans_id = self.shelf_transform.trans_id_file_id(file_id)
127
 
        self.shelf_transform.delete_contents(s_trans_id)
128
 
        self.shelf_transform.create_symlink(old_target, s_trans_id)
129
 
 
130
99
    def shelve_lines(self, file_id, new_lines):
131
100
        """Shelve text changes to a file, using provided lines.
132
101
 
295
264
        tt.deserialize(records)
296
265
        return klass(tree, base_tree, tt, metadata.get('message'))
297
266
 
298
 
    def make_merger(self, task=None):
 
267
    def make_merger(self):
299
268
        """Return a merger that can unshelve the changes."""
300
 
        target_tree = self.transform.get_preview_tree()
301
 
        merger = merge.Merger.from_uncommitted(self.tree, target_tree,
302
 
            task, self.base_tree)
303
 
        merger.merge_type = merge.Merge3Merger
304
 
        return merger
 
269
        pb = ui.ui_factory.nested_progress_bar()
 
270
        try:
 
271
            target_tree = self.transform.get_preview_tree()
 
272
            merger = merge.Merger.from_uncommitted(self.tree, target_tree, pb,
 
273
                                                   self.base_tree)
 
274
            merger.merge_type = merge.Merge3Merger
 
275
            return merger
 
276
        finally:
 
277
            pb.finished()
305
278
 
306
279
    def finalize(self):
307
280
        """Release all resources held by this Unshelver."""