~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

  • Committer: Martin Packman
  • Date: 2011-11-28 19:07:58 UTC
  • mfrom: (6318 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6319.
  • Revision ID: martin.packman@canonical.com-20111128190758-5gj44o5uzwz5sjfq
Merge bzr.dev to resolve conflicts with updated registry help strings

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
        raise ValueError('Length of base (%r) must equal or'
79
79
            ' exceed the platform minimum url length (which is %d)' %
80
80
            (base, MIN_ABS_FILEURL_LENGTH))
81
 
    base = local_path_from_url(base)
82
 
    path = local_path_from_url(path)
 
81
    base = osutils.normpath(local_path_from_url(base))
 
82
    path = osutils.normpath(local_path_from_url(path))
83
83
    return escape(osutils.relpath(base, path))
84
84
 
85
85
 
441
441
    :param url: A relative or absolute URL
442
442
    :return: (url, subsegments)
443
443
    """
444
 
    (parent_url, child_dir) = split(url)
445
 
    subsegments = child_dir.split(",")
446
 
    if len(subsegments) == 1:
 
444
    # GZ 2011-11-18: Dodgy removing the terminal slash like this, function
 
445
    #                operates on urls not url+segments, and Transport classes
 
446
    #                should not be blindly adding slashes in the first place. 
 
447
    lurl = strip_trailing_slash(url)
 
448
    # Segments begin at first comma after last forward slash, if one exists
 
449
    segment_start = lurl.find(",", lurl.rfind("/")+1)
 
450
    if segment_start == -1:
447
451
        return (url, [])
448
 
    return (join(parent_url, subsegments[0]), subsegments[1:])
 
452
    return (lurl[:segment_start], lurl[segment_start+1:].split(","))
449
453
 
450
454
 
451
455
def split_segment_parameters(url):
750
754
        else:
751
755
            self.password = None
752
756
        self.port = port
753
 
        self.quoted_path = quoted_path
 
757
        self.quoted_path = _url_hex_escapes_re.sub(_unescape_safe_chars, quoted_path)
754
758
        self.path = urllib.unquote(self.quoted_path)
755
759
 
756
760
    def __eq__(self, other):
835
839
        """
836
840
        if not isinstance(relpath, str):
837
841
            raise errors.InvalidURL(relpath)
 
842
        relpath = _url_hex_escapes_re.sub(_unescape_safe_chars, relpath)
838
843
        if relpath.startswith('/'):
839
844
            base_parts = []
840
845
        else:
866
871
        if offset is not None:
867
872
            relative = unescape(offset).encode('utf-8')
868
873
            path = self._combine_paths(self.path, relative)
869
 
            path = urllib.quote(path)
 
874
            path = urllib.quote(path, safe="/~")
870
875
        else:
871
876
            path = self.quoted_path
872
877
        return self.__class__(self.scheme, self.quoted_user,