928
929
return _PreviewTree(self)
930
def commit(self, branch, message, merge_parents=None, strict=False):
931
def commit(self, branch, message, merge_parents=None, strict=False,
932
timestamp=None, timezone=None, committer=None, authors=None,
933
revprops=None, revision_id=None):
931
934
"""Commit the result of this TreeTransform to a branch.
933
936
:param branch: The branch to commit to.
934
937
:param message: The message to attach to the commit.
935
:param merge_parents: Additional parents specified by pending merges.
938
:param merge_parents: Additional parent revision-ids specified by
940
:param strict: If True, abort the commit if there are unversioned
942
:param timestamp: if not None, seconds-since-epoch for the time and
943
date. (May be a float.)
944
:param timezone: Optional timezone for timestamp, as an offset in
946
:param committer: Optional committer in email-id format.
947
(e.g. "J Random Hacker <jrandom@example.com>")
948
:param authors: Optional list of authors in email-id format.
949
:param revprops: Optional dictionary of revision properties.
950
:param revision_id: Optional revision id. (Specifying a revision-id
951
may reduce performance for some non-native formats.)
936
952
:return: The revision_id of the revision committed.
938
954
self._check_malformed()
955
971
if self._tree.get_revision_id() != last_rev_id:
956
972
raise ValueError('TreeTransform not based on branch basis: %s' %
957
973
self._tree.get_revision_id())
958
builder = branch.get_commit_builder(parent_ids)
974
revprops = commit.Commit.update_revprops(revprops, branch, authors)
975
builder = branch.get_commit_builder(parent_ids,
980
revision_id=revision_id)
959
981
preview = self.get_preview_tree()
960
982
list(builder.record_iter_changes(preview, last_rev_id,
961
983
self.iter_changes()))
1635
1657
or trans_id in self._new_parent):
1637
1659
mover.rename(full_path, self._limbo_name(trans_id))
1660
except errors.TransformRenameFailed, e:
1639
1661
if e.errno != errno.ENOENT:
1666
1688
if trans_id in self._needs_rename:
1668
1690
mover.rename(self._limbo_name(trans_id), full_path)
1691
except errors.TransformRenameFailed, e:
1670
1692
# We may be renaming a dangling inventory id
1671
1693
if e.errno != errno.ENOENT:
1770
1792
parent_keys = [(file_id, self._file_revision(t, file_id)) for t in
1771
1793
self._iter_parent_trees()]
1772
1794
vf.add_lines((file_id, tree_revision), parent_keys,
1773
self.get_file(file_id).readlines())
1795
self.get_file_lines(file_id))
1774
1796
repo = self._get_repository()
1775
1797
base_vf = repo.texts
1776
1798
if base_vf not in vf.fallback_versionedfiles:
2438
2460
if entry.kind == "directory":
2440
2462
if entry.kind == "file":
2441
if tree.get_file(file_id).read() == file(target_path, 'rb').read():
2463
f = file(target_path, 'rb')
2465
if tree.get_file_text(file_id) == f.read():
2443
2469
elif entry.kind == "symlink":
2444
2470
if tree.get_symlink_target(file_id) == os.readlink(target_path):
2904
2930
"""Rename a file from one path to another."""
2906
2932
osutils.rename(from_, to)
2933
except (IOError, OSError), e:
2908
2934
if e.errno in (errno.EEXIST, errno.ENOTEMPTY):
2909
2935
raise errors.FileExists(to, str(e))
2936
# normal OSError doesn't include filenames so it's hard to see where
2937
# the problem is, see https://bugs.launchpad.net/bzr/+bug/491763
2938
raise errors.TransformRenameFailed(from_, to, str(e), e.errno)
2911
2939
self.past_renames.append((from_, to))
2913
2941
def pre_delete(self, from_, to):
2923
2951
def rollback(self):
2924
2952
"""Reverse all renames that have been performed"""
2925
2953
for from_, to in reversed(self.past_renames):
2926
osutils.rename(to, from_)
2955
osutils.rename(to, from_)
2956
except (OSError, IOError), e:
2957
raise errors.TransformRenameFailed(to, from_, str(e), e.errno)
2927
2958
# after rollback, don't reuse _FileMover
2928
2959
past_renames = None
2929
2960
pending_deletions = None