1
# Copyright (C) 2005, 2006, 2007, 2009 Canonical Ltd
1
# Copyright (C) 2006-2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
343
343
trunk = self.make_branch_and_tree('trunk')
345
345
u1 = trunk.branch.create_checkout('u1')
346
self.build_tree_contents([('u1/hosts', 'initial contents')])
346
self.build_tree_contents([('u1/hosts', 'initial contents\n')])
348
348
self.run_bzr('commit -m add-hosts u1')
350
350
u2 = trunk.branch.create_checkout('u2')
351
self.build_tree_contents([('u2/hosts', 'altered in u2')])
351
self.build_tree_contents([('u2/hosts', 'altered in u2\n')])
352
352
self.run_bzr('commit -m checkin-from-u2 u2')
354
354
# make an offline commits
355
self.build_tree_contents([('u1/hosts', 'first offline change in u1')])
355
self.build_tree_contents([('u1/hosts', 'first offline change in u1\n')])
356
356
self.run_bzr('commit -m checkin-offline --local u1')
358
358
# now try to pull in online work from u2, and then commit our offline
359
359
# work as a merge
360
360
# retcode 1 as we expect a text conflict
361
361
self.run_bzr('update u1', retcode=1)
362
self.assertFileEqual('''\
364
first offline change in u1
362
371
self.run_bzr('resolved u1/hosts')
363
372
# add a text change here to represent resolving the merge conflicts in
364
373
# favour of a new version of the file not identical to either the u1
669
678
def test_commit_hook_template(self):
670
679
# Test that commit template hooks work
671
def restoreDefaults():
672
msgeditor.hooks['commit_message_template'] = []
673
osutils.set_or_unset_env('BZR_EDITOR', default_editor)
674
680
if sys.platform == "win32":
675
681
f = file('fed.bat', 'w')
676
682
f.write('@rem dummy fed')
678
default_editor = osutils.set_or_unset_env('BZR_EDITOR', "fed.bat")
684
osutils.set_or_unset_env('BZR_EDITOR', "fed.bat")
680
686
f = file('fed.sh', 'wb')
681
687
f.write('#!/bin/sh\n')
683
689
os.chmod('fed.sh', 0755)
684
default_editor = osutils.set_or_unset_env('BZR_EDITOR', "./fed.sh")
685
self.addCleanup(restoreDefaults)
690
osutils.set_or_unset_env('BZR_EDITOR', "./fed.sh")
686
691
msgeditor.hooks.install_named_hook("commit_message_template",
687
692
lambda commit_obj, msg: "save me some typing\n", None)
688
693
tree = self.make_branch_and_tree('tree')