Rev 5855: Fix some 'switch' tests. in http://bazaar.launchpad.net/~jameinel/bzr/2.4-set-parent-trees-delta-282941
John Arbash Meinel
john at arbash-meinel.com
Wed May 18 05:06:54 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.4-set-parent-trees-delta-282941
------------------------------------------------------------
revno: 5855
revision-id: john at arbash-meinel.com-20110518050648-ag00febzpl0y7ahk
parent: john at arbash-meinel.com-20110518050100-fuip01rzev5kegtl
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-set-parent-trees-delta-282941
timestamp: Wed 2011-05-18 07:06:48 +0200
message:
Fix some 'switch' tests.
Basically, with switch a WorkingTree can be pointing to a revision that
will no longer be present in the repository the WT is associated with.
So if we can't lookup the basis_tree from the repo, just fall back to
the regular 'set_parent_trees' code.
-------------- next part --------------
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2011-05-17 13:44:12 +0000
+++ b/bzrlib/workingtree_4.py 2011-05-18 05:06:48 +0000
@@ -1145,6 +1145,7 @@
_mod_revision.NULL_REVISION)))
ghosts.append(rev_id)
accepted_revisions.add(rev_id)
+ updated = False
if (len(real_trees) == 1
and not ghosts
and self.branch.repository._format.fast_deltas
@@ -1152,10 +1153,16 @@
and self.get_parent_ids()):
rev_id, rev_tree = real_trees[0]
basis_id = self.get_parent_ids()[0]
- basis_tree = self.branch.repository.revision_tree(basis_id)
- delta = rev_tree.inventory._make_delta(basis_tree.inventory)
- dirstate.update_basis_by_delta(delta, rev_id)
- else:
+ # There are times when basis_tree won't be in
+ # self.branch.repository, (switch, for example)
+ try:
+ basis_tree = self.branch.repository.revision_tree(basis_id)
+ except errors.NoSuchRevision:
+ pass # Fallback to set_parent_trees
+ else:
+ delta = rev_tree.inventory._make_delta(basis_tree.inventory)
+ dirstate.update_basis_by_delta(delta, rev_id)
+ if not updated:
dirstate.set_parent_trees(real_trees, ghosts=ghosts)
self._make_dirty(reset_inventory=False)
More information about the bazaar-commits
mailing list