/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_uncommit.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-05 14:26:58 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120105142658-vek3v6pzlxb751s2
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. 

@only_raises is evil and gave a hard time since any exception during
save_changes() was swallowed.

Possible improvements: 

- add some needs_write_lock decorators to crucial
  methods (_set_config_location ?) but keep locking the branch at higher levels

- decorate branch.unlock to call stack.save if last_lock() it True
  outside of @only_raises scope (evil decorator)

- add @needs_write_lock to stack.set and stack.remove (will probably get
  rid of most testing issues) we probably need a specialized decorator
  that can relay to the store and from there to the branch or whatever is
  needed. This will also helps bzr config to get it right. The
  get_mutable_section trick should not be needed anymore either.

- decorate branch.unlock to call stack.save if last_lock() it True outside
  of @only_raises scope (evil decorator)

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        self.assertEqual((1, history[0]), tree.branch.last_revision_info())
50
50
 
51
51
        # The file should not be removed
52
 
        self.failUnlessExists('tree/two')
 
52
        self.assertPathExists('tree/two')
53
53
        # And it should still be listed as added
54
54
        self.assertIsNot(None, tree.path2id('two'))
55
55
 
96
96
        # If this tree isn't bound, local=True raises an exception
97
97
        self.assertRaises(errors.LocalRequiresBoundBranch,
98
98
            uncommit.uncommit, tree.branch, tree=tree, local=True)
 
99
 
 
100
    def test_uncommit_remove_tags(self):
 
101
        tree, history = self.make_linear_tree()
 
102
        self.assertEqual(history[1], tree.last_revision())
 
103
        self.assertEqual((2, history[1]), tree.branch.last_revision_info())
 
104
        tree.branch.tags.set_tag(u"pointsatexisting", history[0])
 
105
        tree.branch.tags.set_tag(u"pointsatremoved", history[1])
 
106
        uncommit.uncommit(tree.branch, tree=tree)
 
107
        self.assertEqual(history[0], tree.last_revision())
 
108
        self.assertEqual((1, history[0]), tree.branch.last_revision_info())
 
109
        self.assertEqual({
 
110
            "pointsatexisting": history[0]
 
111
            }, tree.branch.tags.get_tag_dict())
 
112
 
 
113
    def test_uncommit_keep_tags(self):
 
114
        tree, history = self.make_linear_tree()
 
115
        self.assertEqual(history[1], tree.last_revision())
 
116
        self.assertEqual((2, history[1]), tree.branch.last_revision_info())
 
117
        tree.branch.tags.set_tag(u"pointsatexisting", history[0])
 
118
        tree.branch.tags.set_tag(u"pointsatremoved", history[1])
 
119
        uncommit.uncommit(tree.branch, tree=tree, keep_tags=True)
 
120
        self.assertEqual(history[0], tree.last_revision())
 
121
        self.assertEqual((1, history[0]), tree.branch.last_revision_info())
 
122
        self.assertEqual({
 
123
            "pointsatexisting": history[0],
 
124
            "pointsatremoved": history[1],
 
125
            }, tree.branch.tags.get_tag_dict())