~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    def __init__(self, work_tree, target_tree, file_list=None):
38
38
        """Constructor.
39
39
 
40
 
        :param work_tree: The working tree to apply changes to
 
40
        :param work_tree: The working tree to apply changes to. This is not
 
41
            required to be locked - a tree_write lock will be taken out.
41
42
        :param target_tree: The tree to make the working tree more similar to.
 
43
            This is not required to be locked - a read_lock will be taken out.
42
44
        :param file_list: The files to make more similar to the target.
43
45
        """
44
46
        self.work_tree = work_tree
73
75
        """
74
76
        for (file_id, paths, changed, versioned, parents, names, kind,
75
77
             executable) in self.iter_changes:
 
78
            # don't shelve add of tree root.  Working tree should never
 
79
            # lack roots, and bzr misbehaves when they do.
 
80
            # FIXME ADHB (2009-08-09): should still shelve adds of tree roots
 
81
            # when a tree root was deleted / renamed.
 
82
            if kind[0] is None and names[1] == '':
 
83
                continue
76
84
            if kind[0] is None or versioned[0] == False:
77
85
                self.creation[file_id] = (kind[1], names[1], parents[1],
78
86
                                          versioned)
104
112
            self.shelve_deletion(change[1])
105
113
        elif change[0] == 'add file':
106
114
            self.shelve_creation(change[1])
107
 
        elif change[0] == 'change kind':
 
115
        elif change[0] in ('change kind', 'modify text'):
108
116
            self.shelve_content_change(change[1])
109
117
        elif change[0] == 'modify target':
110
118
            self.shelve_modify_target(change[1])
111
119
        else:
112
120
            raise ValueError('Unknown change kind: "%s"' % change[0])
113
121
 
 
122
    def shelve_all(self):
 
123
        """Shelve all changes."""
 
124
        for change in self.iter_shelvable():
 
125
            self.shelve_change(change)
 
126
 
114
127
    def shelve_rename(self, file_id):
115
128
        """Shelve a file rename.
116
129