Rev 4537: Defer doing unversioning of file ids during commit to after completing branch operations. (Robert Collins, bug 282402) in http://bazaar.launchpad.net/~lifeless/bzr/bug-282402
Robert Collins
robertc at robertcollins.net
Wed Jul 15 06:54:42 BST 2009
At http://bazaar.launchpad.net/~lifeless/bzr/bug-282402
------------------------------------------------------------
revno: 4537
revision-id: robertc at robertcollins.net-20090715055437-ozlxxlwmcc9v1qyz
parent: pqm at pqm.ubuntu.com-20090714173313-3p3ytzlfuc3y2bm6
committer: Robert Collins <robertc at robertcollins.net>
branch nick: bug-282402
timestamp: Wed 2009-07-15 15:54:37 +1000
message:
Defer doing unversioning of file ids during commit to after completing branch operations. (Robert Collins, bug 282402)
=== modified file 'NEWS'
--- a/NEWS 2009-07-14 16:27:40 +0000
+++ b/NEWS 2009-07-15 05:54:37 +0000
@@ -25,6 +25,11 @@
* BranchBuilder now accepts timezone to avoid test failures in countries far
from GMT. (Vincent Ladeuil, #397716)
+* ``bzr commit`` no longer saves the unversioning of missing files until
+ the commit has completed on the branch. This means that aborting a
+ commit that found a missing file will leave the tree unedited.
+ (Robert Collins, #282402)
+
Improvements
************
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py 2009-06-15 19:04:38 +0000
+++ b/bzrlib/commit.py 2009-07-15 05:54:37 +0000
@@ -204,6 +204,7 @@
"""Commit working copy as a new revision.
:param message: the commit message (it or message_callback is required)
+ :param message_callback: A callback: message = message_callback(cmt_obj)
:param timestamp: if not None, seconds-since-epoch for a
postdated/predated commit.
@@ -392,7 +393,10 @@
# and now do the commit locally.
self.branch.set_last_revision_info(new_revno, self.rev_id)
- # Make the working tree up to date with the branch
+ # Make the working tree be up to date with the branch. This
+ # includes automatic changes scheduled to be made to the tree, such
+ # as updating its basis and unversioning paths that were missing.
+ self.work_tree.unversion(self.deleted_ids)
self._set_progress_stage("Updating the working tree")
self.work_tree.update_basis_by_delta(self.rev_id,
self.builder.get_basis_delta())
@@ -679,7 +683,7 @@
reporter.snapshot_change('modified', new_path)
self._next_progress_entry()
# Unversion IDs that were found to be deleted
- self.work_tree.unversion(deleted_ids)
+ self.deleted_ids = deleted_ids
def _record_unselected(self):
# If specific files are selected, then all un-selected files must be
@@ -842,7 +846,7 @@
content_summary)
# Unversion IDs that were found to be deleted
- self.work_tree.unversion(deleted_ids)
+ self.deleted_ids = deleted_ids
def _commit_nested_tree(self, file_id, path):
"Commit a nested tree."
=== modified file 'bzrlib/tests/per_workingtree/test_commit.py'
--- a/bzrlib/tests/per_workingtree/test_commit.py 2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_workingtree/test_commit.py 2009-07-15 05:54:37 +0000
@@ -280,6 +280,15 @@
wt2.merge_from_branch(wt.branch)
wt2.commit('merged kind change')
+ def test_commit_aborted_does_not_apply_automatic_changes_bug_282402(self):
+ wt = self.make_branch_and_tree('.')
+ wt.add(['a'], ['a-id'], ['file'])
+ def fail_message(obj):
+ raise errors.BzrCommandError("empty commit message")
+ self.assertRaises(errors.BzrCommandError, wt.commit,
+ message_callback=fail_message)
+ self.assertEqual('a', wt.id2path('a-id'))
+
def test_local_commit_ignores_master(self):
# a --local commit does not require access to the master branch
# at all, or even for it to exist.
More information about the bazaar-commits
mailing list