~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weavefile.py

  • Committer: Vincent Ladeuil
  • Date: 2010-03-02 10:21:39 UTC
  • mfrom: (4797.2.24 2.1)
  • mto: This revision was merged to the branch mainline in revision 5069.
  • Revision ID: v.ladeuil+lp@free.fr-20100302102139-b5cba7h6xu13mekg
Merge 2.1 into trunk including fixes for #331095, #507557, #185103, #524184 and #369501

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
#
17
17
# Author: Martin Pool <mbp@canonical.com>
18
18
 
72
72
 
73
73
    for l in weave._weave:
74
74
        if isinstance(l, tuple):
75
 
            assert l[0] in '{}[]'
76
75
            if l[0] == '}':
77
76
                f.write('}\n')
78
77
            else:
81
80
            if not l:
82
81
                f.write(', \n')
83
82
            elif l[-1] == '\n':
84
 
                assert l.find('\n', 0, -1) == -1
85
83
                f.write('. ' + l)
86
84
            else:
87
 
                assert l.find('\n') == -1
88
85
                f.write(', ' + l + '\n')
89
86
 
90
87
    f.write('W\n')
102
99
 
103
100
def _read_weave_v5(f, w):
104
101
    """Private helper routine to read a weave format 5 file into memory.
105
 
    
 
102
 
106
103
    This is only to be used by read_weave and WeaveFile.__init__.
107
104
    """
108
105
    #  200   0   2075.5080   1084.0360   bzrlib.weavefile:104(_read_weave_v5)
118
115
    #  200   0    851.7250    501.1120   bzrlib.weavefile:104(_read_weave_v5)
119
116
    # +59363 0    311.8780    311.8780   +<method 'append' of 'list' objects>
120
117
    # +200   0     30.2500     30.2500   +<method 'readlines' of 'file' objects>
121
 
                  
 
118
 
122
119
    from weave import WeaveFormatError
123
120
 
124
121
    lines = iter(f.readlines())
125
 
    
 
122
 
126
123
    try:
127
124
        l = lines.next()
128
125
    except StopIteration:
140
137
                w._parents.append(map(int, l[2:].split(' ')))
141
138
            else:
142
139
                w._parents.append([])
143
 
 
144
140
            l = lines.next()[:-1]
145
 
            assert '1 ' == l[0:2]
146
141
            w._sha1s.append(l[2:])
147
 
                
148
142
            l = lines.next()
149
 
            assert 'n ' == l[0:2]
150
143
            name = l[2:-1]
151
 
            assert name not in w._name_map
152
144
            w._names.append(name)
153
145
            w._name_map[name] = ver
154
 
                
155
146
            l = lines.next()
156
 
            assert l == '\n'
157
 
 
158
147
            ver += 1
159
148
        elif l == 'w\n':
160
149
            break
173
162
        elif l == '}\n':
174
163
            w._weave.append(('}', None))
175
164
        else:
176
 
            assert l[0] in '{[]', l
177
 
            assert l[1] == ' ', l
178
165
            w._weave.append((intern(l[0]), int(l[2:])))
179
 
 
180
166
    return w
181