93
95
tree3.commit('Feature Y, based on initial X work.',
94
96
timestamp=1233285960, timezone=0)
95
97
tree.merge_from_branch(tree2.branch)
96
tree.merge_from_branch(tree3.branch)
98
tree.merge_from_branch(tree3.branch, force=True)
99
101
def test_commit_template_pending_merges(self):
235
237
self.assertRaises((IOError, OSError), msgeditor.edit_commit_message, '')
237
239
def test__get_editor(self):
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
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'],
279
260
def test__run_editor_EACCES(self):
280
261
"""If running a configured editor raises EACESS, the user is warned."""
317
301
def test__create_temp_file_with_commit_template_in_unicode_dir(self):
318
302
self.requireFeature(tests.UnicodeFilenameFeature)
319
303
if hasattr(self, 'info'):
320
os.mkdir(self.info['directory'])
321
os.chdir(self.info['directory'])
322
msgeditor._create_temp_file_with_commit_template('infotext')
304
tmpdir = self.info['directory']
306
# Force the creation of temp file in a directory whose name
307
# requires some encoding support
308
msgeditor._create_temp_file_with_commit_template('infotext',
324
311
raise TestNotApplicable('Test run elsewhere with non-ascii data.')
356
343
msgeditor.generate_commit_message_template(commit_obj))
358
345
def test_generate_commit_message_template_hook(self):
359
def restoreDefaults():
360
msgeditor.hooks['commit_message_template'] = []
361
self.addCleanup(restoreDefaults)
362
346
msgeditor.hooks.install_named_hook("commit_message_template",
363
347
lambda commit_obj, msg: "save me some typing\n", None)
364
348
commit_obj = commit.Commit()
365
349
self.assertEquals("save me some typing\n",
366
350
msgeditor.generate_commit_message_template(commit_obj))
353
# GZ 2009-11-17: This wants moving to osutils when the errno checking code is
354
class TestPlatformErrnoWorkarounds(TestCaseInTempDir):
355
"""Ensuring workarounds enshrined in code actually serve a purpose"""
357
def test_subprocess_call_bad_file(self):
358
if sys.platform != "win32":
359
raise TestNotApplicable("Workarounds for windows only")
360
import subprocess, errno
361
ERROR_BAD_EXE_FORMAT = 193
362
file("textfile.txt", "w").close()
363
e = self.assertRaises(WindowsError, subprocess.call, "textfile.txt")
364
# Python2.4 used the 'winerror' as the errno, which confuses a lot of
365
# our error trapping code. Make sure that we understand the mapping
367
if sys.version_info >= (2, 5):
368
self.assertEqual(e.errno, errno.ENOEXEC)
369
self.assertEqual(e.winerror, ERROR_BAD_EXE_FORMAT)
371
self.assertEqual(e.errno, ERROR_BAD_EXE_FORMAT)