/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-08-10 15:00:17 UTC
  • mfrom: (7490.40.99 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200810150017-vs7xnrd1vat4iktg
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
 
 
21
19
import gzip
22
20
from io import BytesIO
23
21
import re
50
48
    )
51
49
from ..revision import NULL_REVISION
52
50
from ..revisiontree import RevisionTree
53
 
from ..sixish import (
54
 
    text_type,
55
 
    viewitems,
56
 
    )
57
51
from ..transport import (
58
52
    Transport,
59
53
    register_urlparse_netloc_protocol,
123
117
import os
124
118
import select
125
119
 
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
 
120
import urllib.parse as urlparse
 
121
from urllib.parse import splituser
132
122
 
133
123
# urlparse only supports a limited number of schemes by default
134
124
register_urlparse_netloc_protocol('git')
211
201
        return PermissionDenied(url, message)
212
202
    if message.endswith(' does not appear to be a git repository'):
213
203
        return NotBranchError(url, message)
 
204
    if message == 'pre-receive hook declined':
 
205
        return PermissionDenied(url, message)
214
206
    if re.match('(.+) is not a valid repository name',
215
207
                message.splitlines()[0]):
216
208
        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)
217
213
    m = re.match(r'Permission to ([^ ]+) denied to ([^ ]+)\.', message)
218
214
    if m:
219
215
        return PermissionDenied(m.group(1), 'denied to %s' % m.group(2))
606
602
        push_result.branch_push_result = None
607
603
        repo = self.find_repository()
608
604
        refname = self._get_selected_ref(name)
609
 
        ref_chain, old_sha = self.get_refs_container().follow(refname)
610
 
        if ref_chain:
611
 
            actual_refname = ref_chain[-1]
612
 
        else:
 
605
        try:
 
606
            ref_chain, old_sha = self.get_refs_container().follow(refname)
 
607
        except NotBranchError:
613
608
            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
614
615
        if isinstance(source, GitBranch) and lossy:
615
616
            raise errors.LossyPushToSameVCS(source.controldir, self)
616
617
        source_store = get_object_store(source.repository)
630
631
                    raise errors.NoRoundtrippingSupport(
631
632
                        source, self.open_branch(name=name, nascent_ok=True))
632
633
            if not overwrite:
 
634
                old_sha = remote_refs.get(actual_refname)
633
635
                if remote_divergence(old_sha, new_sha, source_store):
634
636
                    raise DivergedBranches(
635
637
                        source, self.open_branch(name, nascent_ok=True))
636
638
            ret[actual_refname] = new_sha
637
639
            if fetch_tags:
638
 
                for tagname, revid in viewitems(source.tags.get_tag_dict()):
 
640
                for tagname, revid in source.tags.get_tag_dict().items():
639
641
                    if tag_selector and not tag_selector(tagname):
640
642
                        continue
641
643
                    if lossy:
1080
1082
            if peeled is None:
1081
1083
                # Let's just hope it's a commit
1082
1084
                peeled = unpeeled
1083
 
            if not isinstance(tag_name, text_type):
 
1085
            if not isinstance(tag_name, str):
1084
1086
                raise TypeError(tag_name)
1085
1087
            yield (ref_name, tag_name, peeled, unpeeled)
1086
1088