~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-14 16:16:53 UTC
  • mto: (1946.2.6 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1919.
  • Revision ID: john@arbash-meinel.com-20060814161653-54cdcdadcd4e9003
Remove bogus entry from BRANCH.TODO

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# (C) 2005 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
18
18
import os
19
19
import warnings
20
20
 
21
 
from bzrlib import (
22
 
    revision,
23
 
    )
24
21
from bzrlib.branch import Branch
25
22
from bzrlib.errors import NoSuchRevision
26
23
from bzrlib.graph import Graph
28
25
                             common_ancestor,
29
26
                             is_ancestor, MultipleRevisionSources,
30
27
                             NULL_REVISION)
31
 
from bzrlib.tests import TestCase, TestCaseWithTransport
 
28
from bzrlib.tests import TestCaseWithTransport
32
29
from bzrlib.trace import mutter
33
30
from bzrlib.workingtree import WorkingTree
34
31
 
70
67
    tree2.commit("Commit four", rev_id="b@u-0-3")
71
68
    tree2.commit("Commit five", rev_id="b@u-0-4")
72
69
    revisions_2 = br2.revision_history()
73
 
    self.assertEquals(revisions_2[-1], 'b@u-0-4')
74
70
    
75
 
    tree1.merge_from_branch(br2)
 
71
    br1.fetch(br2)
 
72
    tree1.add_pending_merge(revisions_2[4])
 
73
    self.assertEquals(revisions_2[4], 'b@u-0-4')
76
74
    tree1.commit("Commit six", rev_id="a@u-0-3")
77
75
    tree1.commit("Commit seven", rev_id="a@u-0-4")
78
76
    tree2.commit("Commit eight", rev_id="b@u-0-5")
79
 
    self.assertEquals(br2.revision_history()[-1], 'b@u-0-5')
80
77
    
81
 
    tree1.merge_from_branch(br2)
 
78
    br1.fetch(br2)
 
79
    tree1.add_pending_merge(br2.revision_history()[5])
82
80
    tree1.commit("Commit nine", rev_id="a@u-0-5")
83
 
    # DO NOT MERGE HERE - we WANT a GHOST.
84
 
    tree2.add_parent_tree_id(br1.revision_history()[4])
 
81
    # DO NOT FETCH HERE - we WANT a GHOST.
 
82
    # br2.fetch(br1)
 
83
    tree2.add_pending_merge(br1.revision_history()[4])
85
84
    tree2.commit("Commit ten - ghost merge", rev_id="b@u-0-6")
86
85
    
87
86
    return br1, br2
156
155
        wt2.commit("Commit twelve", rev_id="b@u-0-8")
157
156
        wt2.commit("Commit thirtteen", rev_id="b@u-0-9")
158
157
 
159
 
        wt1.merge_from_branch(self.br2)
 
158
        self.br1.fetch(self.br2)
 
159
        wt1.add_pending_merge(self.br2.revision_history()[6])
160
160
        wt1.commit("Commit fourtten", rev_id="a@u-0-6")
161
161
 
162
 
        wt2.merge_from_branch(self.br1)
 
162
        self.br2.fetch(self.br1)
 
163
        wt2.add_pending_merge(self.br1.revision_history()[6])
163
164
        wt2.commit("Commit fifteen", rev_id="b@u-0-10")
164
165
 
165
166
        from bzrlib.revision import MultipleRevisionSources
234
235
        """
235
236
        br1, br2 = make_branches(self)
236
237
        source = MultipleRevisionSources(br1.repository, br2.repository)
237
 
        combined_1 = combined_graph(br1.last_revision(),
 
238
        combined_1 = combined_graph(br1.last_revision(), 
238
239
                                    br2.last_revision(), source)
239
240
        combined_2 = combined_graph(br2.last_revision(),
240
241
                                    br1.last_revision(), source)
287
288
        # in repo 2, which has A, the revision_graph()
288
289
        # should return A and B both.
289
290
        tree_1 = self.make_branch_and_tree('1')
290
 
        tree_1.set_parent_ids(['A'], allow_leftmost_as_ghost=True)
 
291
        tree_1.add_pending_merge('A')
291
292
        tree_1.commit('foo', rev_id='B', allow_pointless=True)
292
293
        tree_2 = self.make_branch_and_tree('2')
293
294
        tree_2.commit('bar', rev_id='A', allow_pointless=True)
296
297
        self.assertEqual({'B':['A'],
297
298
                          'A':[]},
298
299
                         source.get_revision_graph('B'))
 
300
 
 
301
class TestRevisionAttributes(TestCaseWithTransport):
 
302
    """Test that revision attributes are correct."""
 
303
 
 
304
    def test_revision_accessors(self):
 
305
        """Make sure the values that come out of a revision are the same as the ones that go in.
 
306
        """
 
307
        tree1 = self.make_branch_and_tree("br1")
 
308
 
 
309
        # create a revision
 
310
        tree1.commit(message="quux", allow_pointless=True, committer="jaq",
 
311
                     revprops={'empty':'',
 
312
                               'value':'one',
 
313
                               'unicode':'\xb5',
 
314
                               'multiline':'foo\nbar\n\n'
 
315
                              })
 
316
        assert len(tree1.branch.revision_history()) > 0
 
317
        rev_a = tree1.branch.repository.get_revision(tree1.branch.last_revision())
 
318
 
 
319
        tree2 = self.make_branch_and_tree("br2")
 
320
        tree2.commit(message=rev_a.message,
 
321
                     timestamp=rev_a.timestamp,
 
322
                     timezone=rev_a.timezone,
 
323
                     committer=rev_a.committer,
 
324
                     rev_id=rev_a.revision_id,
 
325
                     revprops=rev_a.properties,
 
326
                     allow_pointless=True, # there's nothing in this commit
 
327
                     strict=True,
 
328
                     verbose=True)
 
329
        rev_b = tree2.branch.repository.get_revision(tree2.branch.last_revision())
 
330
        
 
331
        self.assertEqual(rev_a.message, rev_b.message)
 
332
        self.assertEqual(rev_a.timestamp, rev_b.timestamp)
 
333
        self.assertEqual(rev_a.timezone, rev_b.timezone)
 
334
        self.assertEqual(rev_a.committer, rev_b.committer)
 
335
        self.assertEqual(rev_a.revision_id, rev_b.revision_id)
 
336
        self.assertEqual(rev_a.properties, rev_b.properties)