67
67
If --verbose, renames will be given as an 'add + delete' style patch.
68
If --revision is given, it has several states:
69
--revision A..B A is chosen as the base and B is chosen as the target
70
--revision A A is chosen as the target, and the base is it's primary parent
71
--revision ..B B is chosen as the target, and the base is it's primary parent
69
takes_options = ['verbose']
74
takes_options = ['verbose', 'revision']
70
75
takes_args = ['base?', 'target?', 'starting-rev-id?']
73
def run(self, base=None, target=None, starting_rev_id=None, verbose=False):
78
def run(self, base=None, target=None, starting_rev_id=None, verbose=False, revision=None):
74
79
from bzrlib.branch import find_branch
75
80
from bzrlib.commands import parse_spec
76
81
from bzrlib.errors import BzrCommandError
84
b_target_path, target_revno = parse_spec(target)
85
target_branch = find_branch(b_target_path)
86
if target_revno is None or target_revno == -1:
87
target_rev_id = target_branch.last_patch()
89
target_rev_id = target_branch.lookup_revision(target_revno)
87
if revision is not None:
88
if (target is not None or base is not None):
89
raise BzrCommandError('--revision superceeds base and target')
90
if len(revision) == 1:
91
target_info = revision[0]
93
elif len(revision) == 2:
94
target_info = revision[1]
95
base_info = revision[0]
97
raise BzrCommandError('--revision can take at most 2 arguments')
99
target_branch = find_branch('.')
100
target_rev_id = target_branch.lookup_revision(target_info)
92
101
base_branch = target_branch
93
target_rev = target_branch.get_revision(target_rev_id)
94
base_rev_id = target_rev.parents[0].revision_id
102
if base_info is not None:
103
base_rev_id = target_branch.lookup_revision(base_info)
105
target_rev = target_branch.get_revision(target_rev_id)
106
base_rev_id = target_rev.parents[0].revision_id
96
base_path, base_revno = parse_spec(base)
97
base_branch = find_branch(base_path)
98
if base_revno is None or base_revno == -1:
99
base_rev_id = base_branch.last_patch()
101
base_rev_id = base_branch.lookup_revision(base_revno)
110
b_target_path, target_revno = parse_spec(target)
111
target_branch = find_branch(b_target_path)
112
if target_revno is None or target_revno == -1:
113
target_rev_id = target_branch.last_patch()
115
target_rev_id = target_branch.lookup_revision(target_revno)
118
base_branch = target_branch
119
target_rev = target_branch.get_revision(target_rev_id)
120
base_rev_id = target_rev.parents[0].revision_id
122
base_path, base_revno = parse_spec(base)
123
base_branch = find_branch(base_path)
124
if base_revno is None or base_revno == -1:
125
base_rev_id = base_branch.last_patch()
127
base_rev_id = base_branch.lookup_revision(base_revno)
103
129
# outf = codecs.getwriter(user_encoding)(sys.stdout,
104
130
# errors='replace')