~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_dirstate_helpers_py.py

  • Committer: John Arbash Meinel
  • Date: 2008-08-25 21:50:11 UTC
  • mfrom: (0.11.3 tools)
  • mto: This revision was merged to the branch mainline in revision 3659.
  • Revision ID: john@arbash-meinel.com-20080825215011-de9esmzgkue3e522
Merge in Lukáš's helper scripts.
Update the packaging documents to describe how to do the releases
using bzr-builddeb to package all distro platforms
simultaneously.

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
 
27
 
def _bisect_path_left(paths, path):
 
26
def _bisect_path_left_py(paths, path):
28
27
    """Return the index where to insert path into paths.
29
28
 
30
29
    This uses the dirblock sorting. So all children in a directory come before
63
62
        mid = (lo + hi) // 2
64
63
        # Grab the dirname for the current dirblock
65
64
        cur = paths[mid]
66
 
        if _cmp_path_by_dirblock(cur, path) < 0:
 
65
        if _cmp_path_by_dirblock_py(cur, path) < 0:
67
66
            lo = mid + 1
68
67
        else:
69
68
            hi = mid
70
69
    return lo
71
70
 
72
71
 
73
 
def _bisect_path_right(paths, path):
 
72
def _bisect_path_right_py(paths, path):
74
73
    """Return the index where to insert path into paths.
75
74
 
76
75
    This uses a path-wise comparison so we get::
94
93
        mid = (lo+hi)//2
95
94
        # Grab the dirname for the current dirblock
96
95
        cur = paths[mid]
97
 
        if _cmp_path_by_dirblock(path, cur) < 0:
 
96
        if _cmp_path_by_dirblock_py(path, cur) < 0:
98
97
            hi = mid
99
98
        else:
100
99
            lo = mid + 1
101
100
    return lo
102
101
 
103
102
 
104
 
def bisect_dirblock(dirblocks, dirname, lo=0, hi=None, cache={}):
 
103
def bisect_dirblock_py(dirblocks, dirname, lo=0, hi=None, cache={}):
105
104
    """Return the index where to insert dirname into the dirblocks.
106
105
 
107
106
    The return value idx is such that all directories blocks in dirblock[:idx]
132
131
    return lo
133
132
 
134
133
 
135
 
def cmp_by_dirs(path1, path2):
 
134
def cmp_by_dirs_py(path1, path2):
136
135
    """Compare two paths directory by directory.
137
136
 
138
137
    This is equivalent to doing::
158
157
    return cmp(path1.split('/'), path2.split('/'))
159
158
 
160
159
 
161
 
def _cmp_path_by_dirblock(path1, path2):
 
160
def _cmp_path_by_dirblock_py(path1, path2):
162
161
    """Compare two paths based on what directory they are in.
163
162
 
164
163
    This generates a sort order, such that all children of a directory are
184
183
    return cmp(key1, key2)
185
184
 
186
185
 
187
 
def _read_dirblocks(state):
 
186
def _read_dirblocks_py(state):
188
187
    """Read in the dirblocks for the given DirState object.
189
188
 
190
189
    This is tightly bound to the DirState internal representation. It should be
202
201
    # Remove the last blank entry
203
202
    trailing = fields.pop()
204
203
    if trailing != '':
205
 
        raise errors.DirstateCorrupt(state,
206
 
            'trailing garbage: %r' % (trailing,))
 
204
        raise AssertionError("dirstate file has trailing garbage: %r"
 
205
            % (trailing,))
207
206
    # consider turning fields into a tuple.
208
207
 
209
208
    # skip the first field which is the trailing null from the header.
221
220
    field_count = len(fields)
222
221
    # this checks our adjustment, and also catches file too short.
223
222
    if field_count - cur != expected_field_count:
224
 
        raise errors.DirstateCorrupt(state,
 
223
        raise AssertionError(
225
224
            'field count incorrect %s != %s, entry_size=%s, '\
226
225
            'num_entries=%s fields=%r' % (
227
226
            field_count - cur, expected_field_count, entry_size,
289
288
    # To convert from format 3 => format 2
290
289
    # state._dirblocks = sorted(state._dirblocks)
291
290
    state._dirblock_state = DirState.IN_MEMORY_UNMODIFIED
 
291