/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/branch.py

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-11 20:19:38 UTC
  • mfrom: (7526.3.2 work)
  • Revision ID: gustav.hartvigsson@gmail.com-20210111201938-omr9wjz3qdgyxe8k
MergedĀ lp:brz

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
    warning,
60
60
    )
61
61
 
62
 
from .config import (
63
 
    GitBranchConfig,
64
 
    GitBranchStack,
65
 
    )
66
62
from .errors import (
67
63
    NoPushSupport,
68
64
    )
 
65
from .mapping import (
 
66
    encode_git_path,
 
67
    decode_git_path,
 
68
    )
69
69
from .push import (
70
70
    remote_divergence,
71
71
    )
132
132
        updates = {}
133
133
        conflicts = []
134
134
        source_tag_refs = self.source.branch.get_tag_refs()
 
135
        ref_to_tag_map = {}
135
136
 
136
137
        def get_changed_refs(old_refs):
137
138
            ret = dict(old_refs)
145
146
                    ret[ref_name] = unpeeled
146
147
                    updates[tag_name] = self.target.branch.repository.lookup_foreign_revision_id(
147
148
                        peeled)
 
149
                    ref_to_tag_map[ref_name] = tag_name
148
150
                    self.target.branch._tag_refs = None
149
151
                else:
150
152
                    conflicts.append(
153
155
                         self.target.branch.repository.lookup_foreign_revision_id(
154
156
                             old_refs[ref_name])))
155
157
            return ret
156
 
        self.target.branch.repository.controldir.send_pack(
 
158
        result = self.target.branch.repository.controldir.send_pack(
157
159
            get_changed_refs, lambda have, want: [])
 
160
        if result is not None and not isinstance(result, dict):
 
161
            for ref, error in result.ref_status.items():
 
162
                if error:
 
163
                    warning('unable to update ref %s: %s',
 
164
                            ref, error)
 
165
                    del updates[ref_to_tag_map[ref]]
158
166
        return updates, set(conflicts)
159
167
 
160
168
 
474
482
        return "git"
475
483
 
476
484
    def get_config(self):
 
485
        from .config import GitBranchConfig
477
486
        return GitBranchConfig(self)
478
487
 
479
488
    def get_config_stack(self):
 
489
        from .config import GitBranchStack
480
490
        return GitBranchStack(self)
481
491
 
482
492
    def _get_nick(self, local=False, possible_master_transports=None):
488
498
            cs = self.repository._git.get_config_stack()
489
499
            try:
490
500
                return cs.get((b"branch", self.name.encode('utf-8')),
491
 
                              b"nick").decode("utf-8")
 
501
                        b"nick").decode("utf-8")
492
502
            except KeyError:
493
503
                pass
494
504
        return self.name or u"HEAD"
1033
1043
                for path, url, section in parse_submodules(
1034
1044
                        GitConfigFile.from_file(f)):
1035
1045
                    self.target.set_reference_info(
1036
 
                        tree.path2id(path.decode('utf-8')), url.decode('utf-8'),
1037
 
                        path.decode('utf-8'))
 
1046
                        tree.path2id(decode_git_path(path)), url.decode('utf-8'),
 
1047
                        decode_git_path(path))
1038
1048
        except errors.NoSuchFile:
1039
1049
            pass
1040
1050
 
1165
1175
                isinstance(target, RemoteGitBranch))
1166
1176
 
1167
1177
    def _basic_push(self, overwrite, stop_revision, tag_selector=None):
 
1178
        from .remote import parse_git_error
1168
1179
        result = GitBranchPushResult()
1169
1180
        result.source_branch = self.source
1170
1181
        result.target_branch = self.target
1196
1207
                    continue
1197
1208
                refs[tag_name_to_ref(name)] = sha
1198
1209
            return refs
1199
 
        self.target.repository.send_pack(
 
1210
        dw_result = self.target.repository.send_pack(
1200
1211
            get_changed_refs,
1201
1212
            self.source.repository._git.generate_pack_data)
 
1213
        if dw_result is not None and not isinstance(dw_result, dict):
 
1214
            error = dw_result.ref_status.get(self.target.ref)
 
1215
            if error:
 
1216
                raise parse_git_error(self.target.user_url, error)
 
1217
            for ref, error in dw_result.ref_status.items():
 
1218
                if error:
 
1219
                    trace.warning('unable to open ref %s: %s', ref, error)
1202
1220
        return result
1203
1221
 
1204
1222
 
1370
1388
               old_refs, new_refs)
1371
1389
        result.tag_updates = {}
1372
1390
        result.tag_conflicts = []
1373
 
        ret = dict(old_refs)
 
1391
        ret = {}
1374
1392
 
1375
1393
        def ref_equals(refs, ref, git_sha, revid):
1376
1394
            try:
1433
1451
                ret.append((None, v))
1434
1452
        ret.append((None, stop_revision))
1435
1453
        try:
1436
 
            revidmap = self.interrepo.fetch_objects(ret, lossy=lossy, limit=limit)
 
1454
            revidmap = self.interrepo.fetch_revs(ret, lossy=lossy, limit=limit)
1437
1455
        except NoPushSupport:
1438
1456
            raise errors.NoRoundtrippingSupport(self.source, self.target)
1439
1457
        return _mod_repository.FetchResult(revidmap={