/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/weavefile.py

  • Committer: Robert Collins
  • Date: 2006-03-03 02:09:49 UTC
  • mto: (1594.2.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1596.
  • Revision ID: robertc@robertcollins.net-20060303020949-0ddc6f33d0a43943
Smoke test for RevisionStore factories creating revision stores.

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
    
107
107
    This is only to be used by read_weave and WeaveFile.__init__.
108
108
    """
109
 
    #  200   0   2075.5080   1084.0360   bzrlib.weavefile:104(_read_weave_v5)
110
 
    # +60412 0    366.5900    366.5900   +<method 'readline' of 'file' objects>
111
 
    # +59982 0    320.5280    320.5280   +<method 'startswith' of 'str' objects>
112
 
    # +59363 0    297.8080    297.8080   +<method 'append' of 'list' objects>
113
 
    # replace readline call with iter over all lines ->
114
 
    # safe because we already suck on memory.
115
 
    #  200   0   1492.7170    802.6220   bzrlib.weavefile:104(_read_weave_v5)
116
 
    # +59982 0    329.9100    329.9100   +<method 'startswith' of 'str' objects>
117
 
    # +59363 0    320.2980    320.2980   +<method 'append' of 'list' objects>
118
 
    # replaced startswith with slice lookups:
119
 
    #  200   0    851.7250    501.1120   bzrlib.weavefile:104(_read_weave_v5)
120
 
    # +59363 0    311.8780    311.8780   +<method 'append' of 'list' objects>
121
 
    # +200   0     30.2500     30.2500   +<method 'readlines' of 'file' objects>
122
 
                  
123
109
    from weave import WeaveFormatError
124
110
 
125
 
    lines = iter(f.readlines())
126
 
    
127
 
    l = lines.next()
 
111
    l = f.readline()
128
112
    if l != FORMAT_1:
129
113
        raise WeaveFormatError('invalid weave file header: %r' % l)
130
114
 
131
115
    ver = 0
132
 
    # read weave header.
133
116
    while True:
134
 
        l = lines.next()
 
117
        l = f.readline()
135
118
        if l[0] == 'i':
136
119
            if len(l) > 2:
137
120
                w._parents.append(map(int, l[2:].split(' ')))
138
121
            else:
139
122
                w._parents.append([])
140
123
 
141
 
            l = lines.next()[:-1]
142
 
            assert '1 ' == l[0:2]
 
124
            l = f.readline()[:-1]
 
125
            assert l.startswith('1 ')
143
126
            w._sha1s.append(l[2:])
144
127
                
145
 
            l = lines.next()
146
 
            assert 'n ' == l[0:2]
 
128
            l = f.readline()
 
129
            assert l.startswith('n ')
147
130
            name = l[2:-1]
148
131
            assert name not in w._name_map
149
132
            w._names.append(name)
150
133
            w._name_map[name] = ver
151
134
                
152
 
            l = lines.next()
 
135
            l = f.readline()
153
136
            assert l == '\n'
154
137
 
155
138
            ver += 1
158
141
        else:
159
142
            raise WeaveFormatError('unexpected line %r' % l)
160
143
 
161
 
    # read weave body
162
144
    while True:
163
 
        l = lines.next()
 
145
        l = f.readline()
164
146
        if l == 'W\n':
165
147
            break
166
 
        elif '. ' == l[0:2]:
 
148
        elif l.startswith('. '):
167
149
            w._weave.append(l[2:])  # include newline
168
 
        elif ', ' == l[0:2]:
 
150
        elif l.startswith(', '):
169
151
            w._weave.append(l[2:-1])        # exclude newline
170
152
        elif l == '}\n':
171
153
            w._weave.append(('}', None))