/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.5.1 by John Arbash Meinel
Just an initial working step.
1
#!/usr/bin/env python
2
"""\
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.
7
"""
8
9
import bzrlib, bzrlib.commands
10
11
class cmd_changeset(bzrlib.commands.Command):
12
    """Generate a bundled up changeset.
13
14
    This changeset contains all of the meta-information of a
15
    diff, rather than just containing the patch information.
0.5.7 by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information.
16
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
20
    to display.
0.5.1 by John Arbash Meinel
Just an initial working step.
21
    """
0.5.3 by John Arbash Meinel
Added a couple more bits
22
    takes_options = ['revision', 'diff-options']
0.5.1 by John Arbash Meinel
Just an initial working step.
23
    takes_args = ['file*']
24
    aliases = ['cset']
25
26
    def run(self, revision=None, file_list=None, diff_options=None):
27
        from bzrlib import find_branch
28
        import gen_changeset
29
        import sys
30
0.5.7 by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information.
31
        if isinstance(revision, (list, tuple)):
32
            if len(revision) > 1:
33
                raise BzrCommandError('We do not support rollup-changesets yet.')
34
            revision = revision[0]
0.5.1 by John Arbash Meinel
Just an initial working step.
35
        if file_list:
36
            b = find_branch(file_list[0])
37
            file_list = [b.relpath(f) for f in file_list]
38
            if file_list == ['']:
39
                # just pointing to top-of-tree
40
                file_list = None
41
        else:
42
            b = find_branch('.')
43
44
        gen_changeset.show_changeset(b, revision,
45
                specific_files=file_list,
46
                external_diff_options=diff_options,
47
                to_file=sys.stdout)
48
0.5.7 by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information.
49
class cmd_verify_changeset(bzrlib.commands.Command):
50
    """Read a written changeset, and make sure it is valid.
51
52
    """
53
    takes_args = ['filename?']
54
55
    def run(self, filename=None):
56
        import sys, read_changeset
57
        if filename is None or filename == '-':
58
            f = sys.stdin
59
        else:
60
            f = open(filename, 'rb')
61
0.5.17 by John Arbash Meinel
adding apply-changset, plus more meta information.
62
        cset_info = read_changeset.read_changeset(f)
63
        print cset_info
64
        cset = cset_info.get_changeset()
65
        print cset.entries
0.5.7 by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information.
66
0.5.15 by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing.
67
class cmd_apply_changeset(bzrlib.commands.Command):
68
    """Read in the given changeset, and apply it to the
69
    current tree.
70
71
    """
72
    takes_args = ['filename?']
73
    takes_options = []
74
0.5.18 by John Arbash Meinel
Some minor fixups
75
    def run(self, filename=None, reverse=False, auto_commit=False):
0.5.15 by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing.
76
        from bzrlib import find_branch
0.5.17 by John Arbash Meinel
adding apply-changset, plus more meta information.
77
        import sys
78
        import apply_changeset
0.5.15 by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing.
79
80
        b = find_branch('.') # Make sure we are in a branch
81
        if filename is None or filename == '-':
82
            f = sys.stdin
83
        else:
84
            f = open(filename, 'rb')
85
0.5.17 by John Arbash Meinel
adding apply-changset, plus more meta information.
86
        apply_changeset.apply_changeset(b, f, reverse=reverse,
87
                auto_commit=auto_commit)
0.5.15 by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing.
88
0.5.7 by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information.
89
0.5.22 by John Arbash Meinel
Properly registering the plugin.
90
if hasattr(bzrlib.commands, 'register_plugin_command'):
91
    bzrlib.commands.register_plugin_command(cmd_changeset)
92
    bzrlib.commands.register_plugin_command(cmd_verify_changeset)
93
    bzrlib.commands.register_plugin_command(cmd_apply_changeset)
0.5.15 by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing.
94
95
    bzrlib.commands.OPTIONS['reverse'] = None
0.5.17 by John Arbash Meinel
adding apply-changset, plus more meta information.
96
    bzrlib.commands.OPTIONS['auto-commit'] = None
0.5.15 by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing.
97
    cmd_apply_changeset.takes_options.append('reverse')
0.5.17 by John Arbash Meinel
adding apply-changset, plus more meta information.
98
    cmd_apply_changeset.takes_options.append('auto-commit')
0.5.1 by John Arbash Meinel
Just an initial working step.
99