~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf_ui.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
from cStringIO import StringIO
25
25
class ExpectShelver(shelf_ui.Shelver):
26
26
    """A variant of Shelver that intercepts console activity, for testing."""
27
27
 
28
 
    def __init__(self, work_tree, target_tree, diff_writer=None, path=None,
29
 
                 auto=False, auto_apply=False, file_list=None, message=None):
 
28
    def __init__(self, work_tree, target_tree, diff_writer=None,
 
29
                 auto=False, auto_apply=False, file_list=None, message=None,
 
30
                 destroy=False):
30
31
        shelf_ui.Shelver.__init__(self, work_tree, target_tree, diff_writer,
31
 
                                  auto, auto_apply, file_list, message)
 
32
                                  auto, auto_apply, file_list, message,
 
33
                                  destroy)
32
34
        self.expected = []
33
35
        self.diff_writer = StringIO()
34
36
 
162
164
                       'y')
163
165
        shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
164
166
 
 
167
    def test_shelve_modify_target(self):
 
168
        tree = self.create_shelvable_tree()
 
169
        os.symlink('bar', 'tree/baz')
 
170
        tree.add('baz', 'baz-id')
 
171
        tree.commit("Add symlink")
 
172
        os.unlink('tree/baz')
 
173
        os.symlink('vax', 'tree/baz')
 
174
        shelver = ExpectShelver(tree, tree.basis_tree())
 
175
        shelver.expect('Shelve changing target of "baz" from "bar" to '
 
176
                '"vax"? [yNfq?]', 'y')
 
177
        shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
 
178
        shelver.run()
 
179
        self.assertEqual('bar', os.readlink('tree/baz'))
 
180
 
165
181
    def test_shelve_finish(self):
166
182
        tree = self.create_shelvable_tree()
167
183
        shelver = ExpectShelver(tree, tree.basis_tree())
199
215
        shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y')
200
216
        shelver.run()
201
217
 
 
218
    def test_shelve_distroy(self):
 
219
        tree = self.create_shelvable_tree()
 
220
        shelver = shelf_ui.Shelver.from_args(sys.stdout, all=True,
 
221
                                             directory='tree', destroy=True)
 
222
        shelver.run()
 
223
        self.assertIs(None, tree.get_shelf_manager().last_shelf())
 
224
        self.assertFileEqual(LINES_AJ, 'tree/foo')
 
225
 
202
226
 
203
227
class TestUnshelver(tests.TestCaseWithTransport):
204
228