51
54
send_changeset(b, revision, to, message, file)
53
57
class cmd_changeset(Command):
54
58
"""Generate a bundled up changeset.
56
60
This changeset contains all of the meta-information of a
57
61
diff, rather than just containing the patch information.
59
BASE - This is the target tree with which you want to merge.
60
It will be used as the base for all patches. Anyone
61
wanting to merge the changeset will be required to have BASE
62
TARGET - This is the final revision which is desired to be in the
63
changeset. It defaults to the last committed revision. './@'
64
STARTING-REV-ID - All revisions between STARTING-REV and TARGET will
65
be bundled up in the changeset. By default this is
66
chosen as the merge root.
70
If --verbose, renames will be given as an 'add + delete' style patch.
71
If --revision is given, it has several states:
72
--revision A..B A is chosen as the base and B is chosen as the target
73
--revision A A is chosen as the target, and the base is it's primary parent
74
--revision ..B B is chosen as the target, and the base is it's primary parent
76
--message will replace the global message with the one supplied. Though this
77
will not be saved in the final revision messages.
64
- Changeset for the last commit
66
- Changeset to apply the current tree into BASE
68
- Changeset for revision A
69
bzr cset --revision A..B
70
- Changeset to transform A into B
71
bzr cset --revision A..B BASE
72
- Changeset to transform revision A of BASE into revision B
79
takes_options = ['verbose', 'revision', 'message']
80
takes_args = ['base?', 'target?', 'starting-rev-id?']
75
takes_options = ['verbose', 'revision']
76
takes_args = ['base?']
83
def run(self, base=None, target=None, starting_rev_id=None,
84
verbose=False, revision=None, message=None):
85
from bzrlib.commands import parse_spec
86
from bzrlib.errors import BzrCommandError
79
def run(self, base=None, revision=None):
87
80
from bzrlib import user_encoding
91
if revision is not None:
92
if (target is not None or base is not None):
93
raise BzrCommandError('--revision superceeds base and target')
94
if len(revision) == 1:
95
target_info = revision[0]
97
elif len(revision) == 2:
98
target_info = revision[1]
99
base_info = revision[0]
101
raise BzrCommandError('--revision can take at most 2 arguments')
103
target_branch, relpath = Branch.open_containing('.')
104
target_revno, target_rev_id = target_info.in_history(target_branch)
105
base_branch = target_branch
106
if base_info is not None:
107
base_revno, base_rev_id = base_info.in_history(target_branch)
109
target_rev = target_branch.get_revision(target_rev_id)
110
if hasattr(target_rev, 'parent_ids'):
111
base_rev_id = target_rev.parent_ids[0]
113
base_rev_id = target_rev.parents[0].revision_id
117
b_target_path, target_revno = parse_spec(target)
118
target_branch, relpath = Branch.open_containing(b_target_path)
119
if target_revno is None or target_revno == -1:
120
if hasattr(target_branch, 'last_patch'):
121
target_rev_id = target_branch.last_patch()
123
target_rev_id = target_branch.last_revision()
125
target_rev_id = target_branch.get_rev_id(target_revno)
128
base_branch = target_branch
129
target_rev = target_branch.get_revision(target_rev_id)
130
if hasattr(target_rev, 'parent_ids'):
131
base_rev_id = target_rev.parent_ids[0]
133
base_rev_id = target_rev.parents[0].revision_id
135
base_path, base_revno = parse_spec(base)
136
base_branch, relpath = Branch.open_containing(base_path)
137
if base_revno is None or base_revno == -1:
138
if hasattr(target_branch, 'last_patch'):
139
base_rev_id = target_branch.last_patch()
141
base_rev_id = target_branch.last_revision()
143
base_rev_id = base_branch.get_rev_id(base_revno)
145
# outf = codecs.getwriter(user_encoding)(sys.stdout,
148
if starting_rev_id is not None:
149
raise BzrCommandError('Specifying the STARTING-REV-ID'
150
' not yet supported')
152
gen_changeset.show_changeset(base_branch, base_rev_id,
153
target_branch, target_rev_id,
155
to_file=sys.stdout, include_full_diff=verbose,
81
from bzrlib.changeset.serializer import write
82
from bzrlib.fetch import fetch
87
base_branch = Branch.open(base)
89
# We don't want to lock the same branch across
90
# 2 different branches
91
target_branch = Branch.open_containing(u'.')[0]
92
if base_branch is not None and target_branch.base == base_branch.base:
97
target_revision = target_branch.last_revision()
98
if base_branch is not None:
99
base_revision = base_branch.last_revision()
100
elif len(revision) == 1:
101
target_revision = revision[0].in_history(target_branch).rev_id
102
if base_branch is not None:
103
base_revision = base_branch.last_revision()
104
elif len(revision) == 2:
105
target_revision = revision[0].in_history(target_branch).rev_id
106
if base_branch is not None:
107
base_revision = revision[1].in_history(base_branch).rev_id
109
base_revision = revision[1].in_history(target_branch).rev_id
111
raise errors.BzrCommandError('--revision takes 1 or 2 parameters')
113
if base_revision is None:
114
rev = target_branch.get_revision(target_revision)
116
base_revision = rev.parent_ids[0]
118
base_revision = NULL_REVISION
120
if base_branch is not None:
121
fetch(target_branch, base_branch, base_revision)
123
revision_id_list = get_intervening_revisions(target_revision, base_revision,
124
target_branch, target_branch.revision_history())
126
write(target_branch, revision_id_list, sys.stdout)
158
129
class cmd_verify_changeset(Command):
159
130
"""Read a written changeset, and make sure it is valid.