Merge lp:~lifeless/bzr/bug-282402 into lp:~bzr/bzr/trunk-old

Proposed by Robert Collins
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~lifeless/bzr/bug-282402
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 77 lines
To merge this branch: bzr merge lp:~lifeless/bzr/bug-282402
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+8804@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Defer doing unversioning of file ids during commit to after completing
branch operations. (Robert Collins, bug 282402)

This makes it easier to recover if you abort a commit because bzr picked
up a missing file - without this patch, the file is already unversioned
and you've lost the file id so its harder to put things back.

-Rob

--

Revision history for this message
John A Meinel (jameinel) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-07-15 19:06:39 +0000
3+++ NEWS 2009-07-15 21:35:25 +0000
4@@ -25,6 +25,11 @@
5 * BranchBuilder now accepts timezone to avoid test failures in countries far
6 from GMT. (Vincent Ladeuil, #397716)
7
8+* ``bzr commit`` no longer saves the unversioning of missing files until
9+ the commit has completed on the branch. This means that aborting a
10+ commit that found a missing file will leave the tree unedited.
11+ (Robert Collins, #282402)
12+
13 Improvements
14 ************
15
16
17=== modified file 'bzrlib/commit.py'
18--- bzrlib/commit.py 2009-06-15 19:04:38 +0000
19+++ bzrlib/commit.py 2009-07-15 21:35:25 +0000
20@@ -204,6 +204,7 @@
21 """Commit working copy as a new revision.
22
23 :param message: the commit message (it or message_callback is required)
24+ :param message_callback: A callback: message = message_callback(cmt_obj)
25
26 :param timestamp: if not None, seconds-since-epoch for a
27 postdated/predated commit.
28@@ -392,7 +393,10 @@
29 # and now do the commit locally.
30 self.branch.set_last_revision_info(new_revno, self.rev_id)
31
32- # Make the working tree up to date with the branch
33+ # Make the working tree be up to date with the branch. This
34+ # includes automatic changes scheduled to be made to the tree, such
35+ # as updating its basis and unversioning paths that were missing.
36+ self.work_tree.unversion(self.deleted_ids)
37 self._set_progress_stage("Updating the working tree")
38 self.work_tree.update_basis_by_delta(self.rev_id,
39 self.builder.get_basis_delta())
40@@ -679,7 +683,7 @@
41 reporter.snapshot_change('modified', new_path)
42 self._next_progress_entry()
43 # Unversion IDs that were found to be deleted
44- self.work_tree.unversion(deleted_ids)
45+ self.deleted_ids = deleted_ids
46
47 def _record_unselected(self):
48 # If specific files are selected, then all un-selected files must be
49@@ -842,7 +846,7 @@
50 content_summary)
51
52 # Unversion IDs that were found to be deleted
53- self.work_tree.unversion(deleted_ids)
54+ self.deleted_ids = deleted_ids
55
56 def _commit_nested_tree(self, file_id, path):
57 "Commit a nested tree."
58
59=== modified file 'bzrlib/tests/per_workingtree/test_commit.py'
60--- bzrlib/tests/per_workingtree/test_commit.py 2009-07-10 07:14:02 +0000
61+++ bzrlib/tests/per_workingtree/test_commit.py 2009-07-15 21:35:25 +0000
62@@ -280,6 +280,15 @@
63 wt2.merge_from_branch(wt.branch)
64 wt2.commit('merged kind change')
65
66+ def test_commit_aborted_does_not_apply_automatic_changes_bug_282402(self):
67+ wt = self.make_branch_and_tree('.')
68+ wt.add(['a'], ['a-id'], ['file'])
69+ def fail_message(obj):
70+ raise errors.BzrCommandError("empty commit message")
71+ self.assertRaises(errors.BzrCommandError, wt.commit,
72+ message_callback=fail_message)
73+ self.assertEqual('a', wt.id2path('a-id'))
74+
75 def test_local_commit_ignores_master(self):
76 # a --local commit does not require access to the master branch
77 # at all, or even for it to exist.