28
29
revision as _mod_revision,
33
34
from bzrlib.bzrdir import BzrDir
34
from bzrlib.conflicts import (
35
from bzrlib.conflicts import (DuplicateEntry, DuplicateID, MissingParent,
36
UnversionedParent, ParentLoop, DeletingParent,
43
38
from bzrlib.diff import show_diff_trees
44
from bzrlib.errors import (
47
ExistingPendingDeletion,
49
ImmortalPendingDeletion,
55
from bzrlib.osutils import (
39
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
40
ReusingTransform, CantMoveRoot,
41
PathsNotVersionedError, ExistingLimbo,
42
ExistingPendingDeletion, ImmortalLimbo,
43
ImmortalPendingDeletion, LockError)
44
from bzrlib.osutils import file_kind, pathjoin
59
45
from bzrlib.merge import Merge3Merger, Merger
60
46
from bzrlib.tests import (
67
from bzrlib.transform import (
53
from bzrlib.transform import (TreeTransform, ROOT_PARENT, FinalPaths,
54
resolve_conflicts, cook_conflicts,
55
build_tree, get_backup_name,
56
_FileMover, resolve_checkout,
57
TransformPreview, create_from_tree)
82
60
class TestTreeTransform(tests.TestCaseWithTransport):
852
830
rename.set_executability(True, myfile)
855
def test_rename_fails(self):
856
# see https://bugs.launchpad.net/bzr/+bug/491763
857
create, root_id = self.get_transform()
858
first_dir = create.new_directory('first-dir', root_id, 'first-id')
859
myfile = create.new_file('myfile', root_id, 'myfile-text',
862
if os.name == "posix" and sys.platform != "cygwin":
863
# posix filesystems fail on renaming if the readonly bit is set
864
osutils.make_readonly(self.wt.abspath('first-dir'))
865
elif os.name == "nt":
866
# windows filesystems fail on renaming open files
867
self.addCleanup(file(self.wt.abspath('myfile')).close)
869
self.skip("Don't know how to force a permissions error on rename")
870
# now transform to rename
871
rename_transform, root_id = self.get_transform()
872
file_trans_id = rename_transform.trans_id_file_id('myfile-id')
873
dir_id = rename_transform.trans_id_file_id('first-id')
874
rename_transform.adjust_path('newname', dir_id, file_trans_id)
875
e = self.assertRaises(errors.TransformRenameFailed,
876
rename_transform.apply)
878
# "Failed to rename .../work/.bzr/checkout/limbo/new-1
879
# to .../first-dir/newname: [Errno 13] Permission denied"
880
# On windows looks like:
881
# "Failed to rename .../work/myfile to
882
# .../work/.bzr/checkout/limbo/new-1: [Errno 13] Permission denied"
883
# The strerror will vary per OS and language so it's not checked here
884
self.assertContainsRe(str(e),
885
"Failed to rename .*(first-dir.newname:|myfile)")
887
833
def test_set_executability_order(self):
888
834
"""Ensure that executability behaves the same, no matter what order.
2145
2091
self.assertRaises(errors.MalformedTransform, tt.commit, branch,
2148
def test_commit_rich_revision_data(self):
2149
branch, tt = self.get_branch_and_transform()
2150
rev_id = tt.commit(branch, 'message', timestamp=1, timezone=43201,
2151
committer='me <me@example.com>',
2152
revprops={'foo': 'bar'}, revision_id='revid-1',
2153
authors=['Author1 <author1@example.com>',
2154
'Author2 <author2@example.com>',
2156
self.assertEqual('revid-1', rev_id)
2157
revision = branch.repository.get_revision(rev_id)
2158
self.assertEqual(1, revision.timestamp)
2159
self.assertEqual(43201, revision.timezone)
2160
self.assertEqual('me <me@example.com>', revision.committer)
2161
self.assertEqual(['Author1 <author1@example.com>',
2162
'Author2 <author2@example.com>'],
2163
revision.get_apparent_authors())
2164
del revision.properties['authors']
2165
self.assertEqual({'foo': 'bar',
2166
'branch-nick': 'tree'},
2167
revision.properties)
2169
def test_no_explicit_revprops(self):
2170
branch, tt = self.get_branch_and_transform()
2171
rev_id = tt.commit(branch, 'message', authors=[
2172
'Author1 <author1@example.com>',
2173
'Author2 <author2@example.com>', ])
2174
revision = branch.repository.get_revision(rev_id)
2175
self.assertEqual(['Author1 <author1@example.com>',
2176
'Author2 <author2@example.com>'],
2177
revision.get_apparent_authors())
2178
self.assertEqual('tree', revision.properties['branch-nick'])
2181
2095
class MockTransform(object):