Rev 4641: (abentley) Shelve will not remove tree root. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Aug 24 19:28:49 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4641 [merge]
revision-id: pqm at pqm.ubuntu.com-20090824182846-ac4l3skw47g0tzx0
parent: pqm at pqm.ubuntu.com-20090824111405-zv4r3hfomqzsr3g3
parent: aaron at aaronbentley.com-20090824165626-rrxbl8hvxkofbj7l
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2009-08-24 19:28:46 +0100
message:
(abentley) Shelve will not remove tree root.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/shelf.py prepare_shelf.py-20081005181341-n74qe6gu1e65ad4v-1
bzrlib/tests/test_shelf.py test_prepare_shelf.p-20081005181341-n74qe6gu1e65ad4v-2
bzrlib/tests/test_shelf_ui.py test_shelf_ui.py-20081027155203-wtcuazg85wp9u4fv-1
=== modified file 'NEWS'
--- a/NEWS 2009-08-24 03:08:06 +0000
+++ b/NEWS 2009-08-24 18:28:46 +0000
@@ -290,7 +290,9 @@
* Requests for unknown methods no longer cause the smart server to log
lots of backtraces about ``UnknownSmartMethod``, ``do_chunk`` or
``do_end``. (Andrew Bennetts, #338561)
-
+
+* Shelve will not shelve the initial add of the tree root. (Aaron Bentley)
+
* Streaming from bzr servers where there is a chain of stacked branches
(A stacked on B stacked on C) will now work. (Robert Collins, #406597)
=== modified file 'bzrlib/shelf.py'
--- a/bzrlib/shelf.py 2009-08-12 21:53:52 +0000
+++ b/bzrlib/shelf.py 2009-08-21 04:07:06 +0000
@@ -73,6 +73,12 @@
"""
for (file_id, paths, changed, versioned, parents, names, kind,
executable) in self.iter_changes:
+ # don't shelve add of tree root. Working tree should never
+ # lack roots, and bzr misbehaves when they do.
+ # FIXME ADHB (2009-08-09): should still shelve adds of tree roots
+ # when a tree root was deleted / renamed.
+ if kind[0] is None and names[1] == '':
+ continue
if kind[0] is None or versioned[0] == False:
self.creation[file_id] = (kind[1], names[1], parents[1],
versioned)
=== modified file 'bzrlib/tests/test_shelf.py'
--- a/bzrlib/tests/test_shelf.py 2009-08-18 12:49:22 +0000
+++ b/bzrlib/tests/test_shelf.py 2009-08-21 04:07:06 +0000
@@ -464,6 +464,13 @@
self.assertRaises(errors.PathsNotVersionedError,
shelf.ShelfCreator, tree, tree.basis_tree(), ['foo'])
+ def test_shelve_skips_added_root(self):
+ """Skip adds of the root when iterating through shelvable changes."""
+ tree = self.make_branch_and_tree('tree')
+ creator = shelf.ShelfCreator(tree, tree.basis_tree())
+ self.addCleanup(creator.finalize)
+ self.assertEqual([], list(creator.iter_shelvable()))
+
class TestUnshelver(tests.TestCaseWithTransport):
=== modified file 'bzrlib/tests/test_shelf_ui.py'
--- a/bzrlib/tests/test_shelf_ui.py 2009-07-31 17:42:29 +0000
+++ b/bzrlib/tests/test_shelf_ui.py 2009-08-24 16:56:26 +0000
@@ -19,7 +19,12 @@
import os
import sys
-from bzrlib import errors, shelf_ui, tests
+from bzrlib import (
+ errors,
+ shelf_ui,
+ revision,
+ tests,
+)
class ExpectShelver(shelf_ui.Shelver):
@@ -242,6 +247,44 @@
self.assertIs(None, tree.get_shelf_manager().last_shelf())
self.assertFileEqual(LINES_AJ, 'tree/foo')
+ @staticmethod
+ def shelve_all(tree, target_revision_id):
+ tree.lock_write()
+ try:
+ target = tree.branch.repository.revision_tree(target_revision_id)
+ shelver = shelf_ui.Shelver(tree, target, auto=True,
+ auto_apply=True)
+ shelver.run()
+ finally:
+ tree.unlock()
+
+ def test_shelve_old_root_deleted(self):
+ tree1 = self.make_branch_and_tree('tree1')
+ tree1.commit('add root')
+ tree2 = self.make_branch_and_tree('tree2')
+ rev2 = tree2.commit('add root')
+ tree1.merge_from_branch(tree2.branch,
+ from_revision=revision.NULL_REVISION)
+ tree1.commit('Replaced root entry')
+ # This is essentially assertNotRaises(InconsistentDelta)
+ self.expectFailure('Cannot shelve replacing a root entry',
+ self.assertRaises, AssertionError,
+ self.assertRaises, errors.InconsistentDelta,
+ self.shelve_all, tree1, rev2)
+
+ def test_shelve_split(self):
+ outer_tree = self.make_branch_and_tree('outer')
+ outer_tree.commit('Add root')
+ inner_tree = self.make_branch_and_tree('outer/inner')
+ rev2 = inner_tree.commit('Add root')
+ outer_tree.subsume(inner_tree)
+ # This is essentially assertNotRaises(ValueError).
+ # The ValueError is 'None is not a valid file id'.
+ self.expectFailure('Cannot shelve a join back to the inner tree.',
+ self.assertRaises, AssertionError,
+ self.assertRaises, ValueError, self.shelve_all,
+ outer_tree, rev2)
+
class TestApplyReporter(TestShelver):
More information about the bazaar-commits
mailing list