~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-17 07:05:37 UTC
  • mfrom: (4152.1.2 branch.stacked.streams)
  • Revision ID: pqm@pqm.ubuntu.com-20090317070537-zaud24vjs2szna87
(robertc) Add client-side streaming from stacked branches (over
        bzr:// protocols) when the sort order is compatible with doing
        that. (Robert Collins, Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
import errno
19
19
import re
20
20
 
21
21
from bzrlib import (
22
 
    bencode,
23
22
    errors,
24
23
    merge,
25
24
    merge3,
 
25
    osutils,
26
26
    pack,
27
27
    transform,
 
28
    ui,
 
29
    workingtree,
28
30
)
 
31
from bzrlib.util import bencode
29
32
 
30
33
 
31
34
class ShelfCreator(object):
34
37
    def __init__(self, work_tree, target_tree, file_list=None):
35
38
        """Constructor.
36
39
 
37
 
        :param work_tree: The working tree to apply changes to. This is not
38
 
            required to be locked - a tree_write lock will be taken out.
 
40
        :param work_tree: The working tree to apply changes to
39
41
        :param target_tree: The tree to make the working tree more similar to.
40
 
            This is not required to be locked - a read_lock will be taken out.
41
42
        :param file_list: The files to make more similar to the target.
42
43
        """
43
44
        self.work_tree = work_tree
72
73
        """
73
74
        for (file_id, paths, changed, versioned, parents, names, kind,
74
75
             executable) in self.iter_changes:
75
 
            # don't shelve add of tree root.  Working tree should never
76
 
            # lack roots, and bzr misbehaves when they do.
77
 
            # FIXME ADHB (2009-08-09): should still shelve adds of tree roots
78
 
            # when a tree root was deleted / renamed.
79
 
            if kind[0] is None and names[1] == '':
80
 
                continue
81
76
            if kind[0] is None or versioned[0] == False:
82
77
                self.creation[file_id] = (kind[1], names[1], parents[1],
83
78
                                          versioned)
101
96
                elif changed:
102
97
                    yield ('modify text', file_id)
103
98
 
104
 
    def shelve_change(self, change):
105
 
        """Shelve a change in the iter_shelvable format."""
106
 
        if change[0] == 'rename':
107
 
            self.shelve_rename(change[1])
108
 
        elif change[0] == 'delete file':
109
 
            self.shelve_deletion(change[1])
110
 
        elif change[0] == 'add file':
111
 
            self.shelve_creation(change[1])
112
 
        elif change[0] in ('change kind', 'modify text'):
113
 
            self.shelve_content_change(change[1])
114
 
        elif change[0] == 'modify target':
115
 
            self.shelve_modify_target(change[1])
116
 
        else:
117
 
            raise ValueError('Unknown change kind: "%s"' % change[0])
118
 
 
119
 
    def shelve_all(self):
120
 
        """Shelve all changes."""
121
 
        for change in self.iter_shelvable():
122
 
            self.shelve_change(change)
123
 
 
124
99
    def shelve_rename(self, file_id):
125
100
        """Shelve a file rename.
126
101