~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: 2010-04-24 16:54:50 UTC
  • mfrom: (5183.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100424165450-2jfbk8ta0hhznynx
(vila) Only chown() the .bzr.log when creating it (Parth Malwankar)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1827
1827
            real_handlers[kind](abspath, relpath)
1828
1828
 
1829
1829
 
1830
 
def copy_ownership(dst, src=None):
 
1830
def copy_ownership_from_path(dst, src=None):
1831
1831
    """Copy usr/grp ownership from src file/dir to dst file/dir.
1832
1832
 
1833
1833
    If src is None, the containing directory is used as source. If chown
1849
1849
        trace.warning("Unable to copy ownership from '%s' to '%s': IOError: %s." % (src, dst, e))
1850
1850
 
1851
1851
 
1852
 
def mkdir_with_ownership(path, ownership_src=None):
1853
 
    """Create the directory 'path' with specified ownership.
1854
 
 
1855
 
    If ownership_src is given, copies (chown) usr/grp ownership
1856
 
    from 'ownership_src' to 'path'. If ownership_src is None, use the
1857
 
    containing dir ownership.
1858
 
    """
1859
 
    os.mkdir(path)
1860
 
    copy_ownership(path, ownership_src)
1861
 
 
1862
 
 
1863
 
def open_with_ownership(filename, mode='r', bufsize=-1, ownership_src=None):
1864
 
    """Open the file 'filename' with the specified ownership.
1865
 
 
1866
 
    If ownership_src is specified, copy usr/grp ownership from ownership_src
1867
 
    to filename. If ownership_src is None, copy ownership from containing
1868
 
    directory.
1869
 
    Returns the opened file object.
1870
 
    """
1871
 
    f = open(filename, mode, bufsize)
1872
 
    copy_ownership(filename, ownership_src)
1873
 
    return f
1874
 
 
1875
 
 
1876
1852
def path_prefix_key(path):
1877
1853
    """Generate a prefix-order path key for path.
1878
1854