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
|
0.5.17
by John Arbash Meinel
adding apply-changset, plus more meta information. |
16 |
"""\
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
17 |
This contains functionality for installing bundles into repositories
|
0.5.17
by John Arbash Meinel
adding apply-changset, plus more meta information. |
18 |
"""
|
19 |
||
5753.2.1
by Jelmer Vernooij
Work around lazy import issues. |
20 |
from bzrlib import ui |
6150.3.8
by Jonathan Riddell
fix order of imports |
21 |
from bzrlib.i18n import gettext |
22 |
from bzrlib.merge import Merger |
|
1185.82.84
by Aaron Bentley
Moved stuff around |
23 |
from bzrlib.progress import ProgressPhase |
6150.3.8
by Jonathan Riddell
fix order of imports |
24 |
from bzrlib.trace import note |
5815.4.1
by Jelmer Vernooij
Split versionedfile-specific stuff out into VersionedFileRepository. |
25 |
from bzrlib.vf_repository import install_revision |
1185.82.81
by Aaron Bentley
Remove unused functionality |
26 |
|
0.5.67
by John Arbash Meinel
Working on apply_changeset |
27 |
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
28 |
def install_bundle(repository, bundle_reader): |
2520.4.6
by Aaron Bentley
Get installation started |
29 |
custom_install = getattr(bundle_reader, 'install', None) |
30 |
if custom_install is not None: |
|
31 |
return custom_install(repository) |
|
5753.2.1
by Jelmer Vernooij
Work around lazy import issues. |
32 |
pb = ui.ui_factory.nested_progress_bar() |
1185.82.64
by Aaron Bentley
Lock repository while installing revisions |
33 |
repository.lock_write() |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
34 |
try: |
1793.2.2
by Aaron Bentley
Move BundleReader into v07 serializer |
35 |
real_revisions = bundle_reader.real_revisions |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
36 |
for i, revision in enumerate(reversed(real_revisions)): |
6150.3.3
by Jonathan Riddell
gettext() bzrlib/bundle |
37 |
pb.update(gettext("Install revisions"),i, len(real_revisions)) |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
38 |
if repository.has_revision(revision.revision_id): |
39 |
continue
|
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
40 |
cset_tree = bundle_reader.revision_tree(repository, |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
41 |
revision.revision_id) |
42 |
install_revision(repository, revision, cset_tree) |
|
43 |
finally: |
|
1185.82.64
by Aaron Bentley
Lock repository while installing revisions |
44 |
repository.unlock() |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
45 |
pb.finished() |
1185.82.40
by Aaron Bentley
Started work on testing install_revisions/handling empty changesets |
46 |
|
1185.82.81
by Aaron Bentley
Remove unused functionality |
47 |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
48 |
def merge_bundle(reader, tree, check_clean, merge_type, |
1551.11.9
by Aaron Bentley
Apply change reporting to merge |
49 |
reprocess, show_base, change_reporter=None): |
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
50 |
"""Merge a revision bundle into the current tree."""
|
5753.2.1
by Jelmer Vernooij
Work around lazy import issues. |
51 |
pb = ui.ui_factory.nested_progress_bar() |
1185.82.62
by Aaron Bentley
Don't fail if some data is already installed |
52 |
try: |
1185.82.84
by Aaron Bentley
Moved stuff around |
53 |
pp = ProgressPhase("Merge phase", 6, pb) |
54 |
pp.next_phase() |
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
55 |
install_bundle(tree.branch.repository, reader) |
4961.2.20
by Martin Pool
Resolve conflicts with trunk |
56 |
merger = Merger(tree.branch, this_tree=tree, |
1551.11.9
by Aaron Bentley
Apply change reporting to merge |
57 |
change_reporter=change_reporter) |
1185.82.84
by Aaron Bentley
Moved stuff around |
58 |
merger.pp = pp |
59 |
merger.pp.next_phase() |
|
4721.3.2
by Vincent Ladeuil
Simplify mutable_tree.has_changes() and update call sites. |
60 |
if check_clean and tree.has_changes(): |
61 |
raise errors.UncommittedChanges(self) |
|
1793.2.2
by Aaron Bentley
Move BundleReader into v07 serializer |
62 |
merger.other_rev_id = reader.target |
63 |
merger.other_tree = merger.revision_tree(reader.target) |
|
64 |
merger.other_basis = reader.target |
|
1185.82.84
by Aaron Bentley
Moved stuff around |
65 |
merger.pp.next_phase() |
66 |
merger.find_base() |
|
67 |
if merger.base_rev_id == merger.other_rev_id: |
|
6138.3.1
by Jonathan Riddell
use gettext() in more files |
68 |
note(gettext("Nothing to do.")) |
1185.82.84
by Aaron Bentley
Moved stuff around |
69 |
return 0 |
70 |
merger.merge_type = merge_type |
|
71 |
merger.show_base = show_base |
|
72 |
merger.reprocess = reprocess |
|
73 |
conflicts = merger.do_merge() |
|
74 |
merger.set_pending() |
|
75 |
finally: |
|
76 |
pb.clear() |
|
77 |
return conflicts |