1
3
from bzrlib.diff import _patch_header_date
6
from bzrlib.plugins.bzrtools.hunk_selector import (
10
from bzrlib.plugins.bzrtools.errors import NoColor
12
from bzrtools.hunk_selector import (
16
from bzrtools.errors import NoColor
19
7
class ShelfTests(bzrlib.tests.TestCaseWithTransport):
20
8
ORIGINAL = '\n\nhello test world\n\n'
21
9
MODIFIED = '\n\ngoodbye test world\n\n'
564
552
# Hex and is cracky, so it shouldn't work
565
553
stdout, error = self.run_bzr_captured(['unshelve', '0x00'], retcode=3)
566
554
self.assertTrue("Invalid patch name '0x00'" in error)
568
def test_color_hunk_selector(self):
569
"""Make sure NoColor is raised iff terminal.has_ansi_colors is False"""
570
hs = ShelveHunkSelector([])
571
hs = UnshelveHunkSelector([])
573
from bzrlib.plugins.bzrtools import terminal
575
from bzrtools import terminal
576
old_has_ansi_colors = terminal.has_ansi_colors
577
terminal.has_ansi_colors = lambda: False
579
self.assertRaises(NoColor, ShelveHunkSelector, [], True)
580
self.assertRaises(NoColor, UnshelveHunkSelector, [], True)
581
terminal.has_ansi_colors = lambda: True
582
hs = ShelveHunkSelector([], color=True)
583
hs = UnshelveHunkSelector([], color=True)
585
terminal.has_ansi_colors = old_has_ansi_colors
587
def test_no_color(self):
588
"""Ensure --no-color switch can be passed"""
589
self.tree = self.make_branch_and_tree('.')
593
self.tree.add(subdir)
596
self.__create_and_add_test_file()
598
# Modify the test file
599
# write in binary mode because on win32 line-endings should be LF
600
f = file('test_file', 'wb')
601
f.write(self.MODIFIED)
603
stdout, error = self.run_bzr_captured(['shelve', '--all',
605
stdout, error = self.run_bzr_captured(['unshelve', '--all',