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