/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/plugins/fastimport/branch_updater.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from operator import itemgetter
21
21
 
22
22
from ... import errors, osutils, transport
23
 
from ...bzr import bzrdir
24
23
from ...trace import show_error, note
25
24
 
26
25
from .helpers import (
89
88
        # already put the 'trunk' first, do it now.
90
89
        git_to_bzr_map = {}
91
90
        for ref_name in ref_names:
92
 
            git_to_bzr_map[ref_name] = self.cache_mgr.branch_mapper.git_to_bzr(ref_name)
 
91
            git_to_bzr_map[ref_name] = self.cache_mgr.branch_mapper.git_to_bzr(
 
92
                ref_name)
93
93
        if ref_names and self.branch is None:
94
94
            trunk = self.select_trunk(ref_names)
95
95
            git_bzr_items = [(trunk, git_to_bzr_map[trunk])]
103
103
            # Using the Bazaar name, get a directory under the current one
104
104
            repo_base = self.repo.controldir.transport.base
105
105
            return osutils.pathjoin(repo_base, "..", name)
 
106
 
106
107
        def dir_sister_branch(name):
107
108
            # Using the Bazaar name, get a sister directory to the branch
108
109
            return osutils.pathjoin(self.branch.base, "..", name)
113
114
 
114
115
        # Create/track missing branches
115
116
        can_create_branches = (
116
 
                self.repo.is_shared() or
117
 
                self.repo.controldir._format.colocated_branches)
 
117
            self.repo.is_shared() or
 
118
            self.repo.controldir._format.colocated_branches)
118
119
        for ref_name, name in git_bzr_items:
119
120
            tip = self.heads_by_ref[ref_name][0]
120
121
            if can_create_branches:
124
125
                    continue
125
126
                except errors.BzrError as ex:
126
127
                    show_error("ERROR: failed to create branch %s: %s",
127
 
                        name, ex)
 
128
                               name, ex)
128
129
            lost_head = self.cache_mgr.lookup_committish(tip)
129
130
            lost_info = (name, lost_head)
130
131
            lost_heads.append(lost_info)
157
158
            except errors.NotBranchError as ex:
158
159
                return self.repo.controldir.create_branch(name)
159
160
 
160
 
 
161
161
    def _update_branch(self, br, last_mark):
162
162
        """Update a branch with last revision and tag information.
163
163
 
176
176
        my_tags = {}
177
177
        if self.tags:
178
178
            graph = self.repo.get_graph()
179
 
            ancestry = [r for (r, ps) in graph.iter_ancestry([last_rev_id]) if ps is not None]
 
179
            ancestry = [r for (r, ps) in graph.iter_ancestry(
 
180
                [last_rev_id]) if ps is not None]
180
181
            for tag, rev in self.tags.items():
181
182
                if rev in ancestry:
182
183
                    my_tags[tag] = rev
186
187
        if changed:
187
188
            tagno = len(my_tags)
188
189
            note("\t branch %s now has %d %s and %d %s", br.nick,
189
 
                revno, single_plural(revno, "revision", "revisions"),
190
 
                tagno, single_plural(tagno, "tag", "tags"))
 
190
                 revno, single_plural(revno, "revision", "revisions"),
 
191
                 tagno, single_plural(tagno, "tag", "tags"))
191
192
        return changed