/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: Martin Pool
  • Date: 2010-04-27 07:52:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5192.
  • Revision ID: mbp@sourcefrog.net-20100427075208-nc9uf6jgwlyy5r3k
Add osutils.rename that includes the relevant filenames

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import os
18
18
import re
19
19
import stat
20
 
from stat import S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE
 
20
from stat import (S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE,
 
21
                  S_ISCHR, S_ISBLK, S_ISFIFO, S_ISSOCK)
21
22
import sys
22
23
import time
23
24
import codecs
 
25
import warnings
24
26
 
25
27
from bzrlib.lazy_import import lazy_import
26
28
lazy_import(globals(), """
27
29
from datetime import datetime
28
30
import errno
29
 
import getpass
30
31
from ntpath import (abspath as _nt_abspath,
31
32
                    join as _nt_join,
32
33
                    normpath as _nt_normpath,
1148
1149
 
1149
1150
 
1150
1151
def relpath(base, path):
1151
 
    """Return path relative to base, or raise PathNotChild exception.
 
1152
    """Return path relative to base, or raise exception.
1152
1153
 
1153
1154
    The path may be either an absolute path or a path relative to the
1154
1155
    current working directory.
1156
1157
    os.path.commonprefix (python2.4) has a bad bug that it works just
1157
1158
    on string prefixes, assuming that '/u' is a prefix of '/u2'.  This
1158
1159
    avoids that problem.
1159
 
 
1160
 
    NOTE: `base` should not have a trailing slash otherwise you'll get
1161
 
    PathNotChild exceptions regardless of `path`.
1162
1160
    """
1163
1161
 
1164
1162
    if len(base) < MIN_ABS_PATHLENGTH:
2303
2301
        return os.fdopen(os.open(filename, flags), mode, bufsize)
2304
2302
else:
2305
2303
    open_file = open
2306
 
 
2307
 
 
2308
 
def getuser_unicode():
2309
 
    """Return the username as unicode.
2310
 
    """
2311
 
    try:
2312
 
        user_encoding = get_user_encoding()
2313
 
        username = getpass.getuser().decode(user_encoding)
2314
 
    except UnicodeDecodeError:
2315
 
        raise errors.BzrError("Can't decode username as %s." % \
2316
 
                user_encoding)
2317
 
    return username