~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-06-16 18:29:13 UTC
  • mfrom: (1780.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060616182913-d8dc0e4491aaa253
(robertc, j-a-meinel)Implement a sort key and comparison routine for the walkdirs prefix-order path output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
846
846
        for dir in reversed(dirblock):
847
847
            if dir[2] == _directory:
848
848
                pending.append(dir)
 
849
 
 
850
 
 
851
def path_prefix_key(path):
 
852
    """Generate a prefix-order path key for path.
 
853
 
 
854
    This can be used to sort paths in the same way that walkdirs does.
 
855
    """
 
856
    return (dirname(path) , path)
 
857
 
 
858
 
 
859
def compare_paths_prefix_order(path_a, path_b):
 
860
    """Compare path_a and path_b to generate the same order walkdirs uses."""
 
861
    key_a = path_prefix_key(path_a)
 
862
    key_b = path_prefix_key(path_b)
 
863
    return cmp(key_a, key_b)