00000086
     	ˆÃÂÁ581ÀÅÄ E    	‹      Õ–ÛŽÚ0†ï÷)\_ô†ÃÔÝ�jK�ŠÊb©ªªª�‰±HìÈžÀÒ§¯CRÁRPiÕVËEäñä÷x¾±ãØ{ÚãÏÃy?~è‘áÇw½n›Ð
À§f Å‹Ëj­ÐéSB#Äô`µZUWÍª6s� Â$¾‹F†XåÈ©áå>ÿ‚x‘`ÜµÄC‰±ð»Š‹'¢gt†VráÆ­-p±”¡°¹�"�0Íò§JsQƒD$Ú¬¯!Õ+a<("¹ØP÷¦š¯ó9ë%¾³I˜M7Óä¦ñ=ŒÈ’År®ZuJ}O&sbMØ¢ C­,Lc¦Õ¹œQÂblÑ/Ýöà«ÓFùhßc$2bÖ¢oÛ­þÝ P¿Ïá;¬ypš{ê÷˜E’h.gRð£âÇBü(¿š@ØÐÈ¥V[)8Ä]ÔPÇ6eŽõÊDfWUHø¯ªÁÂgÅÞ�:ýqÐ%áyˆmv²ZÔ2#’@¢ó•8Eì×jjÓ»]R&kä<BêR!•¿A˜©…Ò+µé
x�Ùµ
©¿iv“ÜËªQk\WêõJã©ÝÜ6¯9"tä‡ÿ™~†Úf6ŠO¸ˆÙz’XGsÀ{†pN�FÇÔ/�“�—‚`2…2¢\ŠÉBr·<œg¸:{¹ýZnŸ1šPù�†o±JÇÉHõ›—†d‘a¶³‹þ¯QyÎ	¾·ŸûÏ0³l¾Ãµéþû“ðÄ”W16=ŠËåwd ¿
    6   ˆl—Ým_J	õ4Ÿº‚ œP\e«Œ…LZ7ÿ�þB g�:FÆ6/ç¿ƒh¹ÂÆÅ      1
  A   ˆl–Ü4ý( ©”u( 	•íÀà™S�ÿ�þBGÜY¹DGÃ Â�ÏÀƒu�½Ã_ŠI|¥�+Wé3ž¯ÈÇ –    # Copyright (C) 2006-2009 by Jelmer Vernooij
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


"""Upgrading revisions made with older versions of the mapping."""

from ... import (
    osutils,
    trace,
    ui,
    )
from ...errors import (
    BzrError,
    )
from .rebase import (
    generate_transpose_plan,
    CommitBuilderRevisionRewriter,
    rebase,
    rebase_todo,
    )


class UpgradeChangesContent(BzrError):
    """Inconsistency was found upgrading the mapping of a revision."""
    _fmt = """Upgrade will change contents in revision %(revid)s. Use --allow-changes to override."""

    def __init__(self, revid):
        self.revid = revid


def create_deterministic_revid(revid, new_parents):
    """Create a new deterministic revision id with specified new parents.

    Prevents suffix to be appended needlessly.

    :param revid: Original revision id.
    :return: New revision id
    """
    if "-rebase-" in revid:
        revid = revid[0:revid.rfind("-rebase-")]
    return revid + "-rebase-" + osutils.sha_string(":".join(new_parents))[:8]


def upgrade_tags(tags, repository, generate_rebase_map, determine_new_revid,
                 allow_changes=False, verbose=False, branch_renames=None,
                 branch_ancestry=None):
    """Upgrade a tags dictionary."""
    renames = {}
    if branch_renames is not None:
        renames.update(branch_renames)
    pb = ui.ui_factory.nested_progress_bar()
    try:
        tags_dict = tags.get_tag_dict()
        for i, (name, revid) in enumerate(tags_dict.iteritems()):
            pb.update("upgrading tags", i, len(tags_dict))
            if revid not in renames:
                try:
                    repository.lock_read()
                    revid_exists = repository.has_revision(revid)
                finally:
                    repository.unlock()
                if revid_exists:
                    renames.update(upgrade_repository(
                        repository,
                        generate_rebase_map, determine_new_revid,
                        revision_id=revid, allow_changes=allow_changes,
                        verbose=verbose))
            if (revid in renames and
                    (branch_ancestry is None or revid not in branch_ancestry)):
                tags.set_tag(name, renames[revid])
    finally:
        pb.finished()


def upgrade_branch(branch, generate_rebase_map, determine_new_revid,
                   allow_changes=False, verbose=False):
    """Upgrade a branch to the current mapping version.

    :param branch: Branch to upgrade.
    :param foreign_repository: Repository to fetch new revisions from
    :param allow_changes: A