/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: Vincent Ladeuil
  • Date: 2009-04-11 16:06:53 UTC
  • mto: (4286.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4287.
  • Revision ID: v.ladeuil+lp@free.fr-20090411160653-eq1gfn41q3lzhmss
Cleanup test imports and use features to better track skipped tests.

* bzrlib/tests/workingtree_implementations/__init__.py: 
Fix imports. Delete obsolete comment.

* bzrlib/tests/tree_implementations/test_walkdirs.py:
(TestWalkdirs.get_all_subdirs_expected): Reduce duplication.

* bzrlib/tests/tree_implementations/test_test_trees.py: 
Fix import.

* bzrlib/tests/tree_implementations/test_path_content_summary.py: 
Fix imports.

(TestPathContentSummary.test_unicode_symlink_content_summary,
TestPathContentSummary.test_unicode_symlink_target_summary):Use
UnicodeFilenameFeature instead of try/except UnicodeError.

* bzrlib/tests/tree_implementations/test_inv.py: 
Fix imports.
(TestInventoryWithSymlinks): Factor out test that requires
symlinks and use _test_needs_features.
(TestInventory.test_canonical_path,
TestInventory.test_canonical_path_dir,
TestInventory.test_canonical_path_root,
TestInventory.test_canonical_path_invalid_all,
TestInventory.test_canonical_invalid_child): Use assert(expected,
actual)

* bzrlib/tests/tree_implementations/test_get_symlink_target.py: 
Fix imports.
(TestGetSymlinkTarget.test_get_unicode_symlink_target): Use
UnicodeFilenameFeature instead of try/except UnicodeError.

* bzrlib/tests/tree_implementations/__init__.py: 
Fix imports.

(TestCaseWithTree.get_tree_with_subdirs_and_all_supported_content_types,
TestCaseWithTree._create_tree_with_utf8): Use
UnicodeFilenameFeature instead of try/except UnicodeError.

* bzrlib/tests/test_workingtree_4.py:
Fix too long lines.

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