~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_dirstate_helpers_py.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-03-11 13:47:06 UTC
  • mfrom: (5051.3.16 use-branch-open)
  • Revision ID: pqm@pqm.ubuntu.com-20100311134706-kaerqhx3lf7xn6rh
(Jelmer) Pass colocated branch names further down the call stack.

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
"""Python implementations of Dirstate Helper functions."""
18
18
 
24
24
from bzrlib.dirstate import DirState
25
25
 
26
26
 
27
 
def _bisect_path_left_py(paths, path):
 
27
def _bisect_path_left(paths, path):
28
28
    """Return the index where to insert path into paths.
29
29
 
30
30
    This uses the dirblock sorting. So all children in a directory come before
63
63
        mid = (lo + hi) // 2
64
64
        # Grab the dirname for the current dirblock
65
65
        cur = paths[mid]
66
 
        if _cmp_path_by_dirblock_py(cur, path) < 0:
 
66
        if _cmp_path_by_dirblock(cur, path) < 0:
67
67
            lo = mid + 1
68
68
        else:
69
69
            hi = mid
70
70
    return lo
71
71
 
72
72
 
73
 
def _bisect_path_right_py(paths, path):
 
73
def _bisect_path_right(paths, path):
74
74
    """Return the index where to insert path into paths.
75
75
 
76
76
    This uses a path-wise comparison so we get::
94
94
        mid = (lo+hi)//2
95
95
        # Grab the dirname for the current dirblock
96
96
        cur = paths[mid]
97
 
        if _cmp_path_by_dirblock_py(path, cur) < 0:
 
97
        if _cmp_path_by_dirblock(path, cur) < 0:
98
98
            hi = mid
99
99
        else:
100
100
            lo = mid + 1
101
101
    return lo
102
102
 
103
103
 
104
 
def bisect_dirblock_py(dirblocks, dirname, lo=0, hi=None, cache={}):
 
104
def bisect_dirblock(dirblocks, dirname, lo=0, hi=None, cache={}):
105
105
    """Return the index where to insert dirname into the dirblocks.
106
106
 
107
107
    The return value idx is such that all directories blocks in dirblock[:idx]
132
132
    return lo
133
133
 
134
134
 
135
 
def cmp_by_dirs_py(path1, path2):
 
135
def cmp_by_dirs(path1, path2):
136
136
    """Compare two paths directory by directory.
137
137
 
138
138
    This is equivalent to doing::
158
158
    return cmp(path1.split('/'), path2.split('/'))
159
159
 
160
160
 
161
 
def _cmp_path_by_dirblock_py(path1, path2):
 
161
def _cmp_path_by_dirblock(path1, path2):
162
162
    """Compare two paths based on what directory they are in.
163
163
 
164
164
    This generates a sort order, such that all children of a directory are
184
184
    return cmp(key1, key2)
185
185
 
186
186
 
187
 
def _read_dirblocks_py(state):
 
187
def _read_dirblocks(state):
188
188
    """Read in the dirblocks for the given DirState object.
189
189
 
190
190
    This is tightly bound to the DirState internal representation. It should be
289
289
    # To convert from format 3 => format 2
290
290
    # state._dirblocks = sorted(state._dirblocks)
291
291
    state._dirblock_state = DirState.IN_MEMORY_UNMODIFIED
292