Esempio n. 1
0
    def _write_revision(self, rev, rev_tree, base_rev, base_tree,
                        explicit_base, force_binary):
        """Write out the information for a revision."""
        def w(key, value):
            self._write(key, value, indent=1)

        w('message', rev.message.split('\n'))
        w('committer', rev.committer)
        w('date', format_highres_date(rev.timestamp, rev.timezone))
        self.to_file.write('\n')

        self._write_delta(rev_tree, base_tree, rev.revision_id, force_binary)

        w('revision id', rev.revision_id)
        w('sha1', self._testament_sha1(rev.revision_id))
        w('inventory sha1', rev.inventory_sha1)
        if rev.parent_ids:
            w('parent ids', rev.parent_ids)
        if explicit_base:
            w('base id', base_rev)
        if rev.properties:
            self._write('properties', None, indent=1)
            for name, value in sorted(rev.properties.items()):
                self._write(name,
                            value,
                            indent=3,
                            trailing_space_when_empty=True)

        # Add an extra blank space at the end
        self.to_file.write('\n')
Esempio n. 2
0
    def _write_revision(self, rev, rev_tree, base_rev, base_tree, 
                        explicit_base, force_binary):
        """Write out the information for a revision."""
        def w(key, value):
            self._write(key, value, indent=1)

        w('message', rev.message.split('\n'))
        w('committer', rev.committer)
        w('date', format_highres_date(rev.timestamp, rev.timezone))
        self.to_file.write('\n')

        self._write_delta(rev_tree, base_tree, rev.revision_id, force_binary)

        w('revision id', rev.revision_id)
        w('sha1', self._testament_sha1(rev.revision_id))
        w('inventory sha1', rev.inventory_sha1)
        if rev.parent_ids:
            w('parent ids', rev.parent_ids)
        if explicit_base:
            w('base id', base_rev)
        if rev.properties:
            self._write('properties', None, indent=1)
            for name, value in sorted(rev.properties.items()):
                self._write(name, value, indent=3,
                            trailing_space_when_empty=True)
        
        # Add an extra blank space at the end
        self.to_file.write('\n')
Esempio n. 3
0
 def test_random(self):
     t = time.time()
     o = local_time_offset()
     t2, o2 = timestamp.unpack_highres_date(timestamp.format_highres_date(t, o))
     self.assertEquals(t, t2)
     self.assertEquals(o, o2)
     t -= 24*3600*365*2 # Start 2 years ago
     o = -12*3600
     for count in xrange(500):
         t += random.random()*24*3600*30
         o = ((o/3600 + 13) % 25 - 12)*3600 # Add 1 wrap around from [-12, 12]
         date = timestamp.format_highres_date(t, o)
         t2, o2 = timestamp.unpack_highres_date(date)
         self.assertEquals(t, t2,
             'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t))
         self.assertEquals(o, o2,
             'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t))
Esempio n. 4
0
 def from_revision(revision):
     revision_info = RevisionInfo(revision.revision_id)
     date = timestamp.format_highres_date(revision.timestamp,
                                          revision.timezone)
     revision_info.date = date
     revision_info.timezone = revision.timezone
     revision_info.timestamp = revision.timestamp
     revision_info.message = revision.message.split('\n')
     revision_info.properties = [': '.join(p) for p in
                                 revision.properties.iteritems()]
     return revision_info
Esempio n. 5
0
 def test_random(self):
     t = time.time()
     o = local_time_offset()
     t2, o2 = timestamp.unpack_highres_date(
         timestamp.format_highres_date(t, o))
     self.assertEqual(t, t2)
     self.assertEqual(o, o2)
     t -= 24 * 3600 * 365 * 2  # Start 2 years ago
     o = -12 * 3600
     for count in xrange(500):
         t += random.random() * 24 * 3600 * 30
         o = ((o / 3600 + 13) % 25 -
              12) * 3600  # Add 1 wrap around from [-12, 12]
         date = timestamp.format_highres_date(t, o)
         t2, o2 = timestamp.unpack_highres_date(date)
         self.assertEqual(
             t, t2,
             'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2 - t))
         self.assertEqual(
             o, o2,
             'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2 - t))
Esempio n. 6
0
 def from_revision(revision):
     revision_info = RevisionInfo(revision.revision_id)
     date = timestamp.format_highres_date(revision.timestamp,
                                          revision.timezone)
     revision_info.date = date
     revision_info.timezone = revision.timezone
     revision_info.timestamp = revision.timestamp
     revision_info.message = revision.message.split('\n')
     revision_info.properties = [
         ': '.join(p) for p in revision.properties.iteritems()
     ]
     return revision_info