Part of bzrlib
|Function||pack_stat||Convert stat values into a packed representation|
|Function||bisect_dirblock||Return the index where to insert dirname into the dirblocks.|
|Function||cmp_by_dirs||Compare two paths directory by directory.|
|Function||_unpack_stat||Turn a packed_stat back into the stat fields.|
|Function||_bisect_path_left||Return the index where to insert path into paths.|
|Function||_bisect_path_right||Return the index where to insert path into paths.|
|Function||_cmp_path_by_dirblock||Compare two paths based on what directory they are in.|
|Function||_read_dirblocks||Read in the dirblocks for the given DirState object.|
Not all of the fields from the stat included are strictly needed, and by just encoding the mtime and mode a slight speed increase could be gained. However, using the pyrex version instead is a bigger win.
This is meant as a debugging tool, should not be used in real code.
Return the index where to insert path into paths.
This uses the dirblock sorting. So all children in a directory come before the children of children. For example:
a/ b/ c d/ e b-c d-e a-a a=c
Will be sorted as:
a a-a a=c a/b a/b-c a/d a/d-e a/b/c a/d/e
|Parameters||paths||A list of paths to search through|
|path||A single path to insert|
|Returns||An offset where 'path' can be inserted.|
Return the index where to insert path into paths. This uses a path-wise comparison so we get:: a a-b a=b a/b Rather than:: a a-b a/b a=b :param paths: A list of paths to search through :param path: A single path to insert :return: An offset where 'path' can be inserted. :seealso: bisect.bisect_right
The return value idx is such that all directories blocks in dirblock[:idx] have names < dirname, and all blocks in dirblock[idx:] have names >= dirname.
Optional args lo (default 0) and hi (default len(dirblocks)) bound the slice of a to be searched.
This is equivalent to doing:
The idea is that you should compare path components separately. This differs from plain cmp(path1, path2) for paths like 'a-b' and a/b. "a-b" comes after "a" but would come before "a/b" lexically.
|Returns||negative number if path1 comes first, 0 if paths are equal, and positive number if path2 sorts first|
This generates a sort order, such that all children of a directory are sorted together, and grandchildren are in the same order as the children appear. But all grandchildren come after all children.
|path2||the second path|
|Returns||negative number if path1 comes first, 0 if paths are equal and a positive number if path2 sorts first|