/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: 2007-11-09 17:50:31 UTC
  • mto: This revision was merged to the branch mainline in revision 2988.
  • Revision ID: robertc@robertcollins.net-20071109175031-agaiy6530rvbprmb
Change (without backwards compatibility) the
iter_lines_added_or_present_in_versions VersionedFile API to yield the
text version that each line is being returned from. This is useful for
reconcile in determining what inventories reference what texts.
(Robert Collins)

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