~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to weavefile.py

  • Committer: Martin Pool
  • Date: 2005-06-30 08:52:38 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mbp@sourcefrog.net-20050630085238-ebe52cd8b7d6944b
In the weavefile, store only the minimum revisions added, not the full
list of parents.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
series of version headers, followed by the weave itself.
28
28
 
29
29
Each version marker has 'v' and the version, then 'i' and the included
30
 
previous versions.
 
30
previous versions.  The inclusions do not need to list versions
 
31
included by a parent.
31
32
 
32
33
The weave is bracketed by 'w' and 'W' lines, and includes the '{}[]'
33
34
processing instructions.  Lines of text are prefixed by '.' if the
55
56
    for version, included in enumerate(weave._v):
56
57
        print >>f, 'v', version
57
58
        if included:
58
 
            included = list(included)
59
 
            included.sort()
60
 
            assert included[0] >= 0
61
 
            assert included[-1] < version
 
59
            # find a minimal expression of it; bias towards using
 
60
            # later revisions
 
61
            li = list(included)
 
62
            li.sort()
 
63
            li.reverse()
 
64
 
 
65
            mininc = []
 
66
            gotit = set()
 
67
 
 
68
            for pv in li:
 
69
                if pv not in gotit:
 
70
                    mininc.append(pv)
 
71
                    gotit.update(weave._v[pv])
 
72
 
 
73
            assert mininc[0] >= 0
 
74
            assert mininc[-1] < version
62
75
            print >>f, 'i',
63
 
            for i in included:
 
76
            for i in mininc:
64
77
                print >>f, i,
65
78
            print >>f
66
79
        else:
115
128
                raise WeaveFormatError('unexpected line %r' % l)
116
129
            if len(l) > 2:
117
130
                included = map(int, l[2:].split(' '))
118
 
                w._addversion(included)
 
131
                full = set()
 
132
                for pv in included:
 
133
                    full.add(pv)
 
134
                    full.update(w._v[pv])
 
135
                w._addversion(full)
119
136
            else:
120
137
                w._addversion(None)
121
138
            assert f.readline() == '\n'