~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: v.ladeuil+lp at free
  • Date: 2007-05-18 18:20:31 UTC
  • mto: (2485.8.44 bzr.connection.sharing)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070518182031-gbg2cgidv5l20x9p
Takes Robert comments into account.

* bzrlib/transport/ftp.py:
(FtpTransport.__init__): Write a better explanation.

* bzrlib/tests/test_init.py:
(InstrumentedTransport): Just make hooks a class attribute.
(InstrumentedTransport._get_FTP): Run hook directly in the for
loop.
(TransportHooks.run_hook, TransportHooks.uninstall_hook): Not
needed. The hooks should be cleaned up by the test itself.
(TestInit.setUp.cleanup): Resset to default hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
# OR with 0 on those platforms
70
70
O_BINARY = getattr(os, 'O_BINARY', 0)
71
71
 
72
 
# On posix, use lstat instead of stat so that we can
73
 
# operate on broken symlinks. On Windows revert to stat.
74
 
lstat = getattr(os, 'lstat', os.stat)
75
72
 
76
73
def make_readonly(filename):
77
74
    """Make a filename read-only."""
78
 
    mod = lstat(filename).st_mode
79
 
    if not stat.S_ISLNK(mod):
80
 
        mod = mod & 0777555
81
 
        os.chmod(filename, mod)
 
75
    mod = os.stat(filename).st_mode
 
76
    mod = mod & 0777555
 
77
    os.chmod(filename, mod)
82
78
 
83
79
 
84
80
def make_writable(filename):
85
 
    mod = lstat(filename).st_mode
86
 
    if not stat.S_ISLNK(mod):
87
 
        mod = mod | 0200
88
 
        os.chmod(filename, mod)
 
81
    mod = os.stat(filename).st_mode
 
82
    mod = mod | 0200
 
83
    os.chmod(filename, mod)
89
84
 
90
85
 
91
86
_QUOTE_RE = None
1154
1149
        path-from-top might be unicode or utf8, but it is the correct path to
1155
1150
        pass to os functions to affect the file in question. (such as os.lstat)
1156
1151
    """
1157
 
    fs_encoding = _fs_enc.upper()
 
1152
    fs_encoding = sys.getfilesystemencoding()
1158
1153
    if (sys.platform == 'win32' or
1159
1154
        fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968')): # ascii
1160
1155
        return _walkdirs_unicode_to_utf8(top, prefix=prefix)