/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 breezy/tests/blackbox/test_shelve.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-09-22 02:38:35 UTC
  • mfrom: (7058.5.4 upload-symlin)
  • Revision ID: breezy.the.bot@gmail.com-20180922023835-wb9nczxp63jpeudb
Add symlink support to 'brz upload'.

Merged from https://code.launchpad.net/~jelmer/brz/upload-symlinks/+merge/355061

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import os
18
18
 
19
 
from bzrlib import shelf
20
 
from bzrlib.tests import TestCaseWithTransport
21
 
from bzrlib.tests.script import ScriptRunner
 
19
from breezy import shelf
 
20
from breezy.tests import TestCaseWithTransport
 
21
from breezy.tests.script import ScriptRunner
22
22
 
23
23
 
24
24
class TestShelveList(TestCaseWithTransport):
41
41
        self.assertEqual('', err)
42
42
        self.assertEqual('  1: Foo\n', out)
43
43
 
 
44
    def test_shelve_list_via_directory(self):
 
45
        tree = self.make_branch_and_tree('tree')
 
46
        creator = self.make_creator(tree)
 
47
        shelf_id = tree.get_shelf_manager().shelve_changes(creator, 'Foo')
 
48
        out, err = self.run_bzr('shelve -d tree --list', retcode=1)
 
49
        self.assertEqual('', err)
 
50
        self.assertEqual('  1: Foo\n', out)
 
51
 
44
52
    def test_shelve_no_message(self):
45
53
        tree = self.make_branch_and_tree('.')
46
54
        creator = self.make_creator(tree)
64
72
        self.build_tree(['file'])
65
73
        tree.add('file')
66
74
        self.run_bzr('shelve --all --destroy')
67
 
        self.failIfExists('file')
 
75
        self.assertPathDoesNotExist('file')
68
76
        self.assertIs(None, tree.get_shelf_manager().last_shelf())
69
77
 
70
78
    def test_unshelve_keep(self):
71
 
        # https://bugs.edge.launchpad.net/bzr/+bug/492091
 
79
        # https://bugs.launchpad.net/bzr/+bug/492091
72
80
        tree = self.make_branch_and_tree('.')
73
81
        # shelve apparently unhappy working with a tree with no root yet
74
82
        tree.commit('make root')
76
84
 
77
85
        sr = ScriptRunner()
78
86
        sr.run_script(self, '''
79
 
$ bzr add file
80
 
$ bzr shelve --all -m Foo
81
 
$ bzr shelve --list
 
87
$ brz add file
 
88
adding file
 
89
$ brz shelve --all -m Foo
 
90
2>Selected changes:
 
91
2>-D  file
 
92
2>Changes shelved with id "1".
 
93
$ brz shelve --list
82
94
  1: Foo
83
 
$ bzr unshelve --keep
84
 
$ bzr shelve --list
 
95
$ brz unshelve --keep
 
96
2>Using changes with id "1".
 
97
2>Message: Foo
 
98
2>+N  file
 
99
2>All changes applied successfully.
 
100
$ brz shelve --list
85
101
  1: Foo
86
102
$ cat file
87
103
contents of file
88
104
''')
89
105
 
90
106
 
 
107
class TestUnshelvePreview(TestCaseWithTransport):
 
108
 
 
109
    def test_non_ascii(self):
 
110
        """Test that we can show a non-ascii diff that would result from unshelving"""
 
111
 
 
112
        init_content = u'Initial: \u0418\u0437\u043d\u0430\u0447\n'.encode('utf-8')
 
113
        more_content = u'More: \u0415\u0449\u0451\n'.encode('utf-8')
 
114
        next_content = init_content + more_content
 
115
        diff_part = b'@@ -1,1 +1,2 @@\n %s+%s' % (init_content, more_content)
 
116
 
 
117
        tree = self.make_branch_and_tree('.')
 
118
        self.build_tree_contents([('a_file', init_content)])
 
119
        tree.add('a_file')
 
120
        tree.commit(message='committed')
 
121
        self.build_tree_contents([('a_file', next_content)])
 
122
        self.run_bzr(['shelve', '--all'])
 
123
        out, err = self.run_bzr_raw(['unshelve', '--preview'], encoding='latin-1')
 
124
 
 
125
        self.assertContainsString(out, diff_part)
 
126
 
91
127
 
92
128
class TestShelveRelpath(TestCaseWithTransport):
93
129
 
97
133
        tree.add('file')
98
134
        os.chdir('tree/dir')
99
135
        self.run_bzr('shelve --all ../file')
 
136
 
 
137
    def test_shelve_via_directory(self):
 
138
        tree = self.make_branch_and_tree('tree')
 
139
        self.build_tree(['tree/file', 'tree/dir/'])
 
140
        tree.add('file')
 
141
        self.run_bzr('shelve -d tree/dir --all ../file')
 
142
 
 
143
 
 
144
class TestShelveUnshelve(TestCaseWithTransport):
 
145
 
 
146
    def test_directory(self):
 
147
        """Test --directory option"""
 
148
        tree = self.make_branch_and_tree('tree')
 
149
        self.build_tree_contents([('tree/a', b'initial\n')])
 
150
        tree.add('a')
 
151
        tree.commit(message='committed')
 
152
        self.build_tree_contents([('tree/a', b'initial\nmore\n')])
 
153
        self.run_bzr('shelve -d tree --all')
 
154
        self.assertFileEqual(b'initial\n', 'tree/a')
 
155
        self.run_bzr('unshelve --directory tree')
 
156
        self.assertFileEqual(b'initial\nmore\n', 'tree/a')