/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/shelf.py

  • Committer: Jelmer Vernooij
  • Date: 2019-05-20 03:57:29 UTC
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190520035729-9rxvefxkvbbivygy
use default_user_agent function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        :param file_list: The files to make more similar to the target.
69
69
        """
70
70
        self.work_tree = work_tree
71
 
        self.work_transform = work_tree.get_transform()
 
71
        self.work_transform = transform.TreeTransform(work_tree)
72
72
        try:
73
73
            self.target_tree = target_tree
74
74
            self.shelf_transform = transform.TransformPreview(self.target_tree)
98
98
           ('modify text', file_id)
99
99
           ('modify target', file_id, target_target, work_target)
100
100
        """
101
 
        for change in self.iter_changes:
 
101
        for (file_id, paths, changed, versioned, parents, names, kind,
 
102
             executable) in self.iter_changes:
102
103
            # don't shelve add of tree root.  Working tree should never
103
104
            # lack roots, and bzr misbehaves when they do.
104
105
            # FIXME ADHB (2009-08-09): should still shelve adds of tree roots
105
106
            # when a tree root was deleted / renamed.
106
 
            if change.kind[0] is None and change.name[1] == '':
 
107
            if kind[0] is None and names[1] == '':
107
108
                continue
108
109
            # Also don't shelve deletion of tree root.
109
 
            if change.kind[1] is None and change.name[0] == '':
 
110
            if kind[1] is None and names[0] == '':
110
111
                continue
111
 
            if change.kind[0] is None or change.versioned[0] is False:
112
 
                self.creation[change.file_id] = (
113
 
                    change.kind[1], change.name[1], change.parent_id[1], change.versioned)
114
 
                yield ('add file', change.file_id, change.kind[1], change.path[1])
115
 
            elif change.kind[1] is None or change.versioned[0] is False:
116
 
                self.deletion[change.file_id] = (
117
 
                    change.kind[0], change.name[0], change.parent_id[0], change.versioned)
118
 
                yield ('delete file', change.file_id, change.kind[0], change.path[0])
 
112
            if kind[0] is None or versioned[0] is False:
 
113
                self.creation[file_id] = (kind[1], names[1], parents[1],
 
114
                                          versioned)
 
115
                yield ('add file', file_id, kind[1], paths[1])
 
116
            elif kind[1] is None or versioned[0] is False:
 
117
                self.deletion[file_id] = (kind[0], names[0], parents[0],
 
118
                                          versioned)
 
119
                yield ('delete file', file_id, kind[0], paths[0])
119
120
            else:
120
 
                if change.name[0] != change.name[1] or change.parent_id[0] != change.parent_id[1]:
121
 
                    self.renames[change.file_id] = (change.name, change.parent_id)
122
 
                    yield ('rename', change.file_id) + change.path
 
121
                if names[0] != names[1] or parents[0] != parents[1]:
 
122
                    self.renames[file_id] = (names, parents)
 
123
                    yield ('rename', file_id) + paths
123
124
 
124
 
                if change.kind[0] != change.kind[1]:
125
 
                    yield ('change kind', change.file_id, change.kind[0], change.kind[1], change.path[0])
126
 
                elif change.kind[0] == 'symlink':
127
 
                    t_target = self.target_tree.get_symlink_target(change.path[0])
128
 
                    w_target = self.work_tree.get_symlink_target(change.path[1])
129
 
                    yield ('modify target', change.file_id, change.path[0], t_target,
 
125
                if kind[0] != kind[1]:
 
126
                    yield ('change kind', file_id, kind[0], kind[1], paths[0])
 
127
                elif kind[0] == 'symlink':
 
128
                    t_target = self.target_tree.get_symlink_target(paths[0])
 
129
                    w_target = self.work_tree.get_symlink_target(paths[1])
 
130
                    yield ('modify target', file_id, paths[0], t_target,
130
131
                           w_target)
131
 
                elif change.changed_content:
132
 
                    yield ('modify text', change.file_id)
 
132
                elif changed:
 
133
                    yield ('modify text', file_id)
133
134
 
134
135
    def shelve_change(self, change):
135
136
        """Shelve a change in the iter_shelvable format."""
208
209
    def _content_from_tree(tt, tree, file_id):
209
210
        trans_id = tt.trans_id_file_id(file_id)
210
211
        tt.delete_contents(trans_id)
211
 
        transform.create_from_tree(tt, trans_id, tree, tree.id2path(file_id))
 
212
        transform.create_from_tree(tt, trans_id, tree, tree.id2path(file_id),
 
213
                                   file_id)
212
214
 
213
215
    def shelve_content_change(self, file_id):
214
216
        """Shelve a kind change or binary file content change.
266
268
                else:
267
269
                    transform.create_from_tree(
268
270
                        to_transform, s_trans_id, tree,
269
 
                        tree.id2path(file_id))
 
271
                        tree.id2path(file_id), file_id)
270
272
        if version:
271
273
            to_transform.version_file(file_id, s_trans_id)
272
274