~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.py

  • Committer: James Westby
  • Date: 2009-03-12 08:26:35 UTC
  • mto: (4137.1.2 jamesw-integration)
  • mto: This revision was merged to the branch mainline in revision 4141.
  • Revision ID: james.westby@canonical.com-20090312082635-s0ofpsqb647kleru
Shelve can now shelve changes to a symlink's target.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
           ('rename', file_id, target_path, work_path)
62
62
           ('change kind', file_id, target_kind, work_kind, target_path)
63
63
           ('modify text', file_id)
 
64
           ('modify target', file_id, target_target, work_target)
64
65
        """
65
66
        for (file_id, paths, changed, versioned, parents, names, kind,
66
67
             executable) in self.iter_changes:
79
80
 
80
81
                if kind[0] != kind [1]:
81
82
                    yield ('change kind', file_id, kind[0], kind[1], paths[0])
 
83
                elif kind[0] == 'symlink':
 
84
                    t_target = self.target_tree.get_symlink_target(file_id)
 
85
                    w_target = self.work_tree.get_symlink_target(file_id)
 
86
                    yield ('modify target', file_id, paths[0], t_target,
 
87
                            w_target)
82
88
                elif changed:
83
89
                    yield ('modify text', file_id)
84
90
 
96
102
        shelf_parent = self.shelf_transform.trans_id_file_id(parents[1])
97
103
        self.shelf_transform.adjust_path(names[1], shelf_parent, s_trans_id)
98
104
 
 
105
    def shelve_modify_target(self, file_id):
 
106
        """Shelve a change of symlink target.
 
107
 
 
108
        :param file_id: The file id of the symlink which changed target.
 
109
        :param new_target: The target that the symlink should have due
 
110
            to shelving.
 
111
        """
 
112
        new_target = self.target_tree.get_symlink_target(file_id)
 
113
        w_trans_id = self.work_transform.trans_id_file_id(file_id)
 
114
        self.work_transform.delete_contents(w_trans_id)
 
115
        self.work_transform.create_symlink(new_target, w_trans_id)
 
116
 
 
117
        old_target = self.work_tree.get_symlink_target(file_id)
 
118
        s_trans_id = self.shelf_transform.trans_id_file_id(file_id)
 
119
        self.shelf_transform.delete_contents(s_trans_id)
 
120
        self.shelf_transform.create_symlink(old_target, s_trans_id)
 
121
 
99
122
    def shelve_lines(self, file_id, new_lines):
100
123
        """Shelve text changes to a file, using provided lines.
101
124