chown when the file already exists?

John Arbash Meinel john at arbash-meinel.com
Thu Mar 25 17:07:39 GMT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm just going to submit this to pqm, but bzr is broken on Windows.
Specifically the patch:

=== modified file 'bzrlib/osutils.py'
- --- bzrlib/osutils.py   2010-03-11 06:35:52 +0000
+++ bzrlib/osutils.py   2010-03-25 17:04:08 +0000
@@ -1812,8 +1812,9 @@
     If src is None, the containing directory is used as source. If chown
     fails, the error is ignored and a warning is printed.
     """
- -    has_chown = getattr(os, 'chown')
- -    if has_chown is None: return
+    chown = getattr(os, 'chown', None)
+    if chown is None:
+        return

     if src == None:
         src = os.path.dirname(dst)
@@ -1822,7 +1823,7 @@

     try:
         s = os.stat(src)
- -        os.chown(dst, s.st_uid, s.st_gid)
+        chown(dst, s.st_uid, s.st_gid)
     except OSError, e:
         trace.warning("Unable to copy ownership from '%s' to '%s':
IOError: %s." % (src, dst, e))


The big problem is "has_chown = getattr()" raises an exception if you
only use the 2 parameter form. However, this showed another issue.

Why is "bzr status" thinking about calling chown? Digging into it, I see
it is being called from:

def open_with_ownership()

Which is being called for opening .bzr.log... However, if we aren't
creating the file, should we be changing its ownership?

John
=:->


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkurmFsACgkQJdeBCYSNAANnlACgooENe9f9dtM0hfiES3ThF8S/
pa8An0SZp0c8ukERS4VLEEfrgL+Mnmmj
=+bPc
-----END PGP SIGNATURE-----



More information about the bazaar mailing list