~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weavefile.py

  • Committer: Robert Collins
  • Date: 2007-10-22 01:23:51 UTC
  • mfrom: (2921.3.1 graph)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20071022012351-16lm27an2lbzk038
Merge graph history-access bugfix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
def write_weave_v5(weave, f):
55
55
    """Write weave to file f."""
56
 
    print >>f, FORMAT_1,
 
56
    f.write(FORMAT_1)
57
57
 
58
58
    for version, included in enumerate(weave._parents):
59
59
        if included:
60
60
            # mininc = weave.minimal_parents(version)
61
61
            mininc = included
62
 
            print >>f, 'i',
63
 
            for i in mininc:
64
 
                print >>f, i,
65
 
            print >>f
 
62
            f.write('i ')
 
63
            f.write(' '.join(str(i) for i in mininc))
 
64
            f.write('\n')
66
65
        else:
67
 
            print >>f, 'i'
68
 
        print >>f, '1', weave._sha1s[version]
69
 
        print >>f, 'n', weave._names[version]
70
 
        print >>f
 
66
            f.write('i\n')
 
67
        f.write('1 ' + weave._sha1s[version] + '\n')
 
68
        f.write('n ' + weave._names[version] + '\n')
 
69
        f.write('\n')
71
70
 
72
 
    print >>f, 'w'
 
71
    f.write('w\n')
73
72
 
74
73
    for l in weave._weave:
75
74
        if isinstance(l, tuple):
76
75
            assert l[0] in '{}[]'
77
76
            if l[0] == '}':
78
 
                print >>f, '}'
 
77
                f.write('}\n')
79
78
            else:
80
 
                print >>f, '%s %d' % l
 
79
                f.write('%s %d\n' % l)
81
80
        else: # text line
82
81
            if not l:
83
 
                print >>f, ', '
 
82
                f.write(', \n')
84
83
            elif l[-1] == '\n':
85
84
                assert l.find('\n', 0, -1) == -1
86
 
                print >>f, '.', l,
 
85
                f.write('. ' + l)
87
86
            else:
88
87
                assert l.find('\n') == -1
89
 
                print >>f, ',', l
 
88
                f.write(', ' + l + '\n')
90
89
 
91
 
    print >>f, 'W'
 
90
    f.write('W\n')
92
91
 
93
92
 
94
93