~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_btree_serializer_pyx.pyx

  • Committer: Jelmer Vernooij
  • Date: 2011-04-09 22:14:24 UTC
  • mfrom: (5777.4.2 mutableinventorytree)
  • mto: This revision was merged to the branch mainline in revision 5787.
  • Revision ID: jelmer@samba.org-20110409221424-a2air35exbz50hi8
Mergemutableinventorytree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
496
496
    return val
497
497
 
498
498
 
 
499
cdef _format_record_py24(gc_chk_sha1_record *record):
 
500
    """Python2.4 PyString_FromFormat doesn't have %u.
 
501
 
 
502
    It only has %d and %ld. We would really like to even have %llu, which
 
503
    is only in python2.7. So we go back into casting to regular objects.
 
504
    """
 
505
    return "%s %s %s %s" % (record.block_offset, record.block_length,
 
506
                            record.record_start, record.record_end)
 
507
 
 
508
 
499
509
cdef _format_record(gc_chk_sha1_record *record):
500
510
    # This is inefficient to go from a logical state back to a
501
511
    # string, but it makes things work a bit better internally for now.
514
524
                                    record.record_start, record.record_end)
515
525
    return value
516
526
 
 
527
ctypedef object (*formatproc)(gc_chk_sha1_record *)
 
528
cdef formatproc _record_formatter
 
529
_record_formatter = _format_record
 
530
if sys.version_info[:2] == (2, 4):
 
531
    _record_formatter = _format_record_py24
 
532
 
517
533
 
518
534
cdef class GCCHKSHA1LeafNode:
519
535
    """Track all the entries for a given leaf node."""
577
593
        cdef StaticTuple value_and_refs
578
594
        cdef StaticTuple empty
579
595
        value_and_refs = StaticTuple_New(2)
580
 
        value = _format_record(record)
 
596
        value = _record_formatter(record)
581
597
        Py_INCREF(value)
582
598
        StaticTuple_SET_ITEM(value_and_refs, 0, value)
583
599
        # Always empty refs