3
This is an attempt to take the internal delta object, and represent
4
it as a single-file text-only changeset.
5
This should have commands for both generating a changeset,
6
and for applying a changeset.
9
import bzrlib, bzrlib.commands
11
class cmd_changeset(bzrlib.commands.Command):
12
"""Generate a bundled up changeset.
14
This changeset contains all of the meta-information of a
15
diff, rather than just containing the patch information.
17
Right now, rollup changesets, or working tree changesets are
18
not supported. This will only generate a changeset that has been
19
committed. You can use "--revision" to specify a certain change
22
takes_options = ['revision', 'diff-options']
23
takes_args = ['file*']
26
def run(self, revision=None, file_list=None, diff_options=None):
27
from bzrlib import find_branch
31
if isinstance(revision, (list, tuple)):
33
raise BzrCommandError('We do not support rollup-changesets yet.')
34
revision = revision[0]
36
b = find_branch(file_list[0])
37
file_list = [b.relpath(f) for f in file_list]
39
# just pointing to top-of-tree
44
gen_changeset.show_changeset(b, revision,
45
specific_files=file_list,
46
external_diff_options=diff_options,
49
class cmd_verify_changeset(bzrlib.commands.Command):
50
"""Read a written changeset, and make sure it is valid.
53
takes_args = ['filename?']
55
def run(self, filename=None):
56
import sys, read_changeset
57
if filename is None or filename == '-':
60
f = open(filename, 'rb')
62
cset_info = read_changeset.read_changeset(f)
64
cset = cset_info.get_changeset()
67
class cmd_apply_changeset(bzrlib.commands.Command):
68
"""Read in the given changeset, and apply it to the
72
takes_args = ['filename?']
75
def run(self, filename=None, reverse=False, auto_commit=False):
76
from bzrlib import find_branch
78
import apply_changeset
80
b = find_branch('.') # Make sure we are in a branch
81
if filename is None or filename == '-':
84
f = open(filename, 'rb')
86
apply_changeset.apply_changeset(b, f, reverse=reverse,
87
auto_commit=auto_commit)
90
if hasattr(bzrlib.commands, 'register_plugin_cmd'):
91
bzrlib.commands.register_plugin_cmd(cmd_changeset)
92
bzrlib.commands.register_plugin_cmd(cmd_verify_changeset)
93
bzrlib.commands.register_plugin_cmd(cmd_apply_changeset)
95
bzrlib.commands.OPTIONS['reverse'] = None
96
bzrlib.commands.OPTIONS['auto-commit'] = None
97
cmd_apply_changeset.takes_options.append('reverse')
98
cmd_apply_changeset.takes_options.append('auto-commit')