~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.py

  • Committer: Martin Pool
  • Date: 2009-08-26 05:38:16 UTC
  • mfrom: (4634.6.2 2.0)
  • mto: (4634.6.4 2.0)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: mbp@sourcefrog.net-20090826053816-ht6jpktdm77vi6t5
MergeĀ 2.0

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