~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weavefile.py

  • Committer: Martin Pool
  • Date: 2005-07-15 23:35:18 UTC
  • Revision ID: mbp@sourcefrog.net-20050715233518-04217797d302244f
- optimization for Inventory.id2path; access byid map directly rather than 
  through the __getitem__ on the inventory; rather faster

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
57
            # mininc = weave.minimal_parents(version)
58
58
            mininc = included
67
67
 
68
68
    print >>f, 'w'
69
69
 
70
 
    for l in weave._weave:
 
70
    for l in weave._l:
71
71
        if isinstance(l, tuple):
72
72
            assert l[0] in '{}[]'
73
73
            print >>f, '%s %d' % l
105
105
            ver += 1
106
106
 
107
107
            if len(l) > 2:
108
 
                w._parents.append(frozenset(map(int, l[2:].split(' '))))
 
108
                included = map(int, l[2:].split(' '))
 
109
                w._addversion(included)
109
110
            else:
110
 
                w._parents.append(frozenset())
 
111
                w._addversion(None)
111
112
 
112
113
            l = f.readline()[:-1]
113
114
            assert l.startswith('1 ')
125
126
        if l == 'W\n':
126
127
            break
127
128
        elif l.startswith('. '):
128
 
            w._weave.append(l[2:])  # include newline
 
129
            w._l.append(intern(l[2:]))  # include newline
129
130
        elif l.startswith(', '):
130
 
            w._weave.append(l[2:-1])        # exclude newline
 
131
            w._l.append(l[2:-1])        # exclude newline
131
132
        else:
132
133
            assert l[0] in '{}[]', l
133
134
            assert l[1] == ' ', l
134
 
            w._weave.append((intern(l[0]), int(l[2:])))
 
135
            w._l.append((intern(l[0]), int(l[2:])))
135
136
 
136
137
    return w
137
138