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

  • Committer: Jelmer Vernooij
  • Date: 2018-03-31 13:08:14 UTC
  • mto: (0.200.1907 work)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180331130814-anu0utl2c4pdx2j8
Test RemoteGitDir.push_branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    ui,
26
26
    urlutils,
27
27
    )
28
 
from ...controldir import (
 
28
from ...push import (
29
29
    PushResult,
30
30
    )
31
31
from ...errors import (
53
53
from .branch import (
54
54
    GitBranch,
55
55
    GitBranchFormat,
 
56
    GitBranchPushResult,
56
57
    GitTags,
57
58
    )
58
59
from .dir import (
89
90
    Pack,
90
91
    pack_objects_to_data,
91
92
    )
 
93
from dulwich.protocol import ZERO_SHA
92
94
from dulwich.refs import SYMREF
93
95
from dulwich.repo import DictRefsContainer
94
96
import os
415
417
        push_result.branch_push_result = None
416
418
        repo = self.find_repository()
417
419
        refname = self._get_selected_ref(name)
418
 
        def get_changed_refs(refs):
419
 
            self._refs = dict(refs)
420
 
            ret = dict(refs)
421
 
            ret[refname] = repo.lookup_bzr_revision_id(revision_id)[0]
422
 
            return ret
423
420
        source_store = get_object_store(source.repository)
424
 
        if lossy:
425
 
            generate_pack_data = source_store.generate_lossy_pack_data
426
 
        else:
427
 
            generate_pack_data = source_store.generate_pack_data
428
 
        new_refs = self.send_pack(get_changed_refs, generate_pack_data)
 
421
        with source_store.lock_read():
 
422
            def get_changed_refs(refs):
 
423
                self._refs = remote_refs_dict_to_container(refs)
 
424
                ret = dict(refs)
 
425
                # TODO(jelmer): Unpeel if necessary
 
426
                if lossy:
 
427
                    ret[refname] = source_store._lookup_revision_sha1(revision_id)
 
428
                else:
 
429
                    ret[refname] = repo.lookup_bzr_revision_id(revision_id)[0]
 
430
                return ret
 
431
            if lossy:
 
432
                generate_pack_data = source_store.generate_lossy_pack_data
 
433
            else:
 
434
                generate_pack_data = source_store.generate_pack_data
 
435
            new_refs = self.send_pack(get_changed_refs, generate_pack_data)
429
436
        push_result.new_revid = repo.lookup_foreign_revision_id(
430
437
                new_refs[refname])
431
 
        self._refs.update(new_refs)
432
 
        push_result.old_revid = repo.lookup_foreign_revision_id(
433
 
                self._refs.get(refname, ZERO_SHA))
 
438
        try:
 
439
            old_remote = self._refs[refname]
 
440
        except KeyError:
 
441
            old_remote = ZERO_SHA
 
442
        push_result.old_revid = repo.lookup_foreign_revision_id(old_remote)
 
443
        self._refs = remote_refs_dict_to_container(new_refs)
434
444
        push_result.old_revno = None
435
445
        push_result.target_branch = self.open_branch(name)
 
446
        if old_remote != ZERO_SHA:
 
447
            push_result.branch_push_result = GitBranchPushResult()
 
448
            push_result.branch_push_result.source_branch = source
 
449
            push_result.branch_push_result.target_branch = push_result.target_branch
 
450
            push_result.branch_push_result.local_branch = None
 
451
            push_result.branch_push_result.master_branch = push_result.target_branch
 
452
            push_result.branch_push_result.old_revid = push_result.old_revid
 
453
            push_result.branch_push_result.new_revid = push_result.new_revid
436
454
        if source.get_push_location() is None or remember:
437
455
            source.set_push_location(push_result.target_branch.base)
438
456
        return push_result