/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 processors/generic_processor.py

save tags known about in each branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
235
235
        self.note("Updating branch information ...")
236
236
        updater = GenericBranchUpdater(self.repo, self.branch, self.cache_mgr,
237
237
            helpers.invert_dict(self.cache_mgr.heads),
238
 
            self.cache_mgr.last_ref)
 
238
            self.cache_mgr.last_ref, self.tags)
239
239
        branches_updated, branches_lost = updater.update()
240
240
        self._branch_count = len(branches_updated)
241
241
 
824
824
 
825
825
class GenericBranchUpdater(object):
826
826
 
827
 
    def __init__(self, repo, branch, cache_mgr, heads_by_ref, last_ref):
 
827
    def __init__(self, repo, branch, cache_mgr, heads_by_ref, last_ref, tags):
828
828
        """Create an object responsible for updating branches.
829
829
 
830
830
        :param heads_by_ref: a dictionary where
836
836
        self.cache_mgr = cache_mgr
837
837
        self.heads_by_ref = heads_by_ref
838
838
        self.last_ref = last_ref
 
839
        self.tags = tags
839
840
 
840
841
    def update(self):
841
842
        """Update the Bazaar branches and tips matching the heads.
948
949
        :return: whether the branch was changed or not
949
950
        """
950
951
        last_rev_id = self.cache_mgr.revision_ids[last_mark]
951
 
        revno = len(list(self.repo.iter_reverse_revision_history(last_rev_id)))
 
952
        revs = list(self.repo.iter_reverse_revision_history(last_rev_id))
 
953
        revno = len(revs)
952
954
        existing_revno, existing_last_rev_id = br.last_revision_info()
953
955
        changed = False
954
956
        if revno != existing_revno or last_rev_id != existing_last_rev_id:
955
957
            br.set_last_revision_info(revno, last_rev_id)
956
958
            changed = True
957
 
            note("\t branch %s now has %d revisions", br.nick, revno)
958
 
        # TODO: apply tags known in this branch
959
 
        #if self.tags:
960
 
        #    br.tags._set_tag_dict(self.tags)
 
959
        # apply tags known in this branch
 
960
        my_tags = {}
 
961
        if self.tags:
 
962
            for tag,rev in self.tags.items():
 
963
                if rev in revs:
 
964
                    my_tags[tag] = rev
 
965
            if my_tags:
 
966
                br.tags._set_tag_dict(my_tags)
 
967
                changed = True
 
968
        if changed:
 
969
            tagno = len(my_tags)
 
970
            note("\t branch %s now has %d %s and %d %s", br.nick,
 
971
                revno, helpers.single_plural(revno, "revision", "revisions"),
 
972
                tagno, helpers.single_plural(tagno, "tag", "tags"))
961
973
        return changed