~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Robert Collins
  • Date: 2006-07-30 14:02:21 UTC
  • mto: (1852.15.6 Tree.walkdirs)
  • mto: This revision was merged to the branch mainline in revision 1899.
  • Revision ID: robertc@robertcollins.net-20060730140221-19d4964ea23f4406
Add some useful summary data to osutils.walkdirs output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
875
875
    to exclude some directories, they are then not descended into.
876
876
    
877
877
    The data yielded is of the form:
878
 
    [(relpath, basename, kind, lstat, path_from_top), ...]
 
878
    ((directory-relpath, directory-path-from-root),
 
879
    [(relpath, basename, kind, lstat), ...]),
 
880
     - directory-relpath is the containing dirs relpath from prefix
 
881
     - directory-path-from-root is the containing dirs path from /
 
882
     - relpath is the relative path within the subtree being walked.
 
883
     - basename is the basename of the path
 
884
     - kind is the kind of the file now. If unknonwn then the file is not
 
885
       present within the tree - but it may be recorded as versioned. See
 
886
       versioned_kind.
 
887
     - lstat is the stat data *if* the file was statted.
 
888
     - planned, not implemented: 
 
889
       path_from_tree_root is the path from the root of the tree.
879
890
 
880
891
    :param prefix: Prefix the relpaths that are yielded with 'prefix'. This 
881
892
        allows one to walk a subtree but get paths that are relative to a tree
882
893
        rooted higher up.
883
894
    :return: an iterator over the dirs.
884
895
    """
 
896
    #TODO there is a bit of a smell where the results of the directory-
 
897
    # summary in this, and the path from the root, may not agree 
 
898
    # depending on top and prefix - i.e. ./foo and foo as a pair leads to
 
899
    # potentially confusing output. We should make this more robust - but
 
900
    # not at a speed cot. RBC 20060731
885
901
    lstat = os.lstat
886
902
    pending = []
887
903
    _directory = _directory_kind
900
916
            abspath = top + '/' + name
901
917
            statvalue = lstat(abspath)
902
918
            dirblock.append ((relroot + name, name, file_kind_from_stat_mode(statvalue.st_mode), statvalue, abspath))
903
 
        yield dirblock
 
919
        yield (currentdir[0], top), dirblock
904
920
        # push the user specified dirs from dirblock
905
921
        for dir in reversed(dirblock):
906
922
            if dir[2] == _directory: