/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

Merge tree reference fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from io import BytesIO
23
23
from collections import defaultdict
24
24
 
 
25
from dulwich.config import (
 
26
    ConfigFile as GitConfigFile,
 
27
    parse_submodules,
 
28
    )
 
29
 
25
30
from dulwich.objects import (
26
31
    NotCommitError,
27
32
    ZERO_SHA,
809
814
        return GitMemoryTree(self, self.repository._git.object_store,
810
815
                             self.head)
811
816
 
812
 
    def reference_parent(self, path, possible_transports=None):
813
 
        """Return the parent branch for a tree-reference.
814
 
 
815
 
        :param path: The path of the nested tree in the tree
816
 
        :return: A branch associated with the nested tree
817
 
        """
818
 
        # FIXME should provide multiple branches, based on config
819
 
        url = urlutils.strip_segment_parameters(self.user_url)
820
 
        url = urlutils.join(url, path)
821
 
        return branch.Branch.open(url, possible_transports=possible_transports)
822
 
 
823
817
 
824
818
def _quick_lookup_revno(local_branch, remote_branch, revid):
825
819
    if not isinstance(revid, bytes):
980
974
            other_branch=self.source)
981
975
        return head, refs
982
976
 
 
977
    def update_references(self, revid=None):
 
978
        if revid is None:
 
979
            revid = self.target.last_revision()
 
980
        tree = self.target.repository.revision_tree(revid)
 
981
        try:
 
982
            with tree.get_file('.gitmodules') as f:
 
983
                for path, url, section in parse_submodules(
 
984
                        GitConfigFile.from_file(f)):
 
985
                    self.target.set_reference_info(
 
986
                        path.decode('utf-8'), url.decode('utf-8'),
 
987
                        tree.path2id(path.decode('utf-8')))
 
988
        except errors.NoSuchFile:
 
989
            pass
 
990
 
983
991
    def _basic_pull(self, stop_revision, overwrite, run_hooks,
984
992
                    _override_hook_target, _hook_master):
985
993
        if overwrite is True:
1007
1015
                result.tag_conflicts = tags_ret
1008
1016
            (result.new_revno, result.new_revid) = \
1009
1017
                self.target.last_revision_info()
 
1018
            self.update_references(revid=result.new_revid)
1010
1019
            if _hook_master:
1011
1020
                result.master_branch = _hook_master
1012
1021
                result.local_branch = result.target_branch
1075
1084
            self.target.tags, "tags" in overwrite, ignore_master=True)
1076
1085
        (result.tag_updates, result.tag_conflicts) = tags_ret
1077
1086
        result.new_revno, result.new_revid = self.target.last_revision_info()
 
1087
        self.update_references(revid=result.new_revid)
1078
1088
        return result
1079
1089
 
1080
1090