~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.py

  • Committer: Robert Collins
  • Date: 2009-05-11 01:59:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4593.
  • Revision ID: robertc@robertcollins.net-20090511015906-6zi6a9b8tuuhipc8
Less lock thrashing in check.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import re
20
20
 
21
21
from bzrlib import (
22
 
    bencode,
23
22
    errors,
24
23
    merge,
25
24
    merge3,
29
28
    ui,
30
29
    workingtree,
31
30
)
 
31
from bzrlib.util import bencode
32
32
 
33
33
 
34
34
class ShelfCreator(object):
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. This is not
41
 
            required to be locked - a tree_write lock will be taken out.
 
40
        :param work_tree: The working tree to apply changes to
42
41
        :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.
44
42
        :param file_list: The files to make more similar to the target.
45
43
        """
46
44
        self.work_tree = work_tree
75
73
        """
76
74
        for (file_id, paths, changed, versioned, parents, names, kind,
77
75
             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
84
76
            if kind[0] is None or versioned[0] == False:
85
77
                self.creation[file_id] = (kind[1], names[1], parents[1],
86
78
                                          versioned)
104
96
                elif changed:
105
97
                    yield ('modify text', file_id)
106
98
 
107
 
    def shelve_change(self, change):
108
 
        """Shelve a change in the iter_shelvable format."""
109
 
        if change[0] == 'rename':
110
 
            self.shelve_rename(change[1])
111
 
        elif change[0] == 'delete file':
112
 
            self.shelve_deletion(change[1])
113
 
        elif change[0] == 'add file':
114
 
            self.shelve_creation(change[1])
115
 
        elif change[0] in ('change kind', 'modify text'):
116
 
            self.shelve_content_change(change[1])
117
 
        elif change[0] == 'modify target':
118
 
            self.shelve_modify_target(change[1])
119
 
        else:
120
 
            raise ValueError('Unknown change kind: "%s"' % change[0])
121
 
 
122
 
    def shelve_all(self):
123
 
        """Shelve all changes."""
124
 
        for change in self.iter_shelvable():
125
 
            self.shelve_change(change)
126
 
 
127
99
    def shelve_rename(self, file_id):
128
100
        """Shelve a file rename.
129
101