~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weavefile.py

  • Committer: Martin Pool
  • Date: 2005-07-07 10:22:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050707102201-2d2a13a25098b101
- rearrange and clear up merged weave

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    """Write weave to file f."""
53
53
    print >>f, FORMAT_1,
54
54
 
55
 
    for version, included in enumerate(weave._parents):
 
55
    for version, included in enumerate(weave._v):
56
56
        if included:
57
 
            # mininc = weave.minimal_parents(version)
58
 
            mininc = included
 
57
            # find a minimal expression of it; bias towards using
 
58
            # later revisions
 
59
            li = list(included)
 
60
            li.sort()
 
61
            li.reverse()
 
62
 
 
63
            mininc = []
 
64
            gotit = set()
 
65
 
 
66
            for pv in li:
 
67
                if pv not in gotit:
 
68
                    mininc.append(pv)
 
69
                    gotit.update(weave._v[pv])
 
70
 
 
71
            assert mininc[0] >= 0
 
72
            assert mininc[-1] < version
59
73
            print >>f, 'i',
60
74
            for i in mininc:
61
75
                print >>f, i,
67
81
 
68
82
    print >>f, 'w'
69
83
 
70
 
    for l in weave._weave:
 
84
    for l in weave._l:
71
85
        if isinstance(l, tuple):
72
86
            assert l[0] in '{}[]'
73
87
            print >>f, '%s %d' % l
105
119
            ver += 1
106
120
 
107
121
            if len(l) > 2:
108
 
                w._parents.append(frozenset(map(int, l[2:].split(' '))))
 
122
                included = map(int, l[2:].split(' '))
 
123
                full = set()
 
124
                for pv in included:
 
125
                    full.add(pv)
 
126
                    full.update(w._v[pv])
 
127
                w._addversion(full)
109
128
            else:
110
 
                w._parents.append(frozenset())
 
129
                w._addversion(None)
111
130
 
112
131
            l = f.readline()[:-1]
113
132
            assert l.startswith('1 ')
125
144
        if l == 'W\n':
126
145
            break
127
146
        elif l.startswith('. '):
128
 
            w._weave.append(l[2:])  # include newline
 
147
            w._l.append(intern(l[2:]))  # include newline
129
148
        elif l.startswith(', '):
130
 
            w._weave.append(l[2:-1])        # exclude newline
 
149
            w._l.append(l[2:-1])        # exclude newline
131
150
        else:
132
151
            assert l[0] in '{}[]', l
133
152
            assert l[1] == ' ', l
134
 
            w._weave.append((intern(l[0]), int(l[2:])))
 
153
            w._l.append((intern(l[0]), int(l[2:])))
135
154
 
136
155
    return w
137
156