~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.py

  • Committer: Vincent Ladeuil
  • Date: 2010-04-23 08:51:52 UTC
  • mfrom: (5131.2.6 support_OO_flag)
  • mto: This revision was merged to the branch mainline in revision 5179.
  • Revision ID: v.ladeuil+lp@free.fr-20100423085152-uoewc1vnkwqhw0pj
Manually assign docstrings to command objects, so that they work with python -OO

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,
22
23
    errors,
23
24
    merge,
24
25
    merge3,
28
29
    ui,
29
30
    workingtree,
30
31
)
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
 
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)
96
104
                elif changed:
97
105
                    yield ('modify text', file_id)
98
106
 
 
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
 
99
127
    def shelve_rename(self, file_id):
100
128
        """Shelve a file rename.
101
129