/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/per_repository/test_commit_builder.py

  • Committer: Martin
  • Date: 2010-05-25 17:27:52 UTC
  • mfrom: (5254 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5257.
  • Revision ID: gzlist@googlemail.com-20100525172752-amm089xcikv968sw
Merge bzr.dev to unite with similar changes already made

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""Tests for repository commit builder."""
18
18
 
19
 
from copy import copy
20
 
import errno
21
19
import os
22
 
import sys
23
20
 
24
21
from bzrlib import (
25
22
    errors,
 
23
    graph,
26
24
    inventory,
27
25
    osutils,
28
26
    repository,
29
27
    revision as _mod_revision,
30
28
    tests,
31
29
    )
32
 
from bzrlib.graph import Graph
33
 
from bzrlib.tests.per_repository import test_repository
34
 
 
35
 
 
36
 
class TestCommitBuilder(test_repository.TestCaseWithRepository):
 
30
from bzrlib.tests import per_repository
 
31
 
 
32
 
 
33
class TestCommitBuilder(per_repository.TestCaseWithRepository):
37
34
 
38
35
    def test_get_commit_builder(self):
39
36
        branch = self.make_branch('.')
196
193
        self.assertEqual(revision_id,
197
194
            tree.branch.repository.get_inventory(revision_id).revision_id)
198
195
 
 
196
    def test_commit_without_root_errors(self):
 
197
        tree = self.make_branch_and_tree(".")
 
198
        tree.lock_write()
 
199
        try:
 
200
            builder = tree.branch.get_commit_builder([])
 
201
            def do_commit():
 
202
                try:
 
203
                    list(builder.record_iter_changes(
 
204
                        tree, tree.last_revision(), []))
 
205
                    builder.finish_inventory()
 
206
                except:
 
207
                    builder.abort()
 
208
                    raise
 
209
            self.assertRaises(errors.RootMissing, do_commit)
 
210
        finally:
 
211
            tree.unlock()
 
212
 
199
213
    def test_commit_without_root_or_record_iter_changes_errors(self):
200
214
        tree = self.make_branch_and_tree(".")
201
215
        tree.lock_write()
894
908
                self.assertTrue(version_recorded)
895
909
            else:
896
910
                self.assertFalse(version_recorded)
 
911
            self.assertIs(None, builder.new_inventory)
897
912
            builder.finish_inventory()
 
913
            inv_key = (builder._new_revision_id,)
 
914
            inv_sha1 = tree.branch.repository.inventories.get_sha1s(
 
915
                            [inv_key])[inv_key]
 
916
            self.assertEqual(inv_sha1, builder.inv_sha1)
 
917
            self.assertIs(None, builder.new_inventory)
898
918
            new_inventory = builder.revision_tree().inventory
899
919
            new_entry = new_inventory[file_id]
900
920
            if delta_against_basis:
918
938
        # (closest to a public per-file graph API we have today)
919
939
        tree.lock_read()
920
940
        self.addCleanup(tree.unlock)
921
 
        graph = dict(Graph(tree.branch.repository.texts).iter_ancestry([tip]))
922
 
        self.assertEqual(expected_graph, graph)
 
941
        g = dict(graph.Graph(tree.branch.repository.texts).iter_ancestry([tip]))
 
942
        self.assertEqual(expected_graph, g)
923
943
 
924
944
    def test_last_modified_revision_after_content_file_changes(self):
925
945
        # altering a file changes the last modified.