~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_dirstate_helpers_py.py

  • Committer: Aaron Bentley
  • Date: 2007-08-16 00:54:00 UTC
  • mto: This revision was merged to the branch mainline in revision 2711.
  • Revision ID: aaron.bentley@utoronto.ca-20070816005400-oxxtqiy310wx10h9
Fix typo

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2007 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., 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
"""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
24
23
from bzrlib.dirstate import DirState
25
24
 
26
25
 
145
144
 
146
145
    :param path1: first path
147
146
    :param path2: second path
148
 
    :return: negative number if ``path1`` comes first,
 
147
    :return: positive number if ``path1`` comes first,
149
148
        0 if paths are equal,
150
 
        and positive number if ``path2`` sorts first
 
149
        and negative number if ``path2`` sorts first
151
150
    """
152
151
    if not isinstance(path1, str):
153
152
        raise TypeError("'path1' must be a plain string, not %s: %r"
167
166
 
168
167
    :param path1: first path
169
168
    :param path2: the second path
170
 
    :return: negative number if ``path1`` comes first,
 
169
    :return: positive number if ``path1`` comes first,
171
170
        0 if paths are equal
172
 
        and a positive number if ``path2`` sorts first
 
171
        and a negative number if ``path2`` sorts first
173
172
    """
174
173
    if not isinstance(path1, str):
175
174
        raise TypeError("'path1' must be a plain string, not %s: %r"
201
200
    fields = text.split('\0')
202
201
    # Remove the last blank entry
203
202
    trailing = fields.pop()
204
 
    if trailing != '':
205
 
        raise errors.DirstateCorrupt(state,
206
 
            'trailing garbage: %r' % (trailing,))
 
203
    assert trailing == ''
207
204
    # consider turning fields into a tuple.
208
205
 
209
206
    # skip the first field which is the trailing null from the header.
220
217
    expected_field_count = entry_size * state._num_entries
221
218
    field_count = len(fields)
222
219
    # this checks our adjustment, and also catches file too short.
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' % (
 
220
    assert field_count - cur == expected_field_count, \
 
221
        'field count incorrect %s != %s, entry_size=%s, '\
 
222
        'num_entries=%s fields=%r' % (
227
223
            field_count - cur, expected_field_count, entry_size,
228
 
            state._num_entries, fields))
 
224
            state._num_entries, fields)
229
225
 
230
226
    if num_present_parents == 1:
231
227
        # Bind external functions to local names
273
269
                     ),
274
270
                     ])
275
271
            trailing = next()
276
 
            if trailing != '\n':
277
 
                raise ValueError("trailing garbage in dirstate: %r" % trailing)
 
272
            assert trailing == '\n'
278
273
            # append the entry to the current block
279
274
            append_entry(entry)
280
275
        state._split_root_dirblock_into_contents()
289
284
    # To convert from format 3 => format 2
290
285
    # state._dirblocks = sorted(state._dirblocks)
291
286
    state._dirblock_state = DirState.IN_MEMORY_UNMODIFIED
 
287