26
26
from bzrlib import BZRDIR
27
27
from bzrlib.commands import Command, display_command
28
28
from bzrlib.branch import Branch
29
from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError, NotBranchError
30
from bzrlib.errors import DivergedBranches
29
from bzrlib.revision import common_ancestor
30
from bzrlib.errors import (BzrError, BzrCheckError, BzrCommandError,
31
NotBranchError, DivergedBranches, NotConflicted)
31
32
from bzrlib.option import Option
32
33
from bzrlib.revisionspec import RevisionSpec
33
34
import bzrlib.trace
1397
class cmd_remerge(Command):
1400
takes_args = ['file*']
1401
takes_options = ['merge-type', 'reprocess',
1402
Option('show-base', help="Show base revision text in "
1405
def run(self, file_list=None, merge_type=None, show_base=False,
1407
from bzrlib.merge import merge_inner, transform_tree
1408
from bzrlib.merge_core import ApplyMerge3
1409
if merge_type is None:
1410
merge_type = ApplyMerge3
1411
b, file_list = branch_files(file_list)
1414
pending_merges = b.pending_merges()
1415
if len(pending_merges) != 1:
1416
raise BzrCommandError("Sorry, remerge only works after normal"
1417
+ " merges. Not cherrypicking or"
1419
this_tree = b.working_tree()
1420
base_revision = common_ancestor(b.last_revision(),
1421
pending_merges[0], b)
1422
base_tree = b.revision_tree(base_revision)
1423
other_tree = b.revision_tree(pending_merges[0])
1424
interesting_ids = None
1425
if file_list is not None:
1426
interesting_ids = set()
1427
for filename in file_list:
1428
file_id = this_tree.path2id(filename)
1429
interesting_ids.add(file_id)
1430
if this_tree.kind(file_id) != "directory":
1432
for name, ie in this_tree.inventory.iter_entries(file_id):
1433
interesting_ids.add(ie.file_id)
1434
transform_tree(this_tree, b.basis_tree(), interesting_ids)
1435
if file_list is None:
1436
restore_files = list(this_tree.iter_conflicts())
1438
restore_files = file_list
1439
for filename in restore_files:
1441
restore(this_tree.abspath(filename))
1442
except NotConflicted:
1444
conflicts = merge_inner(b, other_tree, base_tree,
1445
interesting_ids = interesting_ids,
1446
other_rev_id=pending_merges[0],
1447
merge_type=merge_type,
1448
show_base=show_base,
1449
reprocess=reprocess)
1396
1457
class cmd_revert(Command):
1397
1458
"""Reverse all changes since the last commit.
1643
1704
# TODO: Some more consistent way to split command definitions across files;
1644
1705
# we do need to load at least some information about them to know of
1646
from bzrlib.conflicts import cmd_resolve, cmd_conflicts
1707
from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore