95
93
tree3.commit('Feature Y, based on initial X work.',
96
94
timestamp=1233285960, timezone=0)
97
95
tree.merge_from_branch(tree2.branch)
98
tree.merge_from_branch(tree3.branch, force=True)
96
tree.merge_from_branch(tree3.branch)
101
99
def test_commit_template_pending_merges(self):
237
235
self.assertRaises((IOError, OSError), msgeditor.edit_commit_message, '')
239
237
def test__get_editor(self):
240
os.environ['BZR_EDITOR'] = 'bzr_editor'
241
os.environ['VISUAL'] = 'visual'
242
os.environ['EDITOR'] = 'editor'
244
conf = config.GlobalConfig.from_string('editor = config_editor\n',
247
editors = list(msgeditor._get_editor())
248
editors = [editor for (editor, cfg_src) in editors]
250
self.assertEqual(['bzr_editor', 'config_editor', 'visual', 'editor'],
253
if sys.platform == 'win32':
254
self.assertEqual(['wordpad.exe', 'notepad.exe'], editors[4:])
256
self.assertEqual(['/usr/bin/editor', 'vi', 'pico', 'nano', 'joe'],
238
# Test that _get_editor can return a decent list of items
239
bzr_editor = os.environ.get('BZR_EDITOR')
240
visual = os.environ.get('VISUAL')
241
editor = os.environ.get('EDITOR')
243
os.environ['BZR_EDITOR'] = 'bzr_editor'
244
os.environ['VISUAL'] = 'visual'
245
os.environ['EDITOR'] = 'editor'
247
ensure_config_dir_exists()
248
f = open(config_filename(), 'wb')
249
f.write('editor = config_editor\n')
252
editors = list(msgeditor._get_editor())
253
editors = [editor for (editor, cfg_src) in editors]
255
self.assertEqual(['bzr_editor', 'config_editor', 'visual',
256
'editor'], editors[:4])
258
if sys.platform == 'win32':
259
self.assertEqual(['wordpad.exe', 'notepad.exe'], editors[4:])
261
self.assertEqual(['/usr/bin/editor', 'vi', 'pico', 'nano',
265
# Restore the environment
266
if bzr_editor is None:
267
del os.environ['BZR_EDITOR']
269
os.environ['BZR_EDITOR'] = bzr_editor
271
del os.environ['VISUAL']
273
os.environ['VISUAL'] = visual
275
del os.environ['EDITOR']
277
os.environ['EDITOR'] = editor
260
279
def test__run_editor_EACCES(self):
261
280
"""If running a configured editor raises EACESS, the user is warned."""
340
356
msgeditor.generate_commit_message_template(commit_obj))
342
358
def test_generate_commit_message_template_hook(self):
359
def restoreDefaults():
360
msgeditor.hooks['commit_message_template'] = []
361
self.addCleanup(restoreDefaults)
343
362
msgeditor.hooks.install_named_hook("commit_message_template",
344
363
lambda commit_obj, msg: "save me some typing\n", None)
345
364
commit_obj = commit.Commit()
346
365
self.assertEquals("save me some typing\n",
347
366
msgeditor.generate_commit_message_template(commit_obj))
350
# GZ 2009-11-17: This wants moving to osutils when the errno checking code is
351
class TestPlatformErrnoWorkarounds(TestCaseInTempDir):
352
"""Ensuring workarounds enshrined in code actually serve a purpose"""
354
def test_subprocess_call_bad_file(self):
355
if sys.platform != "win32":
356
raise TestNotApplicable("Workarounds for windows only")
357
import subprocess, errno
358
ERROR_BAD_EXE_FORMAT = 193
359
file("textfile.txt", "w").close()
360
e = self.assertRaises(WindowsError, subprocess.call, "textfile.txt")
361
# Python2.4 used the 'winerror' as the errno, which confuses a lot of
362
# our error trapping code. Make sure that we understand the mapping
364
if sys.version_info >= (2, 5):
365
self.assertEqual(e.errno, errno.ENOEXEC)
366
self.assertEqual(e.winerror, ERROR_BAD_EXE_FORMAT)
368
self.assertEqual(e.errno, ERROR_BAD_EXE_FORMAT)