/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 breezy/osutils.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-10-13 17:48:47 UTC
  • mfrom: (7397.5.2 python3.8-1)
  • Revision ID: breezy.the.bot@gmail.com-20191013174847-0tyzqp7oktfqjofm
Support passing bytestring paths to osutils.splitpath.

Merged from https://code.launchpad.net/~jelmer/brz/python3.8-1/+merge/374051

Show diffs side-by-side

added added

removed removed

Lines of Context:
1026
1026
 
1027
1027
def splitpath(p):
1028
1028
    """Turn string into list of parts."""
 
1029
    use_bytes = isinstance(p, bytes)
1029
1030
    if os.path.sep == '\\':
1030
1031
        # split on either delimiter because people might use either on
1031
1032
        # Windows
1032
 
        if isinstance(p, bytes):
 
1033
        if use_bytes:
1033
1034
            ps = re.split(b'[\\\\/]', p)
1034
1035
        else:
1035
1036
            ps = re.split(r'[\\/]', p)
1036
1037
    else:
1037
 
        if isinstance(p, bytes):
 
1038
        if use_bytes:
1038
1039
            ps = p.split(b'/')
1039
1040
        else:
1040
1041
            ps = p.split('/')
1041
1042
 
 
1043
    if use_bytes:
 
1044
        parent_dir = b'..'
 
1045
        current_empty_dir = (b'.', b'')
 
1046
    else:
 
1047
        parent_dir = '..'
 
1048
        current_empty_dir = ('.', '')
 
1049
 
1042
1050
    rps = []
1043
1051
    for f in ps:
1044
 
        if f in ('..', b'..'):
 
1052
        if f == parent_dir:
1045
1053
            raise errors.BzrError(gettext("sorry, %r not allowed in path") % f)
1046
 
        elif f in ('.', '', b'.', b''):
 
1054
        elif f in current_empty_dir:
1047
1055
            pass
1048
1056
        else:
1049
1057
            rps.append(f)