/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/plugins/git/remote.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-05-15 18:47:57 UTC
  • mfrom: (6964.2.7 python3-git)
  • Revision ID: breezy.the.bot@gmail.com-20180515184757-xozniaj9gztgtom8
Port some of brz-git to python3.

Merged from https://code.launchpad.net/~jelmer/brz/python3-git/+merge/345479

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    )
48
48
from ...transport import (
49
49
    Transport,
 
50
    register_urlparse_netloc_protocol,
50
51
    )
51
52
 
52
53
from . import (
111
112
import select
112
113
import tempfile
113
114
import urllib
114
 
import urlparse
 
115
 
 
116
try:
 
117
    import urllib.parse as urlparse
 
118
    from urllib.parse import splituser, splitnport
 
119
except ImportError:
 
120
    import urlparse
 
121
    from urllib import splituser, splitnport
115
122
 
116
123
# urlparse only supports a limited number of schemes by default
117
 
 
118
 
urlparse.uses_netloc.extend(['git', 'git+ssh'])
 
124
register_urlparse_netloc_protocol('git')
 
125
register_urlparse_netloc_protocol('git+ssh')
119
126
 
120
127
from dulwich.pack import load_pack_index
121
128
 
151
158
    :return: Tuple with host, port, username, path.
152
159
    """
153
160
    (scheme, netloc, loc, _, _) = urlparse.urlsplit(url)
154
 
    path = urllib.unquote(loc)
 
161
    path = urlparse.unquote(loc)
155
162
    if path.startswith("/~"):
156
163
        path = path[1:]
157
 
    (username, hostport) = urllib.splituser(netloc)
158
 
    (host, port) = urllib.splitnport(hostport, None)
 
164
    (username, hostport) = splituser(netloc)
 
165
    (host, port) = splitnport(hostport, None)
159
166
    return (host, port, username, path)
160
167
 
161
168
 
370
377
                result.refs = {}
371
378
            self._refs = remote_refs_dict_to_container(result.refs, result.symrefs)
372
379
            return result
373
 
        except GitProtocolError, e:
 
380
        except GitProtocolError as e:
374
381
            raise parse_git_error(self.transport.external_url(), e)
375
382
        finally:
376
383
            if pb is not None:
389
396
        try:
390
397
            return self._client.send_pack(self._client_path,
391
398
                    get_changed_refs_wrapper, generate_pack_data, progress)
392
 
        except GitProtocolError, e:
 
399
        except GitProtocolError as e:
393
400
            raise parse_git_error(self.transport.external_url(), e)
394
401
        finally:
395
402
            if pb is not None:
825
832
        :return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
826
833
        """
827
834
        refs = self.controldir.get_refs_container()
828
 
        for ref_name, unpeeled in refs.as_dict().iteritems():
 
835
        for ref_name, unpeeled in refs.as_dict().items():
829
836
            try:
830
837
                tag_name = ref_to_tag_name(ref_name)
831
838
            except (ValueError, UnicodeDecodeError):
845
852
def remote_refs_dict_to_container(refs_dict, symrefs_dict={}):
846
853
    base = {}
847
854
    peeled = {}
848
 
    for k, v in refs_dict.iteritems():
 
855
    for k, v in refs_dict.items():
849
856
        if is_peeled(k):
850
857
            peeled[k[:-3]] = v
851
858
        else:
852
859
            base[k] = v
853
860
            peeled[k] = v
854
 
    for name, target in symrefs_dict.iteritems():
 
861
    for name, target in symrefs_dict.items():
855
862
        base[name] = SYMREF + target
856
863
    ret = DictRefsContainer(base)
857
864
    ret._peeled = peeled