/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5752.3.8 by John Arbash Meinel
Merge bzr.dev 5764 to resolve release-notes (aka NEWS) conflicts
1
# Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 Canonical Ltd
2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6379.6.3 by Jelmer Vernooij
Use absolute_import.
16
0.5.17 by John Arbash Meinel
adding apply-changset, plus more meta information.
17
"""\
1185.82.130 by Aaron Bentley
Rename changesets to revision bundles
18
This contains functionality for installing bundles into repositories
0.5.17 by John Arbash Meinel
adding apply-changset, plus more meta information.
19
"""
20
6379.6.7 by Jelmer Vernooij
Move importing from future until after doc string, otherwise the doc string will disappear.
21
from __future__ import absolute_import
22
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
23
from .. import ui
24
from ..i18n import gettext
25
from ..merge import Merger
26
from ..progress import ProgressPhase
27
from ..trace import note
6670.4.1 by Jelmer Vernooij
Update imports.
28
from ..bzr.vf_repository import install_revision
1185.82.81 by Aaron Bentley
Remove unused functionality
29
0.5.67 by John Arbash Meinel
Working on apply_changeset
30
1185.82.130 by Aaron Bentley
Rename changesets to revision bundles
31
def install_bundle(repository, bundle_reader):
2520.4.6 by Aaron Bentley
Get installation started
32
    custom_install = getattr(bundle_reader, 'install', None)
33
    if custom_install is not None:
34
        return custom_install(repository)
6861.4.2 by Jelmer Vernooij
Review feedback.
35
    with repository.lock_write(), ui.ui_factory.nested_progress_bar() as pb:
1793.2.2 by Aaron Bentley
Move BundleReader into v07 serializer
36
        real_revisions = bundle_reader.real_revisions
1185.82.63 by Aaron Bentley
Added install revision progress bar
37
        for i, revision in enumerate(reversed(real_revisions)):
6809.1.1 by Martin
Apply 2to3 ws_comma fixer
38
            pb.update(gettext("Install revisions"), i, len(real_revisions))
1185.82.63 by Aaron Bentley
Added install revision progress bar
39
            if repository.has_revision(revision.revision_id):
40
                continue
1185.82.130 by Aaron Bentley
Rename changesets to revision bundles
41
            cset_tree = bundle_reader.revision_tree(repository,
7143.15.2 by Jelmer Vernooij
Run autopep8.
42
                                                    revision.revision_id)
1185.82.63 by Aaron Bentley
Added install revision progress bar
43
            install_revision(repository, revision, cset_tree)
1185.82.40 by Aaron Bentley
Started work on testing install_revisions/handling empty changesets
44
1185.82.81 by Aaron Bentley
Remove unused functionality
45
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
46
def merge_bundle(reader, tree, check_clean, merge_type,
7143.15.2 by Jelmer Vernooij
Run autopep8.
47
                 reprocess, show_base, change_reporter=None):
1185.82.130 by Aaron Bentley
Rename changesets to revision bundles
48
    """Merge a revision bundle into the current tree."""
6973.11.4 by Jelmer Vernooij
use context managers.
49
    with ui.ui_factory.nested_progress_bar() as pb:
1185.82.84 by Aaron Bentley
Moved stuff around
50
        pp = ProgressPhase("Merge phase", 6, pb)
51
        pp.next_phase()
1185.82.130 by Aaron Bentley
Rename changesets to revision bundles
52
        install_bundle(tree.branch.repository, reader)
4961.2.20 by Martin Pool
Resolve conflicts with trunk
53
        merger = Merger(tree.branch, this_tree=tree,
1551.11.9 by Aaron Bentley
Apply change reporting to merge
54
                        change_reporter=change_reporter)
1185.82.84 by Aaron Bentley
Moved stuff around
55
        merger.pp = pp
56
        merger.pp.next_phase()
4721.3.2 by Vincent Ladeuil
Simplify mutable_tree.has_changes() and update call sites.
57
        if check_clean and tree.has_changes():
58
            raise errors.UncommittedChanges(self)
1793.2.2 by Aaron Bentley
Move BundleReader into v07 serializer
59
        merger.other_rev_id = reader.target
60
        merger.other_tree = merger.revision_tree(reader.target)
61
        merger.other_basis = reader.target
1185.82.84 by Aaron Bentley
Moved stuff around
62
        merger.pp.next_phase()
63
        merger.find_base()
64
        if merger.base_rev_id == merger.other_rev_id:
6138.3.1 by Jonathan Riddell
use gettext() in more files
65
            note(gettext("Nothing to do."))
1185.82.84 by Aaron Bentley
Moved stuff around
66
            return 0
67
        merger.merge_type = merge_type
68
        merger.show_base = show_base
69
        merger.reprocess = reprocess
70
        conflicts = merger.do_merge()
71
        merger.set_pending()
72
    return conflicts