~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_dirstate_helpers_py.py

  • Committer: Sabin Iacob
  • Date: 2009-03-23 14:59:43 UTC
  • mto: (4189.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4193.
  • Revision ID: iacobs@m0n5t3r.info-20090323145943-3s3p1px5q1rkh2e5
update FSF mailing address

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
"""Python implementations of Dirstate Helper functions."""
18
18
 
20
20
 
21
21
# We cannot import the dirstate module, because it loads this module
22
22
# All we really need is the IN_MEMORY_MODIFIED constant
 
23
from bzrlib import errors
23
24
from bzrlib.dirstate import DirState
24
25
 
25
26
 
200
201
    fields = text.split('\0')
201
202
    # Remove the last blank entry
202
203
    trailing = fields.pop()
203
 
    assert trailing == ''
 
204
    if trailing != '':
 
205
        raise errors.DirstateCorrupt(state,
 
206
            'trailing garbage: %r' % (trailing,))
204
207
    # consider turning fields into a tuple.
205
208
 
206
209
    # skip the first field which is the trailing null from the header.
217
220
    expected_field_count = entry_size * state._num_entries
218
221
    field_count = len(fields)
219
222
    # this checks our adjustment, and also catches file too short.
220
 
    assert field_count - cur == expected_field_count, \
221
 
        'field count incorrect %s != %s, entry_size=%s, '\
222
 
        'num_entries=%s fields=%r' % (
 
223
    if field_count - cur != expected_field_count:
 
224
        raise errors.DirstateCorrupt(state,
 
225
            'field count incorrect %s != %s, entry_size=%s, '\
 
226
            'num_entries=%s fields=%r' % (
223
227
            field_count - cur, expected_field_count, entry_size,
224
 
            state._num_entries, fields)
 
228
            state._num_entries, fields))
225
229
 
226
230
    if num_present_parents == 1:
227
231
        # Bind external functions to local names
269
273
                     ),
270
274
                     ])
271
275
            trailing = next()
272
 
            assert trailing == '\n'
 
276
            if trailing != '\n':
 
277
                raise ValueError("trailing garbage in dirstate: %r" % trailing)
273
278
            # append the entry to the current block
274
279
            append_entry(entry)
275
280
        state._split_root_dirblock_into_contents()
284
289
    # To convert from format 3 => format 2
285
290
    # state._dirblocks = sorted(state._dirblocks)
286
291
    state._dirblock_state = DirState.IN_MEMORY_UNMODIFIED
287