[MERGE REQUEST] revision accessor test case and timestamp fix

Jamie Wilkinson jaq at spacepants.org
Mon Mar 27 21:33:00 BST 2006


I posted this to the list a few months ago, it must've gotten lost :)  Still
looking for review and merge.

http://repo.spacepants.org/bzr/bzr.jaq

revision 1600 and 1601:

revno: 1601
committer: Jamie Wilkinson <jaq at spacepants.org>
branch nick: bzr.jaq
timestamp: Mon 2006-03-27 23:52:15 +1100
message:
  don't cast commit timestamp to long, which loses precision
------------------------------------------------------------
revno: 1600
committer: Jamie Wilkinson <jaq at spacepants.org>
branch nick: bzr.jaq
timestamp: Mon 2006-03-27 23:44:47 +1100
message:
  test that revision accessors act idempotently


=== modified file 'a/bzrlib/commit.py'
--- a/bzrlib/commit.py	
+++ b/bzrlib/commit.py	
@@ -263,7 +263,7 @@
             if timestamp is None:
                 self.timestamp = time.time()
             else:
-                self.timestamp = long(timestamp)
+                self.timestamp = timestamp
                 
             if self.config is None:
                 self.config = bzrlib.config.BranchConfig(self.branch)

=== modified file 'a/bzrlib/tests/test_revision.py'
--- a/bzrlib/tests/test_revision.py	
+++ b/bzrlib/tests/test_revision.py	
@@ -330,3 +330,33 @@
         self.assertEqual({'B':['A'],
                           'A':[]},
                          source.get_revision_graph('B'))
+
+class TestRevisionAttributes(TestCaseWithTransport):
+    """Test that revision attributes are correct."""
+
+    def test_revision_accessors(self):
+        """Make sure the values that come out of a revision are the same as the ones that go in.
+        """
+        tree1 = self.make_branch_and_tree("br1")
+
+        # create a revision
+        tree1.commit(message="quux", allow_pointless=True, committer="jaq")
+        assert len(tree1.branch.revision_history()) > 0
+        rev_a = tree1.branch.repository.get_revision(tree1.branch.last_revision())
+
+        tree2 = self.make_branch_and_tree("br2")
+        tree2.commit(message=rev_a.message,
+                     timestamp=rev_a.timestamp,
+                     timezone=rev_a.timezone,
+                     committer=rev_a.committer,
+                     rev_id=rev_a.revision_id,
+                     allow_pointless=True, # there's nothing in this commit
+                     strict=True,
+                     verbose=True)
+        rev_b = tree2.branch.repository.get_revision(tree2.branch.last_revision())
+        
+        self.assertEqual(rev_a.message, rev_b.message)
+        self.assertEqual(rev_a.timestamp, rev_b.timestamp)
+        self.assertEqual(rev_a.timezone, rev_b.timezone)
+        self.assertEqual(rev_a.committer, rev_b.committer)
+        self.assertEqual(rev_a.revision_id, rev_b.revision_id)






More information about the bazaar mailing list