/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 bzrlib/shelf.py

  • Committer: John Arbash Meinel
  • Date: 2009-04-21 23:54:16 UTC
  • mto: (4300.1.7 groupcompress_info)
  • mto: This revision was merged to the branch mainline in revision 4301.
  • Revision ID: john@arbash-meinel.com-20090421235416-f0cz6ilf5cufbugi
Fix bug #364900, properly remove the 64kB that was just encoded in the copy.
Also, stop supporting None as a copy length in 'encode_copy_instruction'.
It was only used by the test suite, and it is good to pull that sort of thing out of
production code. (Besides, setting the copy to 64kB has the same effect.)

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,
 
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