~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_shelve.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-24 13:14:06 UTC
  • mto: (6445.4.5 nested-trees-spec)
  • mto: This revision was merged to the branch mainline in revision 6518.
  • Revision ID: jelmer@samba.org-20120124131406-wedftkorbpv37bm0
Import nested tree doc from devnotes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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):
77
85
        sr = ScriptRunner()
78
86
        sr.run_script(self, '''
79
87
$ bzr add file
 
88
adding file
80
89
$ bzr shelve --all -m Foo
 
90
2>Selected changes:
 
91
2>-D  file
 
92
2>Changes shelved with id "1".
81
93
$ bzr shelve --list
82
94
  1: Foo
83
95
$ bzr unshelve --keep
 
96
2>Using changes with id "1".
 
97
2>Message: Foo
 
98
2>+N  file
 
99
2>All changes applied successfully.
84
100
$ bzr shelve --list
85
101
  1: Foo
86
102
$ cat file
87
103
contents of file
88
104
''')
89
105
 
 
106
class TestUnshelvePreview(TestCaseWithTransport):
 
107
    
 
108
    def test_non_ascii(self):
 
109
        """Test that we can show a non-ascii diff that would result from unshelving"""
 
110
        
 
111
        init_content = u'Initial: \u0418\u0437\u043d\u0430\u0447\n'.encode('utf-8')
 
112
        more_content = u'More: \u0415\u0449\u0451\n'.encode('utf-8')
 
113
        next_content = init_content + more_content
 
114
        diff_part = '@@ -1,1 +1,2 @@\n %s+%s' % (init_content, more_content)
 
115
        
 
116
        tree = self.make_branch_and_tree('.')
 
117
        self.build_tree_contents([('a_file', init_content)])
 
118
        tree.add('a_file')
 
119
        tree.commit(message='committed')
 
120
        self.build_tree_contents([('a_file', next_content)])
 
121
        self.run_bzr(['shelve', '--all'])
 
122
        out, err = self.run_bzr(['unshelve', '--preview'], encoding='latin-1')
 
123
        
 
124
        self.assertContainsString(out, diff_part)
90
125
 
91
126
 
92
127
class TestShelveRelpath(TestCaseWithTransport):
98
133
        os.chdir('tree/dir')
99
134
        self.run_bzr('shelve --all ../file')
100
135
 
 
136
    def test_shelve_via_directory(self):
 
137
        tree = self.make_branch_and_tree('tree')
 
138
        self.build_tree(['tree/file', 'tree/dir/'])
 
139
        tree.add('file')
 
140
        self.run_bzr('shelve -d tree/dir --all ../file')
 
141
 
101
142
 
102
143
class TestShelveUnshelve(TestCaseWithTransport):
103
144