/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Alexander Belchenko
  • Date: 2007-09-22 17:29:16 UTC
  • mfrom: (2846 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2864.
  • Revision ID: bialix@ukr.net-20070922172916-yzl05wpf8ye852gw
Bug #140419 fixed by Robert Collins

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
        os.chmod(filename, mod)
88
88
 
89
89
 
 
90
def minimum_path_selection(paths):
 
91
    """Return the smallset subset of paths which are outside paths.
 
92
 
 
93
    :param paths: A container (and hence not None) of paths.
 
94
    :return: A set of paths sufficient to include everything in paths via
 
95
        is_inside_any, drawn from the paths parameter.
 
96
    """
 
97
    search_paths = set()
 
98
    paths = set(paths)
 
99
    for path in paths:
 
100
        other_paths = paths.difference([path])
 
101
        if not is_inside_any(other_paths, path):
 
102
            # this is a top level path, we must check it.
 
103
            search_paths.add(path)
 
104
    return search_paths
 
105
 
 
106
 
90
107
_QUOTE_RE = None
91
108
 
92
109
 
786
803
            raise
787
804
        shutil.copyfile(src, dest)
788
805
 
789
 
def delete_any(full_path):
 
806
 
 
807
# Look Before You Leap (LBYL) is appropriate here instead of Easier to Ask for
 
808
# Forgiveness than Permission (EAFP) because:
 
809
# - root can damage a solaris file system by using unlink,
 
810
# - unlink raises different exceptions on different OSes (linux: EISDIR, win32:
 
811
#   EACCES, OSX: EPERM) when invoked on a directory.
 
812
def delete_any(path):
790
813
    """Delete a file or directory."""
791
 
    try:
792
 
        os.unlink(full_path)
793
 
    except OSError, e:
794
 
    # We may be renaming a dangling inventory id
795
 
        if e.errno not in (errno.EISDIR, errno.EACCES, errno.EPERM):
796
 
            raise
797
 
        os.rmdir(full_path)
 
814
    if isdir(path): # Takes care of symlinks
 
815
        os.rmdir(path)
 
816
    else:
 
817
        os.unlink(path)
798
818
 
799
819
 
800
820
def has_symlinks():
802
822
        return True
803
823
    else:
804
824
        return False
805
 
        
 
825
 
806
826
 
807
827
def contains_whitespace(s):
808
828
    """True if there are any whitespace characters in s."""