~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

  • Committer: Robert Collins
  • Date: 2006-08-08 23:19:29 UTC
  • mfrom: (1884 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1912.
  • Revision ID: robertc@robertcollins.net-20060808231929-4e3e298190214b3a
current status

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from bzrlib.branch import Branch
22
22
from bzrlib.errors import NoSuchRevision
23
 
from bzrlib.commit import commit
24
23
from bzrlib.graph import Graph
25
24
from bzrlib.revision import (find_present_ancestors, combined_graph,
26
25
                             common_ancestor,
27
 
                             is_ancestor, MultipleRevisionSources)
 
26
                             is_ancestor, MultipleRevisionSources,
 
27
                             NULL_REVISION)
28
28
from bzrlib.tests import TestCaseWithTransport
29
29
from bzrlib.trace import mutter
30
30
from bzrlib.workingtree import WorkingTree
147
147
class TestIntermediateRevisions(TestCaseWithTransport):
148
148
 
149
149
    def setUp(self):
150
 
        from bzrlib.commit import commit
151
150
        TestCaseWithTransport.setUp(self)
152
151
        self.br1, self.br2 = make_branches(self)
153
152
        wt1 = self.br1.bzrdir.open_workingtree()
223
222
        self.assertTrue(common_ancestor(revisions_2[6], revisions[5], sources),
224
223
                        (revisions[4], revisions_2[5]))
225
224
        self.assertEqual(None, common_ancestor(None, revisions[5], sources))
 
225
        self.assertEqual(NULL_REVISION,
 
226
            common_ancestor(NULL_REVISION, NULL_REVISION, sources))
 
227
        self.assertEqual(NULL_REVISION,
 
228
            common_ancestor(revisions[0], NULL_REVISION, sources))
 
229
        self.assertEqual(NULL_REVISION,
 
230
            common_ancestor(NULL_REVISION, revisions[0], sources))
226
231
 
227
232
    def test_combined(self):
228
233
        """combined_graph
292
297
        self.assertEqual({'B':['A'],
293
298
                          'A':[]},
294
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
        assert len(tree1.branch.revision_history()) > 0
 
312
        rev_a = tree1.branch.repository.get_revision(tree1.branch.last_revision())
 
313
 
 
314
        tree2 = self.make_branch_and_tree("br2")
 
315
        tree2.commit(message=rev_a.message,
 
316
                     timestamp=rev_a.timestamp,
 
317
                     timezone=rev_a.timezone,
 
318
                     committer=rev_a.committer,
 
319
                     rev_id=rev_a.revision_id,
 
320
                     allow_pointless=True, # there's nothing in this commit
 
321
                     strict=True,
 
322
                     verbose=True)
 
323
        rev_b = tree2.branch.repository.get_revision(tree2.branch.last_revision())
 
324
        
 
325
        self.assertEqual(rev_a.message, rev_b.message)
 
326
        self.assertEqual(rev_a.timestamp, rev_b.timestamp)
 
327
        self.assertEqual(rev_a.timezone, rev_b.timezone)
 
328
        self.assertEqual(rev_a.committer, rev_b.committer)
 
329
        self.assertEqual(rev_a.revision_id, rev_b.revision_id)