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

  • Committer: Jelmer Vernooij
  • Date: 2020-07-05 12:50:01 UTC
  • mfrom: (7490.40.46 work)
  • mto: (7490.40.48 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200705125001-7s3vo0p55szbbws7
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Remote dirs, repositories and branches."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import gzip
20
22
from io import BytesIO
21
23
import re
48
50
    )
49
51
from ..revision import NULL_REVISION
50
52
from ..revisiontree import RevisionTree
 
53
from ..sixish import (
 
54
    text_type,
 
55
    viewitems,
 
56
    )
51
57
from ..transport import (
52
58
    Transport,
53
59
    register_urlparse_netloc_protocol,
117
123
import os
118
124
import select
119
125
 
120
 
import urllib.parse as urlparse
121
 
from urllib.parse import splituser
 
126
try:
 
127
    import urllib.parse as urlparse
 
128
    from urllib.parse import splituser
 
129
except ImportError:
 
130
    import urlparse
 
131
    from urllib import splituser
122
132
 
123
133
# urlparse only supports a limited number of schemes by default
124
134
register_urlparse_netloc_protocol('git')
201
211
        return PermissionDenied(url, message)
202
212
    if message.endswith(' does not appear to be a git repository'):
203
213
        return NotBranchError(url, message)
204
 
    if message == 'pre-receive hook declined':
205
 
        return PermissionDenied(url, message)
206
214
    if re.match('(.+) is not a valid repository name',
207
215
                message.splitlines()[0]):
208
216
        return NotBranchError(url, message)
209
 
    if message == (
210
 
            'GitLab: You are not allowed to push code to protected branches '
211
 
            'on this project.'):
212
 
        return PermissionDenied(url, message)
213
217
    m = re.match(r'Permission to ([^ ]+) denied to ([^ ]+)\.', message)
214
218
    if m:
215
219
        return PermissionDenied(m.group(1), 'denied to %s' % m.group(2))
602
606
        push_result.branch_push_result = None
603
607
        repo = self.find_repository()
604
608
        refname = self._get_selected_ref(name)
605
 
        try:
606
 
            ref_chain, old_sha = self.get_refs_container().follow(refname)
607
 
        except NotBranchError:
 
609
        ref_chain, old_sha = self.get_refs_container().follow(refname)
 
610
        if ref_chain:
 
611
            actual_refname = ref_chain[-1]
 
612
        else:
608
613
            actual_refname = refname
609
 
            old_sha = None
610
 
        else:
611
 
            if ref_chain:
612
 
                actual_refname = ref_chain[-1]
613
 
            else:
614
 
                actual_refname = refname
615
614
        if isinstance(source, GitBranch) and lossy:
616
615
            raise errors.LossyPushToSameVCS(source.controldir, self)
617
616
        source_store = get_object_store(source.repository)
631
630
                    raise errors.NoRoundtrippingSupport(
632
631
                        source, self.open_branch(name=name, nascent_ok=True))
633
632
            if not overwrite:
634
 
                old_sha = remote_refs.get(actual_refname)
635
633
                if remote_divergence(old_sha, new_sha, source_store):
636
634
                    raise DivergedBranches(
637
635
                        source, self.open_branch(name, nascent_ok=True))
638
636
            ret[actual_refname] = new_sha
639
637
            if fetch_tags:
640
 
                for tagname, revid in source.tags.get_tag_dict().items():
 
638
                for tagname, revid in viewitems(source.tags.get_tag_dict()):
641
639
                    if tag_selector and not tag_selector(tagname):
642
640
                        continue
643
641
                    if lossy:
1082
1080
            if peeled is None:
1083
1081
                # Let's just hope it's a commit
1084
1082
                peeled = unpeeled
1085
 
            if not isinstance(tag_name, str):
 
1083
            if not isinstance(tag_name, text_type):
1086
1084
                raise TypeError(tag_name)
1087
1085
            yield (ref_name, tag_name, peeled, unpeeled)
1088
1086